2019-04-27 00:56:33 +00:00
|
|
|
# Setup env
|
2019-04-27 13:49:50 +00:00
|
|
|
FROM rust:1.33 AS build
|
2019-04-27 08:51:08 +00:00
|
|
|
RUN USER=root cargo new --bin /opt/lemmy/server--dev
|
2019-04-27 00:56:33 +00:00
|
|
|
WORKDIR /opt/lemmy/server--dev
|
|
|
|
# Enable deps caching
|
|
|
|
RUN mkdir -p src/bin
|
|
|
|
RUN echo 'fn main() { println!("Dummy") }' >src/bin/main.rs
|
|
|
|
# Install deps
|
|
|
|
COPY Cargo.toml .
|
|
|
|
COPY Cargo.lock .
|
2019-04-27 08:51:08 +00:00
|
|
|
RUN cargo build --release
|
|
|
|
RUN rm src/bin/main.rs
|
2019-04-27 00:56:33 +00:00
|
|
|
# Add app
|
2019-04-27 08:51:08 +00:00
|
|
|
COPY src/ src/
|
|
|
|
COPY migrations/ migrations/
|
|
|
|
RUN rm target/release/deps/lemmy*
|
|
|
|
RUN cargo build --release
|
2019-04-27 13:49:50 +00:00
|
|
|
|
|
|
|
# Setup env (no Alpine because Rust requires glibc)
|
|
|
|
FROM ubuntu:18.04
|
|
|
|
RUN apt update
|
|
|
|
RUN apt install postgresql-client -y
|
|
|
|
# Create empty directory where the frontend would normally be
|
|
|
|
RUN mkdir -p /opt/lemmy/ui--dev/dist
|
|
|
|
# Add app
|
|
|
|
COPY --from=build /opt/lemmy/server--dev/target/release/lemmy .
|
2019-04-27 00:56:33 +00:00
|
|
|
# Run app
|
2019-04-27 13:49:50 +00:00
|
|
|
CMD ["./lemmy"]
|