container: Build static executable
Building a static executable and distributing it in a "from scratch" container image dramatically reduces the image size: down to 8 MB from 102 MB. Reimplementing this change because this image is no longer the base for *infra/cfg*. That image is now based on Alpine and copies in the `tmpl` executable.master
parent
1c33dfa4a4
commit
d25d876df5
|
@ -1,23 +1,23 @@
|
|||
FROM registry.fedoraproject.org/fedora-minimal:39 AS build
|
||||
FROM docker.io/library/rust:1.73-alpine AS build
|
||||
|
||||
RUN --mount=type=cache,target=/var/cache \
|
||||
microdnf install -y \
|
||||
--setopt install_weak_deps=0 \
|
||||
cargo\
|
||||
apk add \
|
||||
musl-dev \
|
||||
&& :
|
||||
|
||||
COPY . /src
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
RUN cargo build --release --locked
|
||||
RUN cargo build --release --locked \
|
||||
&& strip target/release/tmpl
|
||||
|
||||
|
||||
FROM registry.fedoraproject.org/fedora-minimal:39
|
||||
FROM scratch
|
||||
|
||||
COPY --from=build /src/target/release/tmpl /usr/local/bin
|
||||
COPY --from=build /src/target/release/tmpl /tmpl
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/tmpl"]
|
||||
ENTRYPOINT ["/tmpl"]
|
||||
|
||||
LABEL name='tmpl' \
|
||||
vendor='Dustin C. Hatch' \
|
||||
|
|
Loading…
Reference in New Issue