mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-25 10:51:03 +00:00
28 lines
763 B
Docker
28 lines
763 B
Docker
# Setup env
|
|
FROM rust:1.33 AS build
|
|
RUN USER=root cargo new --bin /opt/lemmy/server--prod
|
|
WORKDIR /opt/lemmy/server--prod
|
|
# 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 .
|
|
RUN cargo build --release
|
|
RUN rm src/bin/main.rs
|
|
# Add app
|
|
COPY src/ src/
|
|
COPY migrations/ migrations/
|
|
RUN rm target/release/deps/lemmy*
|
|
RUN cargo build --release
|
|
|
|
# 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--prod/dist
|
|
# Add app
|
|
COPY --from=build /opt/lemmy/server--prod/target/release/lemmy .
|
|
# Run app
|
|
CMD ["./lemmy"]
|