1 ARG RUST_BUILDER_IMAGE=clux/muslrust:1.56.0
3 FROM $RUST_BUILDER_IMAGE as chef
5 RUN cargo install cargo-chef
10 ENV RUSTFLAGS="--cfg tokio_unstable"
15 RUN cargo chef prepare --recipe-path recipe.json
18 ARG CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
19 ARG RUSTRELEASEDIR="debug"
20 ENV RUSTFLAGS="--cfg tokio_unstable"
22 COPY --from=planner /app/recipe.json ./recipe.json
23 RUN cargo chef cook --recipe-path recipe.json --target ${CARGO_BUILD_TARGET}
25 # Copy the rest of the dirs
29 RUN echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"
30 RUN cargo build --target ${CARGO_BUILD_TARGET}
33 RUN strip ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server
35 RUN cp ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server /app/lemmy_server
38 FROM alpine:3 as lemmy
40 # Install libpq for postgres
44 COPY --from=builder /app/lemmy_server /app/lemmy