From 7dd0a9d0adf239b0dd722033b3bbb3da1a45f61e Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 20 Oct 2024 22:35:16 -0400 Subject: [PATCH] Update dockerfiles to take advantage of BuildKit. --- docker/webhook_bridge/Dockerfile | 9 ++++++--- docker/webhook_bridge_development/Dockerfile | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docker/webhook_bridge/Dockerfile b/docker/webhook_bridge/Dockerfile index 607c98a..74d9d18 100644 --- a/docker/webhook_bridge/Dockerfile +++ b/docker/webhook_bridge/Dockerfile @@ -1,4 +1,7 @@ -FROM rustlang/rust:nightly-alpine3.20 AS builder +# syntax=docker/dockerfile:1 +ARG ALPINE_VERSION="3.20" + +FROM rustlang/rust:nightly-alpine$ALPINE_VERSION AS builder RUN apk add --no-cache musl-dev pkgconfig libressl-dev @@ -6,9 +9,9 @@ RUN mkdir /source WORKDIR /source COPY . . # TODO: Add static build, which currently errors due to proc_macro. RUSTFLAGS="-C target-feature=+crt-static" -RUN CARGO_TARGET_DIR=/target cargo build --profile release-lto --bin webhook_bridge +RUN --mount=type=tmpfs,target=/tmp --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked CARGO_TARGET_DIR=/target cargo build --profile release-lto --bin webhook_bridge -FROM alpine:3.20 AS runner +FROM alpine:$ALPINE_VERSION AS runner COPY --from=builder /target/release-lto/webhook_bridge /usr/bin/ diff --git a/docker/webhook_bridge_development/Dockerfile b/docker/webhook_bridge_development/Dockerfile index 4ea5afe..281c58b 100644 --- a/docker/webhook_bridge_development/Dockerfile +++ b/docker/webhook_bridge_development/Dockerfile @@ -1,6 +1,9 @@ -FROM rustlang/rust:nightly-alpine3.20 AS builder +# syntax=docker/dockerfile:1 +ARG ALPINE_VERSION="3.20" + +FROM rustlang/rust:nightly-alpine$ALPINE_VERSION AS builder RUN apk add --no-cache musl-dev pkgconfig libressl3.8-libssl libressl-dev -RUN cargo install --locked --no-default-features --features ci-autoclean cargo-cache +RUN --mount=type=tmpfs,target=/tmp --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked cargo install --locked --no-default-features --features ci-autoclean cargo-cache RUN rustup component add rustfmt RUN rustup component add clippy