2023-01-17 05:54:45 +00:00
|
|
|
FROM docker.io/lukemathwalker/cargo-chef:latest-rust-1.65.0 as chef
|
|
|
|
|
|
|
|
FROM chef as diesel
|
|
|
|
RUN cargo install diesel_cli --no-default-features --features postgres
|
2022-12-12 16:54:07 +00:00
|
|
|
|
|
|
|
FROM chef as planner
|
2023-01-17 05:54:45 +00:00
|
|
|
WORKDIR /usr/src/backend
|
2022-12-12 16:54:07 +00:00
|
|
|
RUN mkdir src && touch src/main.rs
|
2022-12-14 18:13:32 +00:00
|
|
|
COPY ./Cargo.toml ./Cargo.lock ./
|
2022-12-12 16:54:07 +00:00
|
|
|
RUN cargo chef prepare --recipe-path recipe.json
|
|
|
|
|
|
|
|
FROM chef as builder
|
2023-01-17 05:54:45 +00:00
|
|
|
WORKDIR /usr/src/backend
|
2022-12-12 16:54:07 +00:00
|
|
|
COPY --from=planner /usr/src/backend/recipe.json .
|
2023-02-22 16:40:39 +00:00
|
|
|
RUN cargo chef cook --recipe-path recipe.json
|
2022-12-12 16:54:07 +00:00
|
|
|
COPY ./src ./src
|
2023-02-22 16:40:39 +00:00
|
|
|
RUN cargo build
|
2022-12-12 16:54:07 +00:00
|
|
|
|
2023-01-17 05:54:45 +00:00
|
|
|
FROM docker.io/debian:bullseye-slim as runner
|
2022-12-12 16:54:07 +00:00
|
|
|
RUN apt update
|
|
|
|
RUN apt install -y libpq5
|
|
|
|
RUN apt install -y ca-certificates
|
|
|
|
RUN apt-get clean
|
2023-01-17 05:54:45 +00:00
|
|
|
RUN apt-get autoremove -y
|
2022-12-12 16:54:07 +00:00
|
|
|
RUN rm -rf /var/lib/{apt,dpkg,cache,log}/
|
|
|
|
WORKDIR /usr/local/bin
|
2022-12-20 18:00:12 +00:00
|
|
|
COPY --from=diesel /usr/local/cargo/bin/diesel .
|
2022-12-12 16:54:07 +00:00
|
|
|
WORKDIR /usr/src/backend
|
|
|
|
COPY ./run.sh .
|
|
|
|
RUN chmod +x ./run.sh
|
|
|
|
COPY ./migrations ./migrations
|
2023-02-22 16:40:39 +00:00
|
|
|
COPY --from=builder /usr/src/backend/target/debug/api /usr/src/backend/target/debug/worker ./bin/
|
2022-12-12 16:54:07 +00:00
|
|
|
EXPOSE 80
|
|
|
|
ENTRYPOINT [ "./run.sh" ]
|