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