1 FROM clux/muslrust:1.70.0 as builder
3 ARG CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
5 # comma-seperated list of features to enable
6 ARG CARGO_BUILD_FEATURES=default
8 # This can be set to release using --build-arg
9 ARG RUST_RELEASE_MODE="debug"
16 RUN --mount=type=cache,target=/app/target \
17 if [ "$RUST_RELEASE_MODE" = "debug" ] ; then \
18 echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs" \
19 && cargo build --target ${CARGO_BUILD_TARGET} --features ${CARGO_BUILD_FEATURES} \
20 && cp ./target/$CARGO_BUILD_TARGET/$RUST_RELEASE_MODE/lemmy_server /app/lemmy_server; \
25 if [ "$RUST_RELEASE_MODE" = "release" ] ; then \
26 echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs" \
27 && cargo build --target ${CARGO_BUILD_TARGET} --features ${CARGO_BUILD_FEATURES} --release \
28 && cp ./target/$CARGO_BUILD_TARGET/$RUST_RELEASE_MODE/lemmy_server /app/lemmy_server; \
32 FROM alpine:3 as lemmy
34 # Install libpq for postgres
35 RUN apk add --no-cache libpq
38 COPY --from=builder /app/lemmy_server /app/lemmy
40 # Create non-privileged user
41 RUN adduser -h /app -s sh -S -u 1000 lemmy
42 RUN chown -R lemmy /app