qchgk_web_docker/Dockerfile

41 lines
910 B
Docker

FROM rust:1-alpine as chef
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL sparse
RUN apk add --no-cache musl-dev curl
# install cargo-binstall
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh -o install-from-binstall-release.sh
RUN sh install-from-binstall-release.sh
# install cargo-chef
RUN cargo binstall -y cargo-chef
WORKDIR /home/rust/src
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef as builder
COPY --from=planner /home/rust/src/recipe.json recipe.json
# build & cache deps
RUN cargo chef cook --release --recipe-path recipe.json
# build app with cached deps
COPY . .
RUN cargo build --release
FROM scratch
COPY static /static
COPY templates /templates
COPY --from=builder /home/rust/src/target/release/qchgk_web /
EXPOSE 8088/tcp
ENTRYPOINT ["/qchgk_web"]