1 ARG RUST_BUILDER_IMAGE=shtripok/rust-musl-builder:arm
3 FROM $RUST_BUILDER_IMAGE as rust
5 #ARG RUSTRELEASEDIR="debug"
6 ARG RUSTRELEASEDIR="release"
10 RUN sudo chown -R rust:rust .
11 RUN USER=root cargo new server
13 COPY Cargo.toml Cargo.lock ./
14 COPY lemmy_db ./lemmy_db
15 COPY lemmy_utils ./lemmy_utils
16 COPY lemmy_structs ./lemmy_structs
17 COPY lemmy_rate_limit ./lemmy_rate_limit
18 COPY lemmy_api ./lemmy_api
19 COPY lemmy_apub ./lemmy_apub
20 COPY lemmy_websocket ./lemmy_websocket
21 RUN mkdir -p ./src/bin \
22 && echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs
23 RUN cargo build --release
24 RUN find target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR -type f -name "$(echo "lemmy_server" | tr '-' '_')*" -exec touch -t 200001010000 {} +
26 COPY migrations ./migrations/
29 # workaround for https://github.com/rust-lang/rust/issues/62896
30 RUN cargo build --frozen --release
33 RUN strip ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server
35 RUN cp ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server /app/server/
37 FROM $RUST_BUILDER_IMAGE as docs
39 COPY --chown=rust:rust docs ./docs
40 RUN mdbook build docs/
42 FROM alpine:3.12 as lemmy
44 # Install libpq for postgres
47 # Install Espeak for captchas
50 RUN addgroup -g 1000 lemmy
51 RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy
54 COPY --chown=lemmy:lemmy config/defaults.hjson /config/defaults.hjson
55 COPY --chown=lemmy:lemmy --from=rust /app/server/lemmy_server /app/lemmy
56 COPY --chown=lemmy:lemmy --from=docs /app/docs/book/ /app/documentation/
58 RUN chown lemmy:lemmy /app/lemmy