diff --git a/.circleci/config.yml b/.circleci/config.yml index dd64a73ed6..c09d662e03 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -487,7 +487,7 @@ jobs: command: | ROUTER_TAG=ghcr.io/apollographql/router # Build debug image - docker build --build-arg ROUTER_RELEASE=${VERSION} --build-arg DEBUG_IMAGE=":debug" -f dockerfiles/Dockerfile.router -t ${ROUTER_TAG}:${VERSION}-debug . + docker build --build-arg ROUTER_RELEASE=${VERSION} -f dockerfiles/Dockerfile.router -t ${ROUTER_TAG}:${VERSION}-debug . # Build release image docker build --build-arg ROUTER_RELEASE=${VERSION} -f dockerfiles/Dockerfile.router -t ${ROUTER_TAG}:${VERSION} . # Note: GH Token owned by apollo-bot2, no expire diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index b7240fef20..fefa615e58 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -70,6 +70,15 @@ By [@bnjjj](https://github.com/bnjjj) in https://github.com/apollographql/router By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/2096 ## 🛠 Maintenance + +### Use `debian:bullseye-slim` as our base Docker image ([PR #2085](https://github.com/apollographql/router/pull/2085)) + +A while ago, when we added compression support to the router, we discovered that the Distroless base-images we were using didn't ship with a copy of `libz.so.1`. We addressed that problem by copying in a version of the library from the Distroless image (Java) which does ship it. While that worked, we found challenges in adding support for both `aarch64` and `amd64` Docker images that would make it less than ideal to continue using those Distroless images. + +Rather than persist with this complexity, we've concluded that it would be better to just use a base image which ships with `libz.so.1`, hence the change to `debian:bullseye-slim`. Those images are still quite minimal and the resulting images are similar in size. + +By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/2085 + ## 📚 Documentation ### Fix example `helm show values` command ([PR #2088](https://github.com/apollographql/router/pull/2088)) diff --git a/dockerfiles/Dockerfile.router b/dockerfiles/Dockerfile.router index 088a4c0e4f..40d475ef3d 100644 --- a/dockerfiles/Dockerfile.router +++ b/dockerfiles/Dockerfile.router @@ -1,6 +1,4 @@ -ARG DEBUG_IMAGE -# Build is required to extract the release files -FROM --platform=linux/amd64 debian:bullseye-slim AS build +FROM debian:bullseye-slim ARG ROUTER_RELEASE=latest @@ -22,23 +20,9 @@ RUN mkdir config schema # Copy configuration for docker image COPY dockerfiles/router.yaml config -# Required so we can copy in libz.so.1 -FROM --platform=linux/amd64 gcr.io/distroless/java17-debian11${DEBUG_IMAGE} as libz-required - -# Final image uses distroless -FROM --platform=linux/amd64 gcr.io/distroless/cc-debian11${DEBUG_IMAGE} - LABEL org.opencontainers.image.authors="Apollo Graph, Inc. https://github.com/apollographql/router" LABEL org.opencontainers.image.source="https://github.com/apollographql/router" -# Copy in the extracted/created files -COPY --from=libz-required /lib/x86_64-linux-gnu/libz.so.1 /lib/x86_64-linux-gnu/libz.so.1 - -WORKDIR /dist - -# Copy in the extracted/created files -COPY --from=build --chown=root:root /dist . - ENV APOLLO_ROUTER_CONFIG_PATH="/dist/config/router.yaml" # Default executable is the router diff --git a/dockerfiles/diy/build_docker_image.sh b/dockerfiles/diy/build_docker_image.sh index 60389a6b38..208f9b756b 100755 --- a/dockerfiles/diy/build_docker_image.sh +++ b/dockerfiles/diy/build_docker_image.sh @@ -122,8 +122,10 @@ fi echo "Building in: ${BUILD_DIR}" # Copy in our dockerfiles, we'll need them later -cp dockerfiles/* "${BUILD_DIR}" || terminate "Couldn't copy dockerfiles to ${BUILD_DIR}" -cp ../router.yaml "${BUILD_DIR}" || terminate "Couldn't copy ../router.yaml to ${BUILD_DIR}" +mkdir "${BUILD_DIR}/dockerfiles" +cp dockerfiles/Dockerfile.repo "${BUILD_DIR}" || terminate "Couldn't copy dockerfiles to ${BUILD_DIR}" +cp ../Dockerfile.router "${BUILD_DIR}" || terminate "Couldn't copy dockerfiles to ${BUILD_DIR}" +cp ../router.yaml "${BUILD_DIR}/dockerfiles" || terminate "Couldn't copy ../router.yaml to ${BUILD_DIR}" # Change to our build directory cd "${BUILD_DIR}" || terminate "Couldn't cd to ${BUILD_DIR}"; @@ -149,7 +151,7 @@ else echo "Building image: ${ROUTER_VERSION}" from released version"" docker build -q -t "router:${ROUTER_VERSION}" \ --build-arg ROUTER_RELEASE="${ROUTER_VERSION}" \ - --no-cache -f Dockerfile.release . \ + --no-cache -f Dockerfile.router . \ || terminate "Couldn't build router image" fi diff --git a/dockerfiles/diy/dockerfiles/Dockerfile.release b/dockerfiles/diy/dockerfiles/Dockerfile.release deleted file mode 100644 index 54c13245d1..0000000000 --- a/dockerfiles/diy/dockerfiles/Dockerfile.release +++ /dev/null @@ -1,47 +0,0 @@ -# Note: We require linux/amd64 images here, because we are definitely -# downloading linux/amd64 images from github and would like our image -# builds to work on platforms such as Mac OS X/M1 (with some help from -# rosetta) -# Build is required to extract the release files -FROM --platform=linux/amd64 debian:bullseye-slim AS build - -ARG ROUTER_RELEASE=latest - -WORKDIR /dist - -# Install curl -RUN \ - apt-get update -y \ - && apt-get install -y \ - curl \ - && rm -rf /var/lib/apt/lists/* - -# Run the Router downloader which puts Router into current working directory -RUN curl -sSL https://router.apollo.dev/download/nix/${ROUTER_RELEASE}/ | sh - -# Make directories for config and schema -RUN mkdir config schema - -# Copy configuration for docker image -COPY router.yaml config - -# Required so we can copy in libz.so.1 -FROM --platform=linux/amd64 gcr.io/distroless/java17-debian11 as libz-required - -# Final image uses distroless. Feel free to change this to an image that suits your needs. -FROM --platform=linux/amd64 gcr.io/distroless/cc-debian11 - -LABEL org.opencontainers.image.authors="Apollo Graph, Inc. https://github.com/apollographql/router" - -# Copy in the extracted/created files -COPY --from=libz-required /lib/x86_64-linux-gnu/libz.so.1 /lib/x86_64-linux-gnu/libz.so.1 - -WORKDIR /dist - -# Copy in the extracted/created files -COPY --from=build --chown=root:root /dist . - -ENV APOLLO_ROUTER_CONFIG_PATH="/dist/config/router.yaml" - -# Default executable is the router -ENTRYPOINT ["/dist/router"] diff --git a/dockerfiles/diy/dockerfiles/Dockerfile.repo b/dockerfiles/diy/dockerfiles/Dockerfile.repo index 296e2eb894..3e0a5b9664 100644 --- a/dockerfiles/diy/dockerfiles/Dockerfile.repo +++ b/dockerfiles/diy/dockerfiles/Dockerfile.repo @@ -28,17 +28,11 @@ RUN mkdir -p /dist/config && \ # Copy configuration for docker image COPY dockerfiles/router.yaml /dist/config -# Required so we can copy in libz.so.1 -FROM --platform=linux/amd64 gcr.io/distroless/java17-debian11 as libz-required +FROM debian:bullseye-slim -# Final image uses distroless. Feel free to change this to an image that suits your needs. -FROM gcr.io/distroless/cc-debian11 - -# Set a label for our image -LABEL org.opencontainers.image.authors="ApolloGraphQL https://github.com/apollographql/router" - -# Copy in the extracted/created files -COPY --from=libz-required /lib/x86_64-linux-gnu/libz.so.1 /lib/x86_64-linux-gnu/libz.so.1 +# Set labels for our image +LABEL org.opencontainers.image.authors="Apollo Graph, Inc. https://github.com/apollographql/router" +LABEL org.opencontainers.image.source="https://github.com/apollographql/router" # Copy in the required files from our build image COPY --from=build --chown=root:root /dist /dist