]> Untitled Git - lemmy.git/blob - docker/prod/Dockerfile
Removing some commented lines from the dockerfile.
[lemmy.git] / docker / prod / Dockerfile
1 ARG RUST_BUILDER_IMAGE=shtripok/rust-musl-builder:arm
2
3 FROM $RUST_BUILDER_IMAGE as rust
4
5 #ARG RUSTRELEASEDIR="debug"
6 ARG RUSTRELEASEDIR="release"
7
8 # Cache deps
9 WORKDIR /app
10 RUN sudo chown -R rust:rust .
11 RUN USER=root cargo new server
12 WORKDIR /app/server
13 COPY --chown=rust:rust server/Cargo.toml server/Cargo.lock ./
14 #RUN sudo chown -R rust:rust .
15 RUN mkdir -p ./src/bin \
16    && echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs
17 RUN cargo build --release
18 RUN rm -f ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/deps/lemmy_server*
19 COPY --chown=rust:rust server/src ./src/
20 COPY --chown=rust:rust server/migrations ./migrations/
21
22 # build for release
23 # workaround for https://github.com/rust-lang/rust/issues/62896
24 RUN cargo build --frozen --release
25
26 # reduce binary size
27 RUN strip ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server
28
29 RUN cp ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server /app/server/
30
31 FROM $RUST_BUILDER_IMAGE as docs
32 WORKDIR /app
33 COPY --chown=rust:rust docs ./docs
34 RUN mdbook build docs/
35
36 FROM node:12-buster as node
37
38 WORKDIR /app/ui
39
40 # Cache deps
41 COPY ui/package.json ui/yarn.lock ./
42 RUN yarn install --pure-lockfile --network-timeout 600000
43
44 # Build
45 COPY ui /app/ui
46 RUN yarn build
47
48 FROM alpine:3.12 as lemmy
49
50 # Install libpq for postgres
51 RUN apk add libpq
52 RUN addgroup -g 1000 lemmy
53 RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy
54
55 # Copy resources
56 COPY --chown=lemmy:lemmy server/config/defaults.hjson /config/defaults.hjson
57 COPY --chown=lemmy:lemmy --from=rust /app/server/lemmy_server /app/lemmy
58 COPY --chown=lemmy:lemmy --from=docs /app/docs/book/ /app/dist/documentation/
59 COPY --chown=lemmy:lemmy --from=node /app/ui/dist /app/dist
60
61 RUN chown lemmy:lemmy /app/lemmy
62 USER lemmy
63 EXPOSE 8536
64 CMD ["/app/lemmy"]