Files
image-proxy/Dockerfile.custom
T
2026-08-27 23:37:07 -04:00

46 lines
954 B
Docker

FROM 11notes/alpine:stable as builder
USER root
RUN apk update && apk add ca-certificates musl-dev build-base openssl-dev curl
ENV PATH="/root/.cargo/bin:${PATH}"
WORKDIR /app
COPY Cargo.toml .
COPY src ./src
RUN mkdir -p /root/.cargo && cat > /root/.cargo/config.toml <<'EOF'
[profile.release]
lto = true
codegen-units = 1
opt-level = 3
panic = "abort"
strip = true
[target.x86_64-unknown-linux-gnu]
rustflags = [
"-C", "target-cpu=native",
"-C", "codegen-units=1",
"-C", "debuginfo=0"
]
EOF
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
RUN rustup target add x86_64-unknown-linux-musl
RUN RUSTFLAGS="-Ctarget-feature=+crt-static" cargo build --release --target x86_64-unknown-linux-musl
FROM scratch
USER 65534:65534
COPY --from=builder --chown=65534:65534 /app/target/x86_64-unknown-linux-musl/release/image-proxy /usr/bin/image-proxy
COPY --from=builder /etc/ssl /etc/ssl
EXPOSE 8080
ENTRYPOINT ["/usr/bin/image-proxy"]