2022-03-21 12:30:43 +00:00
|
|
|
FROM node:16.14.2-alpine
|
2020-07-30 12:23:49 +00:00
|
|
|
|
2022-03-31 09:57:33 +00:00
|
|
|
RUN apk --no-cache add dnsmasq=2.86-r0 && rm -rf /var/cache/apk/*
|
2021-05-25 14:12:04 +00:00
|
|
|
|
2020-07-30 12:23:49 +00:00
|
|
|
WORKDIR /usr/app
|
|
|
|
|
2021-09-15 10:50:22 +00:00
|
|
|
ENV PATH="/usr/app/bin:${PATH}"
|
|
|
|
|
2021-05-24 15:30:29 +00:00
|
|
|
# schedule critical checks to run every 5 minutes (any failures will disable server)
|
|
|
|
# schedule extended checks to run on every hour (optional checks, report only)
|
2022-03-31 09:57:33 +00:00
|
|
|
RUN echo '*/5 * * * * source /etc/environment ; /usr/app/bin/cli run critical >> /proc/1/fd/1' >> /etc/crontabs/root && \
|
|
|
|
echo '0 * * * * source /etc/environment ; /usr/app/bin/cli run extended >> /proc/1/fd/1' >> /etc/crontabs/root
|
2021-05-24 15:13:29 +00:00
|
|
|
|
2021-07-26 12:00:20 +00:00
|
|
|
COPY package.json yarn.lock ./
|
2021-07-26 11:28:27 +00:00
|
|
|
|
2021-07-26 17:06:15 +00:00
|
|
|
RUN yarn --frozen-lockfile
|
2021-07-26 11:28:27 +00:00
|
|
|
|
2020-09-09 14:08:10 +00:00
|
|
|
COPY src src
|
|
|
|
COPY cli cli
|
2021-09-15 10:50:22 +00:00
|
|
|
COPY bin bin
|
2020-07-30 12:23:49 +00:00
|
|
|
|
|
|
|
EXPOSE 3100
|
|
|
|
ENV NODE_ENV production
|
2021-05-24 15:30:29 +00:00
|
|
|
|
2022-02-08 11:22:49 +00:00
|
|
|
# 1. get public server ip and save it in /etc/environment (passed to cron tasks as env variable)
|
|
|
|
# 2. start dnsmasq in the background with:
|
2021-08-27 12:15:22 +00:00
|
|
|
# - alias PORTAL_DOMAIN with current server ip so it overrides potential load balancer request
|
2021-06-24 09:33:55 +00:00
|
|
|
# - default docker nameserver 127.0.0.11 for any other request
|
2022-02-08 11:22:49 +00:00
|
|
|
# 3. replace docker nameserver with dnsmasq nameserver in /etc/resolv.conf
|
|
|
|
# 4. start crond in the background to schedule periodic health checks
|
|
|
|
# 5. start the health-check api service
|
2021-05-25 14:12:04 +00:00
|
|
|
CMD [ "sh", "-c", \
|
2022-02-08 11:22:49 +00:00
|
|
|
"export serverip=$(node src/whatismyip.js) && \
|
2022-02-08 11:25:08 +00:00
|
|
|
echo \"export serverip=${serverip}\" >> /etc/environment && \
|
2022-02-07 14:57:24 +00:00
|
|
|
dnsmasq --no-resolv --log-facility=/var/log/dnsmasq.log --address=/$PORTAL_DOMAIN/$serverip --server=127.0.0.11 && \
|
|
|
|
echo \"$(sed 's/127.0.0.11/127.0.0.1/' /etc/resolv.conf)\" > /etc/resolv.conf && \
|
|
|
|
crond && \
|
2021-07-26 12:12:33 +00:00
|
|
|
node src/index.js" \
|
2021-05-25 14:12:04 +00:00
|
|
|
]
|