-
Notifications
You must be signed in to change notification settings - Fork 273
/
Dockerfile.router
80 lines (62 loc) · 1.91 KB
/
Dockerfile.router
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
FROM debian:bookworm-slim AS downloader
ARG ROUTER_RELEASE=latest
ARG ARTIFACT_URL=
ARG CIRCLE_TOKEN=
# Install curl
RUN \
apt-get update -y \
&& apt-get install -y \
curl
WORKDIR /dist
# Run the Router downloader which puts Router into current working directory
RUN if [ -z "${ARTIFACT_URL}"]; then \
curl -sSL "https://router.apollo.dev/download/nix/${ROUTER_RELEASE}"/ | sh; \
else \
cd /; \
curl -sSL -H "Circle-Token: ${CIRCLE_TOKEN}" -o - "${ARTIFACT_URL}" | tar -xzf -; \
cd -; \
fi
FROM debian:bookworm-slim AS distro
ARG DEBUG_IMAGE=false
ARG REPO_URL=https://github.com/apollographql/router
# Add a user to run the router as
RUN useradd -m router
WORKDIR /dist
COPY --from=downloader /dist/router /dist
# Update apt and install ca-certificates
RUN \
apt-get update -y \
&& apt-get install -y \
ca-certificates
# If debug image, install heaptrack and make a data directory
RUN \
if [ "${DEBUG_IMAGE}" = "true" ]; then \
apt-get install -y heaptrack && \
mkdir data && \
chown router data; \
fi
# Clean up apt lists
RUN rm -rf /var/lib/apt/lists/*
# Make directories for config and schema
RUN mkdir config schema
# Copy configuration for docker image
COPY dockerfiles/router.yaml config
LABEL org.opencontainers.image.authors="Apollo Graph, Inc. ${REPO_URL}"
LABEL org.opencontainers.image.source="${REPO_URL}"
ENV APOLLO_ROUTER_CONFIG_PATH="/dist/config/router.yaml"
# Create a wrapper script to run the router, use exec to ensure signals are handled correctly
RUN \
echo '#!/usr/bin/env bash \
\nset -e \
\n \
\nif [ -f "/usr/bin/heaptrack" ]; then \
\n exec heaptrack -o /dist/data/$(hostname)/router_heaptrack /dist/router "$@" \
\nelse \
\n exec /dist/router "$@" \
\nfi \
' > /dist/router_wrapper.sh
# Make sure we can run our wrapper
RUN chmod 755 /dist/router_wrapper.sh
USER router
# Default executable is the wrapper script
ENTRYPOINT ["/dist/router_wrapper.sh"]