2023-11-24 16:27:01 +00:00
|
|
|
FROM debian:bullseye-slim as final
|
|
|
|
|
2023-11-24 16:35:25 +00:00
|
|
|
RUN apt-get update; apt-get install -y libssl3; rm -rf /var/lib/apt/lists/*
|
2023-11-24 16:27:01 +00:00
|
|
|
|
2023-08-20 12:30:11 +00:00
|
|
|
FROM rust:latest as build
|
|
|
|
|
|
|
|
RUN apt-get update; \
|
2023-11-24 16:27:01 +00:00
|
|
|
apt-get install -y libclang-dev automake autoconf \
|
|
|
|
openssl
|
2023-08-20 12:30:11 +00:00
|
|
|
|
|
|
|
# 1. Create a new empty shell project
|
|
|
|
RUN USER=root cargo new --bin nerdcult_api
|
|
|
|
WORKDIR /nerdcult_api
|
|
|
|
|
|
|
|
# 2. Copy our manifests
|
|
|
|
COPY ./Cargo.lock ./Cargo.lock
|
|
|
|
COPY ./Cargo.toml ./Cargo.toml
|
|
|
|
|
|
|
|
# 3. Build only the dependencies to cache them
|
|
|
|
RUN cargo build --release
|
|
|
|
RUN rm src/*.rs
|
|
|
|
|
|
|
|
# 4. Now that the dependency is built, copy your source code
|
|
|
|
COPY ./src ./src
|
|
|
|
COPY .sqlx .sqlx
|
|
|
|
|
|
|
|
# 5. Build for release.
|
|
|
|
RUN rm ./target/release/deps/nerdcult_api*
|
|
|
|
|
|
|
|
RUN SQLX_OFFLINE=true cargo build --release
|
|
|
|
|
2023-11-24 16:27:01 +00:00
|
|
|
FROM final
|
2023-08-20 12:30:11 +00:00
|
|
|
|
|
|
|
COPY --from=build /nerdcult_api/target/release/nerdcult_api /bin/nerdcult_api
|
|
|
|
|
|
|
|
CMD ["/bin/nerdcult_api"]
|