This repository has been archived by the owner on Feb 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
71 lines (52 loc) · 1.65 KB
/
Dockerfile
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
# ====================
# STAGE 1: base
# ====================
FROM ruby:2.6.1-alpine3.9 AS base
ENV CLIENT_DEPS git libcap ca-certificates bind-tools dumb-init
ENV BUILD_DEPS build-base cmake libxml2-dev libxslt-dev libffi-dev zlib-dev libressl-dev openssl-dev
RUN set -xe \
&& apk add --update --no-cache ${CLIENT_DEPS} \
&& apk add --virtual .build-deps ${BUILD_DEPS} \
&& mkdir -p /src \
&& rm -rf /var/cache/apk/*
WORKDIR /src/
# ====================
# STAGE 2: bundler
# ====================
FROM base AS bundler
COPY ./source/Gemfile* /src/
RUN set -xe \
&& gem install bundler --update \
&& bundle config --global silence_root_warning 1 \
&& bundle config --global build.nokogiri --use-system-libraries \
&& bundle config --global jobs `expr $(cat /proc/cpuinfo | grep -c "cpu cores") - 1` \
&& bundle config --global retry 6 \
&& echo -e 'gem: --no-document' >> /etc/gemrc \
&& bundle install \
&& rm -rf /usr/local/bundle/cache/*.gem \
&& find /usr/local/bundle/gems/ -name "*.c" -delete \
&& find /usr/local/bundle/gems/ -name "*.o" -delete
FROM base AS dev
WORKDIR /src/
COPY ./source/ /src/
COPY --from=bundler /usr/local/bundle /usr/local/bundle
EXPOSE 8053
EXPOSE 8053/udp
CMD ["ash"]
# ====================
# STAGE 3: secure
# ====================
FROM base AS secure
WORKDIR /src/
COPY --from=bundler /usr/local/bundle /usr/local/bundle
RUN set -xe \
&& setcap 'cap_net_raw+ep' /bin/busybox \
&& setcap 'cap_net_raw+ep' /usr/local/bin/ruby \
&& addgroup -g 1000 -S dot \
&& adduser -u 1000 -S dot -G dot
COPY --chown=dot:dot ./source/ /src/
USER dot
EXPOSE 8053
EXPOSE 8053/udp
ENTRYPOINT ["dumb-init"]
CMD ["ruby", "bin/dot.rb", "run"]