FROM rust:1.83.0-alpine3.20 AS builder RUN apk add --no-cache musl-dev; WORKDIR /app COPY . . RUN --mount=type=cache,id=cargo-registry,target=/usr/local/cargo/registry \ --mount=type=cache,id=cargo-target,target=/app/target \ set -e; \ cargo build --color always --release --locked; \ # The cache will disappear after this directive, so we # need to copy the binary to a persistent place. cp target/release/gitea /app/gitea; FROM alpine:3.21.0 AS final RUN apk add --no-cache ca-certificates; ENV RUST_BACKTRACE=1 ENV RUST_LOG=info COPY --from=builder /app/gitea /bin/ # Put this last, as it's the only thing that's different between variants. # This way, the previous layers can all be shared. ARG VARIANT="missing build arg 'VARIANT'" COPY ./shims/${VARIANT}/* /opt/resource/