]> Untitled Git - lemmy.git/blob - docker/prod/Dockerfile
For untagged commits, include hash in version name (fixes #1563)
[lemmy.git] / docker / prod / Dockerfile
1 # Build the project
2 FROM ekidd/rust-musl-builder:1.50.0 as builder
3
4 ARG CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
5 ARG RUSTRELEASEDIR="release"
6
7 WORKDIR /app
8
9 COPY ./ ./
10
11 RUN sudo chown -R rust:rust .
12 RUN echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"
13 RUN cargo build --release
14
15 # reduce binary size
16 RUN strip ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server
17
18 RUN cp ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server /app/lemmy_server
19
20 # The alpine runner
21 FROM alpine:3.12 as lemmy
22
23 # Install libpq for postgres
24 RUN apk add libpq
25
26 RUN addgroup -g 1000 lemmy
27 RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy
28
29 # Copy resources
30 COPY --chown=lemmy:lemmy --from=builder /app/lemmy_server /app/lemmy
31
32 RUN chown lemmy:lemmy /app/lemmy
33 USER lemmy
34 EXPOSE 8536
35 CMD ["/app/lemmy"]