32 lines
957 B
Text
32 lines
957 B
Text
|
FROM lukemathwalker/cargo-chef:latest-rust-1.65.0 as chef
|
||
|
WORKDIR /usr/src/backend
|
||
|
|
||
|
FROM chef as planner
|
||
|
RUN mkdir src && touch src/main.rs
|
||
|
COPY ./Cargo.toml .
|
||
|
RUN cargo chef prepare --recipe-path recipe.json
|
||
|
|
||
|
FROM chef as builder
|
||
|
RUN cargo install diesel_cli --no-default-features --features postgres
|
||
|
COPY --from=planner /usr/src/backend/recipe.json .
|
||
|
RUN cargo chef cook --release --recipe-path recipe.json
|
||
|
COPY ./src ./src
|
||
|
RUN cargo build --release
|
||
|
|
||
|
FROM debian:buster-slim as runner
|
||
|
RUN apt update
|
||
|
RUN apt install -y libpq5
|
||
|
RUN apt install -y ca-certificates
|
||
|
RUN apt-get clean
|
||
|
RUN apt-get autoremove --yes
|
||
|
RUN rm -rf /var/lib/{apt,dpkg,cache,log}/
|
||
|
WORKDIR /usr/local/bin
|
||
|
COPY --from=builder /usr/local/cargo/bin/diesel .
|
||
|
WORKDIR /usr/src/backend
|
||
|
COPY ./run.sh .
|
||
|
RUN chmod +x ./run.sh
|
||
|
COPY ./migrations ./migrations
|
||
|
COPY --from=builder /usr/src/backend/target/release/api /usr/src/backend/target/release/worker ./bin/
|
||
|
EXPOSE 80
|
||
|
ENTRYPOINT [ "./run.sh" ]
|