37 lines
840 B
Docker
37 lines
840 B
Docker
FROM debian:bullseye-slim as final
|
|
|
|
RUN apt-get update; apt-get install -y libssl1.1; rm -rf /var/lib/apt/lists/*
|
|
|
|
FROM rust:latest as build
|
|
|
|
RUN apt-get update; \
|
|
apt-get install -y libclang-dev automake autoconf \
|
|
openssl
|
|
|
|
# 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
|
|
|
|
FROM final
|
|
|
|
COPY --from=build /nerdcult_api/target/release/nerdcult_api /bin/nerdcult_api
|
|
|
|
CMD ["/bin/nerdcult_api"]
|