1 FROM node:10-jessie as node
6 COPY ui/package.json ui/yarn.lock ./
7 RUN yarn install --pure-lockfile
14 # contains qemu-*-static for cross-compilation
15 FROM multiarch/qemu-user-static as qemu
18 FROM arm64v8/rust:1.40-buster as rust
20 COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin
21 #COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin
25 #RUN apt-get update && apt-get install -y mc
26 #RUN apt-get install -y musl-tools mc
28 #RUN rustup target add ${TARGET}
32 RUN USER=root cargo new server
34 COPY server/Cargo.toml server/Cargo.lock ./
35 RUN mkdir -p ./src/bin \
36 && echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs
37 RUN cargo build --release
39 COPY server/src ./src/
40 COPY server/migrations ./migrations/
41 RUN rm -f ./target/release/deps/lemmy_server* ; rm -f ./target/debug/deps/lemmy_server*
45 RUN cargo build --frozen --release
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 # RUN cp /app/server/target/debug/lemmy_server /app/server/ready
52 RUN cp /app/server/target/release/lemmy_server /app/server/ready
55 # debian because build with dynamic linking with debian:buster
56 FROM arm64v8/debian:buster-slim as lemmy
58 #COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin
59 COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin
61 # Install libpq for postgres
63 RUN apt-get update && apt-get install -y libpq5
65 RUN addgroup --gid 1000 lemmy
67 #RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy
69 RUN adduser --disabled-password --shell /bin/sh --uid 1000 --ingroup lemmy lemmy
72 COPY server/config/defaults.hjson /config/defaults.hjson
73 COPY --from=rust /app/server/ready /app/lemmy
74 COPY --from=node /app/ui/dist /app/dist
76 RUN chown lemmy:lemmy /app/lemmy