]> Untitled Git - lemmy.git/blob - docker/dev/Dockerfile
Add console-subscriber (#2003)
[lemmy.git] / docker / dev / Dockerfile
1 ARG RUST_BUILDER_IMAGE=clux/muslrust:1.56.0
2
3 FROM $RUST_BUILDER_IMAGE as chef
4 USER root
5 RUN cargo install cargo-chef
6 WORKDIR /app
7
8 # Cargo chef plan
9 FROM chef as planner
10 ENV RUSTFLAGS="--cfg tokio_unstable"
11
12 # Copy dirs
13 COPY . .
14
15 RUN cargo chef prepare --recipe-path recipe.json
16
17 FROM chef as builder
18 ARG CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
19 ARG RUSTRELEASEDIR="debug"
20 ENV RUSTFLAGS="--cfg tokio_unstable"
21
22 COPY --from=planner /app/recipe.json ./recipe.json
23 RUN cargo chef cook --recipe-path recipe.json --target ${CARGO_BUILD_TARGET}
24
25 # Copy the rest of the dirs
26 COPY . .
27
28 # Build the project
29 RUN echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"
30 RUN cargo build --target ${CARGO_BUILD_TARGET}
31
32 # reduce binary size
33 RUN strip ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server
34
35 RUN cp ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server /app/lemmy_server
36
37 # The alpine runner
38 FROM alpine:3 as lemmy
39
40 # Install libpq for postgres
41 RUN apk add libpq
42
43 # Copy resources
44 COPY --from=builder /app/lemmy_server /app/lemmy
45
46 EXPOSE 8536
47 CMD ["/app/lemmy"]