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*
44 RUN cargo build --frozen --release
47 RUN strip /app/server/target/release/lemmy_server
49 # Get diesel-cli on there just in case
50 # RUN cargo install diesel_cli --no-default-features --features postgres
52 # RUN cp /app/server/target/debug/lemmy_server /app/server/ready
53 RUN cp /app/server/target/release/lemmy_server /app/server/ready
56 # debian because build with dynamic linking with debian:buster
57 FROM arm64v8/debian:buster-slim as lemmy
59 #COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin
60 COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin
62 # Install libpq for postgres
64 RUN apt-get update && apt-get install -y libpq5
66 RUN addgroup --gid 1000 lemmy
68 #RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy
70 RUN adduser --disabled-password --shell /bin/sh --uid 1000 --ingroup lemmy lemmy
73 COPY server/config/defaults.hjson /config/defaults.hjson
74 COPY --from=rust /app/server/ready /app/lemmy
75 COPY --from=node /app/ui/dist /app/dist
77 RUN chown lemmy:lemmy /app/lemmy