qchgk_web_docker/Dockerfile

41 lines
910 B
Docker
Raw Permalink Normal View History

2023-08-18 08:51:49 +00:00
FROM rust:1-alpine as chef
2023-03-28 14:01:05 +00:00
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL sparse
2019-08-20 13:15:55 +00:00
2023-08-18 08:51:49 +00:00
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
2023-03-28 14:28:39 +00:00
2023-03-28 14:26:00 +00:00
WORKDIR /home/rust/src
2023-08-18 08:51:49 +00:00
FROM chef AS planner
2019-08-20 13:15:55 +00:00
2023-08-18 08:51:49 +00:00
COPY . .
2019-08-20 13:15:55 +00:00
2023-08-18 08:51:49 +00:00
RUN cargo chef prepare --recipe-path recipe.json
2019-08-20 13:15:55 +00:00
2023-08-18 08:51:49 +00:00
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
2019-08-20 13:15:55 +00:00
FROM scratch
COPY static /static
COPY templates /templates
2023-03-28 16:29:18 +00:00
COPY --from=builder /home/rust/src/target/release/qchgk_web /
2019-08-20 13:15:55 +00:00
EXPOSE 8088/tcp
ENTRYPOINT ["/qchgk_web"]