feat: update image

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2023-06-04 14:43:53 +02:00
parent 7d8722d995
commit 5b1890424e
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912
3 changed files with 39 additions and 9 deletions

View File

@ -16,7 +16,9 @@ then
fi
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker pull "$latest_tag"
#docker pull "$latest_tag"
DOCKER_BUILDKIT=1 docker build --cache-from "$latest_tag" -t "$tag" -f "$TMP/build_release.Dockerfile" .
export DOCKER_BUILDKIT=1
docker build -t "$tag" -f "$TMP/build_release.Dockerfile" --build-arg "BIN_NAME=$BIN_NAME" --target=runtime .
docker tag "$tag" "$latest_tag"

View File

@ -12,5 +12,5 @@ echo "docker: logging in"
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
echo "docker: pushing image $tag"
docker push --all-tags "$base_tag"
docker push "$base_tag"

View File

@ -1,11 +1,39 @@
FROM rust:1.62.1-slim-buster
FROM rust:1.70 AS chef
# We only pay the installation cost once,
# it will be cached from the second build onwards
RUN <<EOF
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
EOF
RUN apt-get update && apt-get upgrade -y
RUN apt-get install libssl-dev
RUN apt-get install -y -q build-essential curl
ENV DOCKER_BUILD=true
ENV SQLX_OFFLINE true
RUN <<EOF
apt update -y && apt install -y libc6-dev libssl-dev libpq-dev
EOF
RUN cargo binstall --no-confirm --no-symlinks cargo-chef
WORKDIR app
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
RUN cargo build
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --recipe-path recipe.json
# Build application
ARG BIN_NAME
COPY . .
RUN cargo build --release --bin $BIN_NAME
# We do not need the Rust toolchain to run the binary!
FROM debian:buster-slim as runtime
ARG BIN_NAME
WORKDIR app
COPY --from=builder /app/target/release/$BIN_NAME /usr/local/bin
CMD ["/usr/local/bin/$BIN_NAME"]
CMD [ "cargo", "run" ]