Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changesets/docs_lambertjosh_update_docker_docs_runtime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Updates the Docker deployment instructions to use the Apollo Runtime container [PR #7734](https://github.com/apollographql/router/pull/7734)

With the release of the MCP Server, a method to easily deploy Apollo's runtime services was needed. The Apollo Runtime container was designed to address this need, which includes both the Router and MCP Servers in a single Docker container. This PR updates the Router deployment Docker instructions to use this new container.

By [lambertjosh](https://github.com/lambertjosh) in https://github.com/apollographql/router/pull/7734
6 changes: 5 additions & 1 deletion docs/source/_sidebar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ items:
- label: "Overview"
href: "./self-hosted"
- label: "Docker"
href: "./self-hosted/containerization/docker"
children:
- label: "Docker with the Apollo Runtime Container"
href: "./self-hosted/containerization/docker"
- label: "Docker with Apollo Router"
href: "./self-hosted/containerization/docker-router-only"
- label: "Kubernetes"
children:
- label: "Quickstart"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
---
title: Deploying only GraphOS Router in Docker
subtitle: Deploy router-only container image
description: Run an Apollo Router-only container image in Docker with examples covering basic setup, configuration overrides, debugging, and building custom Docker images.
---

import ElasticNotice from '../../../../shared/elastic-notice.mdx';

This guide provides the following examples of running an Apollo Router container image in Docker:

* Running a basic example with default configuration.

Check warning on line 11 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L11

Use hyphens (-) for unordered list items, not asterisks (*). ```suggestion - Running a basic example with default configuration. ```
* Customizing your configuration to override the default configuration.

Check warning on line 12 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L12

Use hyphens (-) for unordered list items, not asterisks (*). ```suggestion - Customizing your configuration to override the default configuration. ```
* Debugging your containerized router.

Check warning on line 13 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L13

Use hyphens (-) for unordered list items, not asterisks (*). ```suggestion - Debugging your containerized router. ```
* Manually specifying a supergraph for your router.

Check warning on line 14 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L14

Use hyphens (-) for unordered list items, not asterisks (*). ```suggestion - Manually specifying a supergraph for your router. ```
* Building your own router Docker image.

Check warning on line 15 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L15

Use hyphens (-) for unordered list items, not asterisks (*). ```suggestion - Building your own router Docker image. ```

The [documentation](https://docs.docker.com/engine/reference/run/) for the `docker run` command is a helpful reference for the examples in this guide.

Check warning on line 17 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L17

Link text should be descriptive of the link's destination. ```suggestion The [<code>docker run</code> command documentation](https://docs.docker.com/engine/reference/run/) is a helpful reference for the examples in this guide. ```

The exact image version to use depends on which release you wish to use. In the following examples, replace `<image version>` with your chosen version, for example `v1.32.0`.

<ElasticNotice />

<Note>This container image only contains the router. Apollo recommends using the [Apollo Runtime container](docker.mdx), which contains all Apollo runtime services.</Note>

## Basic example running router in Docker

Check warning on line 25 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L25

Headings in tutorials should use imperative verbs. ```suggestion ## Run a basic example in Docker ```

To run the router, your Docker container must have the [`APOLLO_GRAPH_REF`](/router/configuration/overview#apollo_graph_ref) and [`APOLLO_KEY`](/router/configuration/overview#apollo_key) environment variables set to your graph ref and API key, respectively.

Below is a basic example of running a router image with Docker, either with `docker run` or `docker compose`. It downloads your supergraph schema from Apollo and uses a default configuration that listens for connections on port `4000`.

Check warning on line 29 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L29

Avoid using directional words like 'below'. ```suggestion The following is a basic example of running a router image with Docker, either with <code>docker run</code> or <code>docker compose</code>. It downloads your supergraph schema from Apollo and uses a default configuration that listens for connections on port <code>4000</code>. ```

You can use `docker run` with the following example command:

```bash title="Docker"
docker run -p 4000:4000 \
--env APOLLO_GRAPH_REF="<your-graph-ref>" \
--env APOLLO_KEY="<your-graph-api-key>" \
--rm \
ghcr.io/apollographql/router:<router-image-version>
```

You can also use `docker compose` with the following example `compose.yaml`:

```yaml title="compose.yaml"
services:
apollo-router:
image: ghcr.io/apollographql/router:<router-image-version>
ports:
- "4000:4000"
environment:
APOLLO_GRAPH_REF: "<your-graph-ref>"
APOLLO_KEY: "<your-graph-api-key>"
```

Whether you use `docker run` or `docker compose`, make sure to replace `<router-image-version>` with whichever version you want to use, and `<your-graph-ref>` and `<your-graph-api-key>` with your graph reference and API key, respectively.

For more complex configurations, such as overriding subgraph URLs or propagating headers, see [Router Configuration](/router/configuration/overview/).

## Override the configuration

Apollo's default Docker images include a [basic router configuration](https://github.com/apollographql/router/blob/main/dockerfiles/router.yaml). Inside the container, this file is located at `/dist/config/router.yaml`.

If you wish to override the default configuration, it is important to preserve aspects of the default configuration. In particular, it is generally important for the router to bind to and listen on the special address of `0.0.0.0` (for all interfaces) to ensure it's exposed on a network interface that's accessible outside of the local container. Without this configuration, the router will only listen on `localhost`.

Check warning on line 62 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L62

This phrasing is more direct and easier to read. ```suggestion When you override the default configuration, you must preserve certain default settings. Specifically, the router must bind to <code>0.0.0.0</code> to be accessible outside its container. Otherwise, the router only listens on <code>localhost</code>. ```

You can provide your own configuration from the host environment to the router by mounting your configuration to `/dist/config/router.yaml` as follows:

```bash {4}
docker run -p 4000:4000 \
--env APOLLO_GRAPH_REF="<your-graph-ref>" \
--env APOLLO_KEY="<your-graph-api-key>" \
--mount "type=bind,source=/home/user/router.yaml,target=/dist/config/router.yaml" \
--rm \
ghcr.io/apollographql/router:<router-image-version>
```

<Note>

Both local and container paths must be specified as absolute paths.

</Note>

In this example we are mounting a file from the host system (`/home/user/router.yaml`) in place of the default configuration provided in the image at `/dist/config/router.yaml`.

Check warning on line 81 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L81

Avoid using 'we' when referring to the reader's actions. Frame content relative to the reader. ```suggestion This example mounts a file from the host system (<code>/home/user/router.yaml</code>) in place of the default configuration provided in the image at <code>/dist/config/router.yaml</code>. ```

## Passing command-line arguments to the router binary

Check warning on line 83 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L83

Headings in tutorials should use imperative verbs. ```suggestion ## Pass command-line arguments to the router binary ```

By default, the `router` command invoked inside the published container doesn't set any of the [available command-line options](/router/configuration/overview#command-line-options). To set them, append the desired option(s) to the `docker run` command.

For example, to start the router using the `--log debug` option, use the following `docker run` command with the option added at the end:

```bash {5}
docker run -p 4000:4000 \
--env APOLLO_GRAPH_REF="<your-graph-ref>" \
--env APOLLO_KEY="<your-graph-api-key>" \
--rm \
ghcr.io/apollographql/router:<router-image-version> --log debug
```

## Debugging your container

Check warning on line 97 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L97

Headings in tutorials should use imperative verbs. ```suggestion ## Debug your container ```

You can debug your container by setting the `entrypoint` in a `docker run` command:

```bash
docker run -p 4000:4000 \
--env APOLLO_GRAPH_REF="<your graph>" \
--env APOLLO_KEY="<your key>" \
--mount "type=bind,source=/router.yaml,target=/dist/config/router.yaml" \
--rm \
--interactive \
--tty \
--entrypoint=bash \
ghcr.io/apollographql/router:<image version>
dist# pwd
/dist
dist# ls
config router schema
dist# exit
exit
```

In this example, we've added both interactive and tty flags, and we've changed the entrypoint of the image to be a bash shell.

Check warning on line 119 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L119

Avoid using 'we' when referring to the reader's actions. Frame content relative to the reader. ```suggestion This example adds both interactive and tty flags and changes the image's entrypoint to a bash shell. ```

### Running the debug container to investigate memory issues

Check warning on line 121 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L121

Headings in tutorials should use imperative verbs. ```suggestion ### Run the debug container to investigate memory issues ```

```bash
docker run -p 4000:4000 \
--env APOLLO_GRAPH_REF="<your graph>" \
--env APOLLO_KEY="<your key>" \
--mount "type=bind,source=/data,target=/dist/data"
--rm \
ghcr.io/apollographql/router:<image version>-debug
```

The router runs under the control of [heaptrack](https://github.com/KDE/heaptrack). The heaptrack output is saved to the `/data` directory. The output can be analyzed directly using `heaptrack_gui` or `heaptrack_print` or shared with Apollo support.

## Specifying the supergraph

Check warning on line 134 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L134

Headings in tutorials should use imperative verbs. ```suggestion ## Specify the supergraph ```

If you don't want to automatically update your supergraph via [Apollo Uplink](/federation/managed-federation/uplink/), or you don't have connectivity to access Apollo Uplink from your environment, you can manually specify the details of your supergraph in a `docker run` command:

```bash
docker run -p 4000:4000 \
--mount "type=bind,source=/docker.graphql,target=/dist/schema/local.graphql" \
--rm \
ghcr.io/apollographql/router:<image version> -c config/router.yaml -s schema/local.graphql
```

In this example, we have to mount the local definition of the supergraph into our image, _and_ specify the location of the file. It doesn't have to be mounted in the `/dist/schema` directory, but it's a reasonable location to use. We must specify the configuration file location as well, since overriding the default params will override our default config file location. In this case, since we don't want to change our router configuration but want to make sure it's used, we just specify the default location of the default configuration.

Check warning on line 145 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L145

Rephrase to be reader-centric ('you') instead of using 'we'. ```suggestion In this example, you mount the local definition of the supergraph into the image _and_ specify the file's location. Although it doesn't have to be mounted in the <code>/dist/schema</code> directory, that's a reasonable location. You must also specify the configuration file location, because overriding the default parameters also overrides the default config file location. In this case, to use the default router configuration, specify its default location. ```

## Building your own container

Check warning on line 147 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L147

Headings in tutorials should use imperative verbs. ```suggestion ## Build your own container ```

<Note>

This section is aimed at developers familiar with tooling such as `docker` and `git` who wish to make their own DIY container images. The script documented here is not a part of the router product, but an illustrative example of what's involved in making your own images.

Check notice on line 151 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L151

This phrasing is more direct and uses simpler language. ```suggestion This section is for developers familiar with tools like <code>docker</code> and <code>git</code> who want to create their own container images. The script shown here is an illustrative example and not part of the router product. ```

</Note>

In the `dockerfiles/diy` directory, we now provide a script, `build_docker_image.sh` which illustrates how to build your own docker images from either our released tarballs or from a git commit hash or tag. Here's how to use it:

Check warning on line 155 in docs/source/routing/self-hosted/containerization/docker-router-only.mdx

View check run for this annotation

Apollo Librarian / AI Style Review

docs/source/routing/self-hosted/containerization/docker-router-only.mdx#L155

Use 'Apollo' instead of 'we' for clarity when referring to the company. ```suggestion In the <code>dockerfiles/diy</code> directory, Apollo provides a script, <code>build_docker_image.sh</code>, which illustrates how to build your own docker images from either our released tarballs or from a git commit hash or tag. Here's how to use it: ```

```bash
% ./build_docker_image.sh -h
Usage: build_docker_image.sh [-b [-r <repo>]] [-d] [<release>]
-b build docker image from the default repo, if not present build from a released version
-d build debug image, router will run under control of heaptrack
-r build docker image from a specified repo, only valid with -b flag
<release> a valid release. If [-b] is specified, this is optional
Example 1: Building HEAD from the repo
build_docker_image.sh -b
Example 2: Building HEAD from a different repo
build_docker_image.sh -b -r /Users/anon/dev/router
Example 3: Building tag from the repo
build_docker_image.sh -b v0.9.1
Example 4: Building commit hash from the repo
build_docker_image.sh -b 7f7d223f42af34fad35b898d976bc07d0f5440c5
Example 5: Building tag v0.9.1 from the released version
build_docker_image.sh v0.9.1
Example 6: Building a debug image with tag v0.9.1 from the released version
build_docker_image.sh -d v0.9.1
```

The example uses [debian:bullseye-slim image](https://hub.docker.com/_/debian/) for the final image build. Feel free to modify the script to use images which better suit your own needs, but be careful if using the `-d` flag because it makes the assumption that there is a `heaptrack` package available to install.
Loading