]> Untitled Git - lemmy.git/blob - docker/Dockerfile
Use Rust 1.70 for Docker and CI (#3265)
[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 # This can be set to release using --build-arg
6 ARG RUST_RELEASE_MODE="debug"
7
8 COPY . .
9
10 # Build the project
11     
12 # Debug mode build
13 RUN --mount=type=cache,target=/app/target \
14     if [ "$RUST_RELEASE_MODE" = "debug" ] ; then \
15       echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs" \
16       && cargo build --target ${CARGO_BUILD_TARGET} \
17       && cp ./target/$CARGO_BUILD_TARGET/$RUST_RELEASE_MODE/lemmy_server /app/lemmy_server; \
18     fi
19
20 # Release mode build
21 RUN \
22     if [ "$RUST_RELEASE_MODE" = "release" ] ; then \
23       echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs" \
24       && cargo build --target ${CARGO_BUILD_TARGET} --release \
25       && cp ./target/$CARGO_BUILD_TARGET/$RUST_RELEASE_MODE/lemmy_server /app/lemmy_server; \
26     fi
27
28 # The alpine runner
29 FROM alpine:3 as lemmy
30
31 # Install libpq for postgres
32 RUN apk add libpq
33
34 # Copy resources
35 COPY --from=builder /app/lemmy_server /app/lemmy
36
37 CMD ["/app/lemmy"]