forked from Deuxfleurs/garage
31 lines
1.1 KiB
Docker
31 lines
1.1 KiB
Docker
# This Dockerfile is meant for production use only, binaries
|
|
# are built against release targets and stripped of symbols.
|
|
|
|
# First build stage, bluntly building a release target
|
|
FROM rust:1.70.0-alpine as builder
|
|
COPY ./Cargo.toml ./Cargo.lock ./
|
|
COPY src ./src
|
|
# Copy the git repository so that git_version can properly
|
|
# guess the package version. This is not perfectly idiomatic.
|
|
COPY .git ./.git
|
|
ENV RUSTFLAGS='-C target-feature=+crt-static'
|
|
ENV FEATURES=k2v,sled,lmdb,sqlite,consul-discovery,kubernetes-discovery,metrics,telemetry-otlp,bundled-libs
|
|
ENV TARGET=x86_64-unknown-linux-musl
|
|
|
|
RUN apk add --no-cache musl-dev make git file protoc
|
|
RUN cargo fetch
|
|
RUN cargo build --release --features $FEATURES --target $TARGET \
|
|
&& mv target/$TARGET/release/garage ./garage \
|
|
&& strip ./garage
|
|
|
|
# Second clean stage just copying over the static binary
|
|
FROM scratch
|
|
ENV RUST_BACKTRACE=1
|
|
ENV RUST_LOG=garage=info
|
|
COPY --from=builder ./garage /garage
|
|
# Configuration is not included in the image and should be
|
|
# mounted as a volume. No volume is explicitely declared for
|
|
# this as there is no container-level persistence need.
|
|
CMD /garage server -c /config.toml
|
|
|