1 FROM node:10-jessie as node
5 COPY ui/package.json ui/yarn.lock ./
6 RUN yarn install --pure-lockfile
12 FROM rust:latest as rust
16 RUN apt-get install musl-tools -y
17 RUN rustup target add x86_64-unknown-linux-musl
21 RUN USER=root cargo new server
23 COPY server/Cargo.toml server/Cargo.lock ./
24 RUN mkdir -p ./src/bin \
25 && echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs
26 RUN RUSTFLAGS=-Clinker=musl-gcc cargo build --release --target=x86_64-unknown-linux-musl
27 RUN rm -f ./target/x86_64-unknown-linux-musl/release/deps/lemmy_server*
28 COPY server/src ./src/
29 COPY server/migrations ./migrations/
32 RUN RUSTFLAGS=-Clinker=musl-gcc cargo build --frozen --release --target=x86_64-unknown-linux-musl
34 # Get diesel-cli on there just in case
35 # RUN cargo install diesel_cli --no-default-features --features postgres
39 # Install libpq for postgres
43 COPY --from=rust /app/server/target/x86_64-unknown-linux-musl/release/lemmy_server /app/lemmy
44 COPY --from=node /app/ui/dist /app/dist
45 RUN addgroup -g 1000 lemmy
46 RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy
47 RUN chown lemmy:lemmy /app/lemmy