build(docker): clean up and update debian version

This commit is contained in:
Paul Campbell 2024-05-12 18:35:47 +01:00
parent 4d352f005d
commit e34d5c2c2c
2 changed files with 12 additions and 22 deletions

View file

@ -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

View file

@ -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" ]