1 # can be build on x64, arm32, arm64 platforms
2 # to build on target platform run
3 # docker build -f Dockerfile.libc -t dessalines/lemmy:version ../..
5 # to use docker buildx run
6 # docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile.libc -t YOURNAME/lemmy --push ../..
8 FROM node:12-buster as node
9 # use this if use docker buildx
10 #FROM --platform=$BUILDPLATFORM node:12-buster as node
15 COPY ui/package.json ui/yarn.lock ./
16 RUN yarn install --pure-lockfile --network-timeout 100000
23 FROM rust:1.40 as rust
28 RUN USER=root cargo new server
30 COPY server/Cargo.toml server/Cargo.lock ./
31 RUN mkdir -p ./src/bin \
32 && echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs
35 RUN cargo build --release
37 # rm -f ./target/release/deps/lemmy_server* ; rm -f ./target/debug/deps/lemmy_server*
38 COPY server/src ./src/
39 COPY server/migrations ./migrations/
43 # workaround for https://github.com/rust-lang/rust/issues/62896
44 #RUN RUSTFLAGS='-Ccodegen-units=1' cargo build --release
45 RUN cargo build --release --frozen
46 #RUN cargo build --frozen
48 # Get diesel-cli on there just in case
49 # RUN cargo install diesel_cli --no-default-features --features postgres
51 # make result place always the same for lemmy container
52 RUN cp /app/server/target/release/lemmy_server /app/server/ready
53 #RUN cp /app/server/target/debug/lemmy_server /app/server/ready
56 FROM rust:1.40 as docs
62 RUN cargo install mdbook
63 RUN mdbook build docs/
67 # debian because build with dynamic linking with debian:buster
68 FROM debian:buster as lemmy
70 # Install libpq for postgres
72 RUN apt-get update && apt-get install -y libpq5
73 RUN addgroup --gid 1000 lemmy
75 #RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy
77 RUN adduser --disabled-password --shell /bin/sh --uid 1000 --ingroup lemmy lemmy
80 COPY server/config/defaults.hjson /config/defaults.hjson
81 COPY --from=node /app/ui/dist /app/dist
82 COPY --from=docs /app/docs/book/ /app/dist/documentation/
83 COPY --from=rust /app/server/ready /app/lemmy
85 RUN chown lemmy:lemmy /app/lemmy