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 server/Cargo.toml server/Cargo.lock ./
14 COPY server/lemmy_db ./lemmy_db
15 COPY server/lemmy_utils ./lemmy_utils
16 RUN mkdir -p ./src/bin \
17 && echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs
18 RUN cargo build --release
19 RUN find target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR -type f -name "$(echo "lemmy_server" | tr '-' '_')*" -exec touch -t 200001010000 {} +
20 COPY server/src ./src/
21 COPY server/migrations ./migrations/
24 # workaround for https://github.com/rust-lang/rust/issues/62896
25 RUN cargo build --frozen --release
28 RUN strip ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server
30 RUN cp ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server /app/server/
32 FROM $RUST_BUILDER_IMAGE as docs
34 COPY --chown=rust:rust docs ./docs
35 RUN mdbook build docs/
37 FROM node:12-buster as node
42 COPY ui/package.json ui/yarn.lock ./
43 RUN yarn install --pure-lockfile --network-timeout 600000
49 FROM alpine:3.12 as lemmy
51 # Install libpq for postgres
54 # Install Espeak for captchas
57 RUN addgroup -g 1000 lemmy
58 RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy
61 COPY --chown=lemmy:lemmy server/config/defaults.hjson /config/defaults.hjson
62 COPY --chown=lemmy:lemmy --from=rust /app/server/lemmy_server /app/lemmy
63 COPY --chown=lemmy:lemmy --from=docs /app/docs/book/ /app/dist/documentation/
64 COPY --chown=lemmy:lemmy --from=node /app/ui/dist /app/dist
66 RUN chown lemmy:lemmy /app/lemmy