101 lines
4.0 KiB
Docker
101 lines
4.0 KiB
Docker
FROM rust:1.96.1-bookworm AS deps
|
|
|
|
WORKDIR /app
|
|
|
|
COPY Cargo.toml Cargo.lock ./
|
|
COPY vendor ./vendor
|
|
COPY .sqlx ./.sqlx
|
|
COPY apps/admin-api/Cargo.toml apps/admin-api/Cargo.toml
|
|
COPY apps/mcp-server/Cargo.toml apps/mcp-server/Cargo.toml
|
|
COPY crates/crank-core/Cargo.toml crates/crank-core/Cargo.toml
|
|
COPY crates/crank-schema/Cargo.toml crates/crank-schema/Cargo.toml
|
|
COPY crates/crank-mapping/Cargo.toml crates/crank-mapping/Cargo.toml
|
|
COPY crates/crank-registry/Cargo.toml crates/crank-registry/Cargo.toml
|
|
COPY crates/crank-runtime/Cargo.toml crates/crank-runtime/Cargo.toml
|
|
COPY crates/crank-adapter-rest/Cargo.toml crates/crank-adapter-rest/Cargo.toml
|
|
|
|
RUN mkdir -p \
|
|
apps/admin-api/src \
|
|
apps/mcp-server/src \
|
|
crates/crank-core/src \
|
|
crates/crank-schema/src \
|
|
crates/crank-mapping/src \
|
|
crates/crank-registry/src \
|
|
crates/crank-runtime/src \
|
|
crates/crank-adapter-rest/src \
|
|
&& printf 'fn main() {}\n' > apps/admin-api/src/main.rs \
|
|
&& printf 'fn main() {}\n' > apps/mcp-server/src/main.rs \
|
|
&& printf 'pub fn placeholder() {}\n' > crates/crank-core/src/lib.rs \
|
|
&& printf 'pub fn placeholder() {}\n' > crates/crank-schema/src/lib.rs \
|
|
&& printf 'pub fn placeholder() {}\n' > crates/crank-mapping/src/lib.rs \
|
|
&& printf 'pub fn placeholder() {}\n' > crates/crank-registry/src/lib.rs \
|
|
&& printf 'pub fn placeholder() {}\n' > crates/crank-runtime/src/lib.rs \
|
|
&& printf 'pub fn placeholder() {}\n' > crates/crank-adapter-rest/src/lib.rs
|
|
|
|
RUN --mount=type=cache,id=crank-mcp-cargo-registry,target=/usr/local/cargo/registry \
|
|
--mount=type=cache,id=crank-mcp-cargo-git,target=/usr/local/cargo/git/db \
|
|
--mount=type=cache,id=crank-mcp-target,target=/app/target \
|
|
SQLX_OFFLINE=true cargo build --release -p mcp-server
|
|
|
|
FROM rust:1.96.1-bookworm AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
COPY Cargo.toml Cargo.lock ./
|
|
COPY vendor ./vendor
|
|
COPY .sqlx ./.sqlx
|
|
COPY apps ./apps
|
|
COPY crates ./crates
|
|
|
|
RUN --mount=type=cache,id=crank-mcp-cargo-registry,target=/usr/local/cargo/registry \
|
|
--mount=type=cache,id=crank-mcp-cargo-git,target=/usr/local/cargo/git/db \
|
|
--mount=type=cache,id=crank-mcp-target,target=/app/target \
|
|
SQLX_OFFLINE=true cargo build --release -p mcp-server \
|
|
&& cp /app/target/release/mcp-server /tmp/mcp-server
|
|
|
|
# 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=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 \
|
|
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' \
|
|
&& sh /usr/local/bin/prepare-runtime-rootfs /runtime \
|
|
&& echo "crank-security-refresh=${CRANK_SECURITY_REFRESH}"
|
|
|
|
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
|
|
|
|
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"]
|