fix(security): minimize runtime images and enforce complete vulnerability scans
This commit is contained in:
1 parent
0c1fb38e31
commit
f685616ae8
13 files changed
+2736
-37
No files matched your search
@@ -53,30 +53,48 @@ RUN --mount=type=cache,id=crank-mcp-cargo-registry,target=/usr/local/cargo/regis
|
||||
SQLX_OFFLINE=true cargo build --release -p mcp-server \
|
||||
&& cp /app/target/release/mcp-server /tmp/mcp-server
|
||||
|
||||
FROM debian:bookworm-slim
|
||||
# Trusted CA bundle source for the package stage. The slim image ships no CA
|
||||
# certificates, so the HTTPS Debian mirror can only be reached after seeding
|
||||
# them; the Rust base image provides the bundle without rebuilding the app.
|
||||
FROM rust:1.96.1-bookworm AS ca-bundle
|
||||
|
||||
RUN test -s /etc/ssl/certs/ca-certificates.crt
|
||||
|
||||
# Package stage: install the security-refreshed Debian packages, then assemble
|
||||
# the minimal runtime rootfs. Kept independent of the Rust builder so it can be
|
||||
# built and reviewed on its own.
|
||||
FROM debian:bookworm-slim AS runtime-rootfs
|
||||
|
||||
ARG CRANK_SECURITY_REFRESH
|
||||
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
COPY --from=ca-bundle /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
COPY scripts/prepare-runtime-rootfs.sh /usr/local/bin/prepare-runtime-rootfs
|
||||
|
||||
RUN sed -i 's|http://deb.debian.org|https://deb.debian.org|g' /etc/apt/sources.list.d/debian.sources \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends --only-upgrade libpcre2-8-0 perl-base \
|
||||
&& apt-get install -y --no-install-recommends --only-upgrade \
|
||||
base-files libc6 libgcc-s1 gcc-12-base bash dash libtinfo6 libselinux1 libpcre2-8-0 coreutils \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& dpkg --compare-versions "$(dpkg-query -W -f='${Version}' libpcre2-8-0)" ge '10.42-1+deb12u2' \
|
||||
&& dpkg --compare-versions "$(dpkg-query -W -f='${Version}' perl-base)" ge '5.36.0-7+deb12u4' \
|
||||
&& sh /usr/local/bin/prepare-runtime-rootfs /runtime \
|
||||
&& echo "crank-security-refresh=${CRANK_SECURITY_REFRESH}"
|
||||
|
||||
WORKDIR /app
|
||||
COPY scripts/docker-http-healthcheck.sh /runtime/usr/local/bin/crank-http-healthcheck
|
||||
|
||||
RUN chmod 0755 /runtime/usr/local/bin/crank-http-healthcheck
|
||||
|
||||
FROM scratch
|
||||
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
COPY --from=runtime-rootfs /runtime /
|
||||
|
||||
COPY --from=builder /tmp/mcp-server /usr/local/bin/mcp-server
|
||||
COPY scripts/docker-http-healthcheck.sh /usr/local/bin/crank-http-healthcheck
|
||||
|
||||
RUN test -s /etc/ssl/certs/ca-certificates.crt \
|
||||
&& chmod 0755 /usr/local/bin/crank-http-healthcheck
|
||||
|
||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
ENV CRANK_MCP_BIND=0.0.0.0:3002
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
EXPOSE 3002
|
||||
|
||||
CMD ["mcp-server"]
|
||||
Reference in new issue
Block a user