Skip to content

Commit

Permalink
make commands for docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
djkato committed Mar 11, 2024
1 parent cd54526 commit 9461c8a
Show file tree
Hide file tree
Showing 8 changed files with 36,342 additions and 43 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
target/
tmp/

Cargo.lock
Dockerfile
Makefile.toml
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM rust:alpine as chef
RUN apk add musl-dev pkgconfig openssl openssl-dev
ENV OPENSSL_DIR=/usr
# RUN rustup default nightly
# RUN rustup target add x86_64-unknown-linux-musl
RUN cargo install cargo-chef
WORKDIR /src

FROM chef as planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

FROM chef as builder
COPY --from=planner /src/recipe.json recipe.json
RUN cargo chef cook --target=x86_64-unknown-linux-musl --release --recipe-path=recipe.json
COPY . .
RUN cargo build --target=x86_64-unknown-linux-musl --release

FROM scratch as chef-sitemap-generator
COPY --from=builder /src/target/x86_64-unknown-linux-musl/release/sitemap-generator /sitemap-generator
CMD [ "/sitemap-generator" ]
LABEL service=chef-sitemap-generator
LABEL org.opencontainers.image.title="djkato/saleor-sitemap-generator"\
org.opencontainers.image.description="Creates and keeps Sitemap.xml uptodate with Saleor." \
org.opencontainers.image.url="https://github.com/djkato/saleor-apps-rs"\
org.opencontainers.image.source="https://github.com/djkato/saleor-apps-rs"\
org.opencontainers.image.authors="Djkáťo <[email protected]>"\
org.opencontainers.image.licenses="PolyForm-Noncommercial-1.0.0"

FROM scratch as chef-simple-payment-gateway
COPY --from=builder /src/target/x86_64-unknown-linux-musl/release/simple-payment-gateway /simple-payment-gateway
CMD [ "/simple-payment-gateway" ]
LABEL service=chef-simple-payment-gateway
LABEL org.opencontainers.image.title="djkato/saleor-simple-payment-gateway"\
org.opencontainers.image.description="Payment gateway that adds payment methods that don't need actual verification: Cash on delivery, Cash on warehouse pickup, bank tranfer." \
org.opencontainers.image.url="https://github.com/djkato/saleor-apps-rs"\
org.opencontainers.image.source="https://github.com/djkato/saleor-apps-rs"\
org.opencontainers.image.authors="Djkáťo <[email protected]>"\
org.opencontainers.image.licenses="PolyForm-Noncommercial-1.0.0"
39 changes: 39 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Configures the default task to run
[tasks.default]
alias = "build-containers"

# Overrides the default build task
[tasks.build]
alias = "build-containers"

[tasks.build-sitemap-generator]
workspace = false
script = '''
docker build --rm --target chef-sitemap-generator .
docker tag $(docker image ls -q --filter=label=service=chef-sitemap-generator) ghcr.io/djkato/saleor-sitemap-generator
'''

[tasks.build-simple-payment-gateway]
workspace = false
script = '''
docker build --rm --target chef-simple-payment-gateway .
docker tag $(docker image ls -q --filter=label=service=chef-simple-payment-gateway) ghcr.io/djkato/saleor-simple-payment-gateway
'''

[tasks.build-containers]
workspace = false
dependencies = ["build-sitemap-generator", "build-simple-payment-gateway"]

[tasks.push-containers]
workspace = false
script = '''
docker push ghcr.io/djkato/saleor-sitemap-generator:latest
docker push ghcr.io/djkato/saleor-simple-payment-gateway:latest
'''

[tasks.delete-containers]
workspace = false
script = '''
docker image rm $(docker image ls -q --filter=label=service=chef-simple-payment-gateway)
docker image rm $(docker image ls -q --filter=label=service=chef-sitemap-generator)
'''
53 changes: 48 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,50 @@

This repo contains the following main components:

| Crate | Description |
| --------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
| [**saleor-app-sdk**](https://crates.io/crates/saleor-app-sdk) | Types and utilities for making Saleor Apps |
| [**saleor-app-template**](https://github.com/djkato/saleor-apps-rs/tree/master/saleor-app-template) | Simple template for making Saleor apps using axum |
| [**saleor-app-sitemap**](https://crates.io/crates/saleor-app-sitemap) | Saleor App for keeping sitemap.xml uptodate |
| Crate | Description |
| ----------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| [**saleor-app-sdk**](https://crates.io/crates/sdk) | Types and utilities for making Saleor Apps |
| [**saleor-app-template**](https://github.com/djkato/saleor-apps-rs/tree/master/app-template) | Simple template for making Saleor apps using axum |
| [**saleor-app-sitemap**](https://github.com/djkato/saleor-apps-rs/tree/master/sitemap-generator) | Saleor App for keeping sitemap.xml uptodate |
| [**saleor-app-sitemap**](https://github.com/djkato/saleor-apps-rs/tree/master/simple-payment-gateway) | Saleor App that adds payment methods: Cash on delivery, Cash on warehouse pickup, bank tranfer etc. |

# Using the apps

Pick the apps you wanna use from this repo. You can find prebuilt docker images on the right sidebar next to the code tree under "Packages".
Simply add the package to your `docker-compose.yml`, for example like so:

```yml
version: "3.4"

services:
redisapl:
image: bitnami/redis:latest
environment:
- ALLOW_EMPTY_PASSWORD=yes
ports:
- 6380:6379
restart: unless-stopped
networks:
- saleor-app-tier
volumes:
- saleor-redis:/bitnami/redis/data

saleor-app-simple-gateway:
image: ghcr.io/djkato/saleor-simple-payment-gateway:latest
restart: unless-stopped
env_file:
- ./app-simple-gateway.env
ports:
- "3030:3030"
networks:
- saleor-app-tier
depends_on:
- redisapl

networks:
saleor-app-tier:
driver: bridge
```
# Using this repo
Expand Down Expand Up @@ -43,3 +82,7 @@ Each workspace member has it's licensed in it's own directory.

- saleor-app-sdk, saleor-app-template and the root structure fall under either MIT or Apache 2.0 at your convenience.
- Rest of the apps in this repo fall under `PolyForm-Noncommercial-1.0.md`. If you want to use my apps commercially, each app costs 10€ (or voluntarily more). Upon payment/donation you are allowed to use the given app commercially.

## Docker images

To build the docker image, log into ghcr.io via docker like `docker login ghcr.io -u <USER> -p <GITHUB KEY WITH PACKAGE PERMS>` run `cargo make`. To publish, run `cargo push-containers`. If you want to push image to your own place, modify `Makefile.toml` and `Dockerfile` to include your username instead of mine.
19 changes: 0 additions & 19 deletions app-template/Dockerfile

This file was deleted.

3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "nightly"
targets = ["x86_64-unknown-linux-musl"]
19 changes: 0 additions & 19 deletions simple-payment-gateway/Dockerfile

This file was deleted.

Loading

0 comments on commit 9461c8a

Please sign in to comment.