FROM rust:%%RUST_VERSION%%-slim AS builder WORKDIR /usr/src/unftp COPY . . RUN apt-get update && apt-get install -y \ musl-dev \ musl-tools RUN rustup target add x86_64-unknown-linux-musl ENV RUSTFLAGS="-C target-feature=+crt-static" RUN BUILD_VERSION="%%BUILD_VERSION%%" cargo build --no-default-features --features docker --release --target=x86_64-unknown-linux-musl FROM alpine:latest # we could also RUN 'apk add ca-certificates', but we prefer to be consistent with the -minimal image COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt # run as user for security RUN mkdir /unftp && mkdir -p /srv RUN addgroup -g 1010 unftp \ && adduser -D -s /bin/sh -u 1010 -G unftp unftp \ && chown -R unftp:unftp /unftp /srv COPY --chown=unftp:unftp --from=builder /usr/src/unftp/target/x86_64-unknown-linux-musl/release/unftp /unftp VOLUME /srv WORKDIR /unftp USER unftp CMD ["/unftp/unftp", "-vv"]