Update dockerfiles to take advantage of BuildKit.
Some checks failed
format Build format has succeeded
clippy Build clippy has failed
rust-test Build rust-test has failed

This commit is contained in:
Tom Alexander 2024-10-20 23:38:53 -04:00
parent 0171fea2ed
commit 7139714723
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 13 additions and 7 deletions

View File

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

View File

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