summaryrefslogtreecommitdiffstats
path: root/Dockerfile
blob: 3f3aa4e767ed781f62f1cabfaf508805055e5be2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
FROM node:10-jessie as node
#If encounter Invalid cross-device error -run on host 'echo N | sudo tee /sys/module/overlay/parameters/metacopy'
WORKDIR /app/ui

COPY ui/package.json ui/yarn.lock ./
RUN yarn install --pure-lockfile # This caches your deps
COPY ui /app/ui
RUN yarn build

FROM rust:1.33 as rust

# create a new empty shell project
WORKDIR /app
RUN USER=root cargo new server
WORKDIR /app/server

# copy over your manifests
COPY server/Cargo.toml server/Cargo.lock ./

# this build step will cache your dependencies
RUN  mkdir -p ./src/bin \
  && echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs 
RUN cargo build --release --bin lemmy
RUN rm -r ./target/release/.fingerprint/server-*

# copy your source tree
# RUN rm -rf ./src/
COPY server/src ./src/
COPY server/migrations ./migrations/

# build for release
RUN cargo build --frozen --release --bin lemmy
RUN mv /app/server/target/release/lemmy /app/lemmy

# Get diesel-cli on there just in case
# RUN cargo install diesel_cli --no-default-features --features postgres

# The output image
# FROM debian:stable-slim
# RUN apt-get -y update && apt-get install -y postgresql-client
# COPY --from=rust /app/server/target/release/lemmy /app/lemmy
COPY --from=node /app/ui/dist /app/dist
EXPOSE 8536