forked from cturra/docker-ntp
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDockerfile.gps
More file actions
44 lines (35 loc) 路 1.79 KB
/
Copy pathDockerfile.gps
File metadata and controls
44 lines (35 loc) 路 1.79 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
FROM alpine:3.24
ARG BUILD_DATE
LABEL org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.authors="Simon Rupf <[email protected]>" \
org.opencontainers.image.documentation=https://github.com/simonrupf/docker-chronyd \
org.opencontainers.image.description="chronyd with optional GPS reference clock via gpsd, supervised by s6"
# default configuration
ENV NTP_DIRECTIVES="ratelimit\nrtcsync"
# install chrony, gpsd and s6 supervision
RUN apk add --no-cache chrony-nts gpsd s6 tzdata && \
rm /etc/chrony/chrony.conf && \
chmod 1750 /etc/chrony && \
mkdir /run/chrony && \
chown -R chrony:chrony /etc/chrony /run/chrony /var/lib/chrony && \
chmod 1750 /etc/chrony /run/chrony /var/lib/chrony
# entrypoint generates chrony.conf then execs s6-svscan, which supervises
# chronyd and gpsd as siblings (see assets/s6/services/). The service tree
# is copied to /run/chrony/services at startup so s6 can write its
# supervise/ state on an otherwise-read-only rootfs.
COPY --chmod=0755 assets/startup-gps.sh /bin/startup
COPY --chmod=0755 assets/s6 /etc/s6
# ntp port
EXPOSE 123/udp
# marking volumes that need to be writable
# this will also create unnamed volumes on the host system
VOLUME /etc/chrony /run/chrony /var/lib/chrony
# health: chronyd reachable AND gpsd supervised as up. A persistently dead
# gpsd (e.g. unplugged GPS) is restarted by s6, but `s6-svstat -u` returns
# false while it is between restarts, so Docker's default --retries=3 will
# mark the container unhealthy on a sustained outage.
HEALTHCHECK CMD chronyc -n tracking >/dev/null 2>&1 && \
[ "$(s6-svstat -u /run/chrony/services/gpsd)" = "true" ] || exit 1
# start s6 as PID 1 (via the startup script, which generates chrony.conf first)
USER chrony:chrony
ENTRYPOINT [ "/bin/startup" ]