-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile-alpine
More file actions
63 lines (46 loc) · 1.92 KB
/
Dockerfile-alpine
File metadata and controls
63 lines (46 loc) · 1.92 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
# Do not use if you care about security (read comments)!
FROM alpine:latest
LABEL maintainer "publicarray"
LABEL description "NTP reference implementation, refactored for security"
ENV REVISION 0
ENV NTPSEC_BUILD_DEPS python-dev m4 tar gcc libc-dev bison libressl-dev libcap-dev libseccomp-dev
RUN apk add --no-cache $NTPSEC_BUILD_DEPS
# https://github.com/ntpsec/ntpsec/releases
ENV NTPSEC_VERSION 1.1.8
ENV NTPSEC_DOWNLOAD_URL "https://ftp.ntpsec.org/pub/releases/ntpsec-${NTPSEC_VERSION}.tar.gz"
ENV NTPSEC_SHA256 226b4b29d5166ea3d241a24f7bfc2567f289cf6ed826d8aeb9f2f261c1836bde
RUN set -x && \
mkdir -p /tmp && \
cd /tmp && \
wget -O ntpsec.tar.gz $NTPSEC_DOWNLOAD_URL && \
echo "${NTPSEC_SHA256} *ntpsec.tar.gz" | sha256sum -c - && \
tar xzf ntpsec.tar.gz && \
cd ntpsec-${NTPSEC_VERSION} && \
## can't find apk \
# ./buildprep && \
./waf configure && \
./waf build && \
./waf check && \
./waf install
#------------------------------------------------------------------------------#
FROM alpine:latest
ENV NTPSEC_RUN_DEPS python libressl libcap libseccomp
RUN apk add --no-cache $NTPSEC_RUN_DEPS
COPY --from=0 /usr/local/sbin/ntpd /usr/local/sbin/ntpd
COPY --from=0 /usr/local/bin/ntp* /usr/local/bin/
COPY --from=0 /usr/local/lib/python2.7/site-packages/ntp/ /usr/local/lib/python2.7/site-packages/ntp/
RUN set -x && \
mkdir -p /var/ntpsec/ && \
addgroup -S _ntpsec && \
adduser -S -D -H -s /sbin/nologin -G _ntpsec -g _ntpsec _ntpsec && \
chown -R _ntpsec:_ntpsec /var/ntpsec/
COPY ntp.conf /etc/ntp.conf
EXPOSE 123/udp
RUN ntpd --version
## Broken, Can't find ntp python module
# RUN ntpq --version
ENTRYPOINT ["/usr/local/sbin/ntpd"]
CMD ["-n"]
## libseccomp restrictions don't work, no leap seconds
## changing nice (process priority) is not permitted even with --cap-add SYS_NICE, same locking process into RAM
# CMD ["-n", "-i", "/var/ntpsec/", "-u", "_ntpsec:_ntpsec", "-N"]