2023-01-25 14:41:36 +00:00
|
|
|
# syntax=docker/dockerfile:1
|
2025-10-29 15:03:50 +00:00
|
|
|
FROM scratch AS router_pkg
|
2023-01-25 14:41:36 +00:00
|
|
|
FROM scratch AS config
|
|
|
|
|
|
2025-12-09 08:36:17 +00:00
|
|
|
FROM rust:1.91.1-slim-bookworm AS build
|
2023-01-18 20:00:23 +00:00
|
|
|
|
2023-04-19 12:01:40 +00:00
|
|
|
# Required by Apollo Router
|
|
|
|
|
RUN apt-get update
|
2023-09-07 08:35:55 +00:00
|
|
|
RUN apt-get -y install npm protobuf-compiler cmake
|
2023-04-19 12:01:40 +00:00
|
|
|
RUN rm -rf /var/lib/apt/lists/*
|
|
|
|
|
RUN update-ca-certificates
|
|
|
|
|
RUN rustup component add rustfmt
|
2023-01-18 20:00:23 +00:00
|
|
|
|
2023-04-19 12:01:40 +00:00
|
|
|
WORKDIR /usr/src
|
2025-10-29 15:03:50 +00:00
|
|
|
# Create blank projects
|
2023-01-18 20:00:23 +00:00
|
|
|
RUN USER=root cargo new router
|
|
|
|
|
|
2023-04-19 12:01:40 +00:00
|
|
|
# Copy Cargo files
|
2025-10-29 15:03:50 +00:00
|
|
|
COPY --from=router_pkg Cargo.toml /usr/src/router/
|
2023-01-25 14:41:36 +00:00
|
|
|
COPY --from=config Cargo.lock /usr/src/router/
|
2023-01-18 20:00:23 +00:00
|
|
|
|
|
|
|
|
WORKDIR /usr/src/router
|
2024-11-18 14:16:00 +00:00
|
|
|
# Get the dependencies cached, so we can use dummy input files so Cargo wont fail
|
|
|
|
|
RUN echo 'fn main() { println!(""); }' > ./src/main.rs
|
|
|
|
|
RUN echo 'fn main() { println!(""); }' > ./src/lib.rs
|
2023-09-07 08:35:55 +00:00
|
|
|
RUN cargo build --release
|
2023-01-18 20:00:23 +00:00
|
|
|
|
2024-11-18 14:16:00 +00:00
|
|
|
# Copy in the actual source code
|
2025-10-29 15:03:50 +00:00
|
|
|
COPY --from=router_pkg src ./src
|
2023-01-18 20:00:23 +00:00
|
|
|
RUN touch ./src/main.rs
|
2024-11-18 14:16:00 +00:00
|
|
|
RUN touch ./src/lib.rs
|
2023-01-18 20:00:23 +00:00
|
|
|
|
|
|
|
|
# Real build this time
|
2023-09-07 08:35:55 +00:00
|
|
|
RUN cargo build --release
|
2023-01-18 20:00:23 +00:00
|
|
|
|
|
|
|
|
# Runtime
|
2025-06-23 08:31:00 +00:00
|
|
|
FROM debian:bookworm-slim AS runtime
|
2023-01-18 20:00:23 +00:00
|
|
|
|
|
|
|
|
RUN apt-get update
|
|
|
|
|
RUN apt-get -y install ca-certificates
|
|
|
|
|
RUN rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
LABEL org.opencontainers.image.title=$IMAGE_TITLE
|
|
|
|
|
LABEL org.opencontainers.image.version=$RELEASE
|
|
|
|
|
LABEL org.opencontainers.image.description=$IMAGE_DESCRIPTION
|
|
|
|
|
LABEL org.opencontainers.image.authors="The Guild"
|
|
|
|
|
LABEL org.opencontainers.image.vendor="Kamil Kisiela"
|
2024-11-18 14:16:00 +00:00
|
|
|
LABEL org.opencontainers.image.url="https://github.com/graphql-hive/console"
|
|
|
|
|
LABEL org.opencontainers.image.source="https://github.com/graphql-hive/console"
|
2023-01-18 20:00:23 +00:00
|
|
|
|
|
|
|
|
RUN mkdir -p /dist/config
|
|
|
|
|
RUN mkdir /dist/schema
|
|
|
|
|
|
|
|
|
|
# Copy in the required files from our build image
|
|
|
|
|
COPY --from=build --chown=root:root /usr/src/router/target/release/router /dist
|
2025-10-29 15:03:50 +00:00
|
|
|
COPY --from=router_pkg router.yaml /dist/config/router.yaml
|
2023-01-18 20:00:23 +00:00
|
|
|
|
|
|
|
|
WORKDIR /dist
|
|
|
|
|
|
|
|
|
|
ENV APOLLO_ROUTER_CONFIG_PATH="/dist/config/router.yaml"
|
|
|
|
|
|
|
|
|
|
ENTRYPOINT ["./router"]
|