]> Untitled Git - lemmy.git/blob - docker/Dockerfile
add enable_federated_downvotes site option
[lemmy.git] / docker / Dockerfile
1 FROM clux/muslrust:1.70.0 as builder
2 WORKDIR /app
3 ARG CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
4
5 # comma-seperated list of features to enable
6 ARG CARGO_BUILD_FEATURES=default
7
8 # This can be set to release using --build-arg
9 ARG RUST_RELEASE_MODE="debug"
10
11 COPY . .
12
13 # Build the project
14     
15 # Debug mode build
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; \
21     fi
22
23 # Release mode build
24 RUN \
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; \
29     fi
30
31 # The alpine runner
32 FROM alpine:3 as lemmy
33
34 # Install libpq for postgres
35 RUN apk add --no-cache libpq
36
37 # Copy resources
38 COPY --from=builder /app/lemmy_server /app/lemmy
39
40 # Create non-privileged user
41 RUN adduser -h /app -s sh -S -u 1000 lemmy
42 RUN chown -R lemmy /app
43 USER lemmy
44
45 CMD ["/app/lemmy"]