1 ARG RUST_BUILDER_IMAGE=ekidd/rust-musl-builder:1.47.0
4 FROM $RUST_BUILDER_IMAGE as planner
6 RUN cargo install cargo-chef --version 0.1.6
11 RUN sudo chown -R rust:rust .
12 RUN cargo chef prepare --recipe-path recipe.json
14 # Cargo chef cache dependencies
15 FROM $RUST_BUILDER_IMAGE as cacher
16 ARG CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
18 RUN cargo install cargo-chef --version 0.1.6
19 COPY --from=planner /app/recipe.json ./recipe.json
20 RUN sudo chown -R rust:rust .
21 RUN cargo chef cook --release --target ${CARGO_BUILD_TARGET} --recipe-path recipe.json
24 FROM $RUST_BUILDER_IMAGE as builder
26 ARG CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
27 ARG RUSTRELEASEDIR="release"
31 # Copy over the cached dependencies
32 COPY --from=cacher /app/target target
33 COPY --from=cacher /home/rust/.cargo /home/rust/.cargo
35 # Copy the rest of the dirs
38 RUN sudo chown -R rust:rust .
39 RUN cargo build --release
42 RUN strip ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server
44 RUN cp ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server /app/lemmy_server
47 FROM $RUST_BUILDER_IMAGE as docs
49 RUN cargo install mdbook --git https://github.com/Ruin0x11/mdBook.git \
50 --branch localization --rev d06249b --force
51 COPY --chown=rust:rust docs ./docs
52 RUN mdbook build docs/
55 FROM alpine:3.12 as lemmy
57 # Install libpq for postgres
60 # Install Espeak for captchas
63 RUN addgroup -g 1000 lemmy
64 RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy
67 COPY --chown=lemmy:lemmy config/defaults.hjson /config/defaults.hjson
68 COPY --chown=lemmy:lemmy --from=builder /app/lemmy_server /app/lemmy
69 COPY --chown=lemmy:lemmy --from=docs /app/docs/book/ /app/documentation/
71 RUN chown lemmy:lemmy /app/lemmy