From a4c5abc57a0fa18a48e2b383008353843edd0328 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 20 Oct 2024 23:38:53 -0400 Subject: [PATCH] Update dockerfiles to take advantage of BuildKit. --- docker/ta_waybar_pipewire/Dockerfile | 13 ++++++++----- docker/ta_waybar_pipewire_development/Dockerfile | 7 +++++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/docker/ta_waybar_pipewire/Dockerfile b/docker/ta_waybar_pipewire/Dockerfile index f2e1815..0f42cc6 100644 --- a/docker/ta_waybar_pipewire/Dockerfile +++ b/docker/ta_waybar_pipewire/Dockerfile @@ -1,13 +1,16 @@ -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 pkgconf pipewire-dev clang-dev RUN mkdir /root/ta_waybar_pipewire WORKDIR /root/ta_waybar_pipewire -COPY . . +COPY --link . . # 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 +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 -FROM alpine:3.20 AS runner +FROM alpine:$ALPINE_VERSION AS runner -COPY --from=builder /target/release-lto/ta_waybar_pipewire /usr/bin/ +COPY --link --from=builder /target/release-lto/ta_waybar_pipewire /usr/bin/ diff --git a/docker/ta_waybar_pipewire_development/Dockerfile b/docker/ta_waybar_pipewire_development/Dockerfile index e751066..bcbac4e 100644 --- a/docker/ta_waybar_pipewire_development/Dockerfile +++ b/docker/ta_waybar_pipewire_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 pkgconf pipewire-dev clang-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