diff --git a/.gitea/workflows/docker.yml b/.gitea/workflows/docker.yml new file mode 100644 index 0000000..8332731 --- /dev/null +++ b/.gitea/workflows/docker.yml @@ -0,0 +1,30 @@ +name: Docker + +on: + push: + branches: [main] + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Log in to Gitea container registry + uses: docker/login-action@v3 + with: + registry: git.betalupi.com + username: ${{ gitea.actor }} + password: ${{ secrets.DEPLOY_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: git.betalupi.com/${{ gitea.repository }}:latest + cache-from: type=registry,ref=git.betalupi.com/${{ gitea.repository }}:cache + cache-to: type=registry,ref=git.betalupi.com/${{ gitea.repository }}:cache,mode=max diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b369ebc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +FROM rust:1.91-bookworm AS base + +# +# MARK: Build +# +FROM base AS build + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + ca-certificates wget unzip \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app/rust +COPY . . +RUN cargo build --release --workspace +RUN cargo test --release --workspace + +# +# MARK: Release +# +FROM debian:bookworm@sha256:00cd074b40c4d99ff0c24540bdde0533ca3791edcdac0de36d6b9fb3260d89e2 AS deploy + +WORKDIR /app + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=build \ + /app/rust/target/release/pile \ + /app/bin/ + +ENV PATH="/app/bin:$PATH" +ENV RUST_BACKTRACE=full + +ENTRYPOINT [""]