From e34d5c2c2cc20ae11bea377f384806a9c50515ab Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 12 May 2024 18:35:47 +0100 Subject: [PATCH] build(docker): clean up and update debian version --- .woodpecker/tag-created.yml | 4 ---- Dockerfile | 30 ++++++++++++------------------ 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/.woodpecker/tag-created.yml b/.woodpecker/tag-created.yml index 2dbc4403..6b61fda3 100644 --- a/.woodpecker/tag-created.yml +++ b/.woodpecker/tag-created.yml @@ -1,5 +1,4 @@ steps: - publish-to-forgejo: when: - event: tag @@ -23,9 +22,6 @@ steps: username: kemitix repo: git.kemitix.net/kemitix/git-next dockerfile: Dockerfile - build_args: - - CARGO_PROFILE=release - - CARGO_TARGET=release auto_tag: true dry-run: false # push to remote repo registry: git.kemitix.net diff --git a/Dockerfile b/Dockerfile index faa564f8..b8b8d4b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,21 @@ # Leveraging the pre-built Docker images with # cargo-chef and the Rust toolchain -FROM git.kemitix.net/kemitix/git-next-builder:latest AS builder +FROM git.kemitix.net/kemitix/git-next-builder:latest AS chef WORKDIR /app +FROM chef as planner COPY Cargo.toml ./ -COPY src src +COPY crates crates RUN cargo chef prepare --recipe-path recipe.json -ARG CARGO_PROFILE -# Build dependencies - this is the caching Docker layer! -RUN cargo chef cook --profile "$CARGO_PROFILE" --recipe-path recipe.json -# Build application -COPY Cargo.toml ./ -COPY src src -COPY default.toml ./ -COPY server-default.toml ./ -ARG CARGO_PROFILE -RUN cargo build --profile "$CARGO_PROFILE" --bin git-next -RUN if test "$CARGO_PROFILE" == "release" ; then strip target/release/git-next ; fi +FROM chef as builder +COPY --from=planner /app/recipe.json recipe.json +RUN cargo chef cook --profile release --recipe-path recipe.json +COPY . . +RUN cargo build --release --bin git-next && \ + strip target/release/git-next -# We do not need the Rust toolchain to run the binary! -FROM docker.io/debian:stable-20240211-slim AS runtime +FROM docker.io/debian:stable-20240423-slim AS runtime WORKDIR /app RUN apt-get update && \ apt-get install --no-install-recommends -y \ @@ -29,7 +24,6 @@ RUN apt-get update && \ && \ rm -rf /var/lib/apt/lists/* USER 1000 +COPY --from=builder /app/target/release/git-next /usr/local/bin -ARG CARGO_TARGET -COPY --from=builder /app/target/"$CARGO_TARGET"/git-next /usr/local/bin -ENTRYPOINT [ "/usr/local/bin/git-next" ] +ENTRYPOINT [ "/usr/local/bin/git-next", "server", "start" ]