-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
110 lines (89 loc) · 2.72 KB
/
Copy pathDockerfile
File metadata and controls
110 lines (89 loc) · 2.72 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# syntax=docker/dockerfile:1.7
ARG BASE_IMAGE=debian:bookworm-slim
FROM ${BASE_IMAGE}
ENV HOME=/home/graphit \
GRAPHIT_GLOBAL_DIR=/home/graphit/.graphit
ENV GRAPHIT_MODULES_AGENT=false \
GRAPHIT_MODULES_DREAM=false \
GRAPHIT_MODULES_DAEMON_UI=true
ENV GRAPHIT_UI_HOST=0.0.0.0 \
GRAPHIT_UI_ALLOWED_ORIGINS= \
GRAPHIT_MCP_HOST=0.0.0.0 \
GRAPHIT_HUB_EVENTS_ANONYMIZE=false \
GRAPHIT_AGENT= \
GRAPHIT_CLI=
ENV GRAPHIT_CLIENT_SECRET=
RUN <<'EOF' sh -eu
apt-get update
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
tar \
unzip \
git \
less \
ripgrep \
tzdata
rm -rf /var/lib/apt/lists/*
EOF
COPY --chmod=0755 .build/graphit-linux-amd64 /usr/local/bin/graphit
RUN <<'EOF' sh -eu
groupadd --gid 10001 graphit
useradd --uid 10001 --gid graphit --create-home --shell /bin/bash graphit
mkdir -p "${GRAPHIT_GLOBAL_DIR}"
chown graphit:graphit "${GRAPHIT_GLOBAL_DIR}"
EOF
EXPOSE 8080 8081
HEALTHCHECK --interval=30s --timeout=5s --start-period=5m --retries=3 \
CMD curl -fsS "http://127.0.0.1:8081/health" >/dev/null && \
case "${GRAPHIT_MODULES_DAEMON_UI}" in \
[Tt][Rr][Uu][Ee]) curl -fsS "http://127.0.0.1:8080/health" >/dev/null ;; \
esac
VOLUME ["/home/graphit/.graphit"]
COPY <<'SCRIPT' /usr/local/bin/graphit-entrypoint
#!/bin/sh
set -eu
# Container listener ports are part of the image contract. Publish a different
# host port with Docker's HOST:CONTAINER mapping instead of moving the listeners.
GRAPHIT_UI_PORT=8080
GRAPHIT_MCP_PORT=8081
export GRAPHIT_UI_PORT GRAPHIT_MCP_PORT
case "${GRAPHIT_GLOBAL_DIR}" in
/*) ;;
*)
echo "GRAPHIT_GLOBAL_DIR must be an absolute path." >&2
exit 1
;;
esac
if [ "${GRAPHIT_GLOBAL_DIR}" = "/" ]; then
echo "GRAPHIT_GLOBAL_DIR must not be the filesystem root." >&2
exit 1
fi
if ! mkdir -p "${GRAPHIT_GLOBAL_DIR}"; then
echo "Cannot create GRAPHIT_GLOBAL_DIR as user graphit (UID/GID 10001): ${GRAPHIT_GLOBAL_DIR}" >&2
exit 1
fi
if [ ! -r "${GRAPHIT_GLOBAL_DIR}" ] || [ ! -w "${GRAPHIT_GLOBAL_DIR}" ] || [ ! -x "${GRAPHIT_GLOBAL_DIR}" ]; then
echo "GRAPHIT_GLOBAL_DIR must be readable, writable, and traversable by user graphit (UID/GID 10001): ${GRAPHIT_GLOBAL_DIR}" >&2
exit 1
fi
if [ ! -f "${GRAPHIT_GLOBAL_DIR}/config.json" ]; then
env GRAPHIT_MODULES_DAEMON=false graphit setup \
--non-interactive \
"--anonymize-events=${GRAPHIT_HUB_EVENTS_ANONYMIZE}" \
"--agent=${GRAPHIT_AGENT}" \
"--cli=${GRAPHIT_CLI}" \
< /dev/null
fi
if [ "$#" -eq 0 ]; then
exec graphit daemon
fi
case "$1" in
-*) exec graphit daemon "$@" ;;
esac
exec "$@"
SCRIPT
RUN chmod 0755 /usr/local/bin/graphit-entrypoint
WORKDIR /home/graphit/.graphit
USER graphit
ENTRYPOINT ["/usr/local/bin/graphit-entrypoint"]