kanzashi-cdn/Dockerfile

43 lines
1.2 KiB
Text
Raw Permalink Normal View History

2026-07-24 06:21:13 +02:00
# syntax=docker/dockerfile:1
FROM rust:alpine AS chef
RUN apk add --no-cache openssl-dev musl-dev openssl-libs-static lld git g++ make cmake
RUN cargo install cargo-chef
WORKDIR /app
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
ENV OPENSSL_LIB_DIR=/usr/lib
ENV OPENSSL_INCLUDE_DIR=/usr/include/openssl
ENV OPENSSL_STATIC=1
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/app/target \
cargo chef cook --release --recipe-path recipe.json --target x86_64-unknown-linux-musl
COPY . .
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/app/target \
cargo build --release --target x86_64-unknown-linux-musl && \
mkdir -p /app/dist && \
cp /app/target/x86_64-unknown-linux-musl/release/kanzashi-cdn /app/dist/
FROM alpine:latest AS final
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
COPY --from=builder /app/dist/kanzashi-cdn ./kanzashi-cdn
COPY --from=builder /app/templates ./templates
ENV ROCKET_ADDRESS=0.0.0.0
ENV ROCKET_PORT=8000
EXPOSE 8000
ENTRYPOINT ["./kanzashi-cdn"]