error-pages/Dockerfile
Paramtamtam ce98410e51
Nginx Healthcheck endpoint + Dockerfile healthcheck (#23)
Co-authored-by: modem7 <modem7@gmail.com>
2021-09-06 11:47:10 +05:00

53 lines
1.8 KiB
Docker

# Image page: <https://hub.docker.com/_/node>
FROM node:15.14-alpine as builder
# copy required sources into builder image
COPY ./generator /src/generator
COPY ./config.json /src
COPY ./templates /src/templates
COPY ./docker /src/docker
# install generator dependencies
WORKDIR /src/generator
RUN yarn install --frozen-lockfile --no-progress --non-interactive
# run generator
WORKDIR /src
RUN ./generator/generator.js -c ./config.json -o ./out
# prepare rootfs for runtime
RUN mkdir /tmp/rootfs
WORKDIR /tmp/rootfs
RUN set -x \
&& mkdir -p \
./docker-entrypoint.d \
./etc/nginx/conf.d \
./opt \
&& mv /src/out ./opt/html \
&& echo -e "User-agent: *\nDisallow: /\n" > ./opt/html/robots.txt \
&& touch ./opt/html/favicon.ico \
&& mv /src/docker/docker-entrypoint.d/* ./docker-entrypoint.d \
&& mv /src/docker/nginx-server.conf ./etc/nginx/conf.d/default.conf
# Image page: <https://hub.docker.com/_/nginx>
FROM nginx:1.21.1-alpine as runtime
LABEL \
# Docs: <https://github.com/opencontainers/image-spec/blob/master/annotations.md>
org.opencontainers.image.title="error-pages" \
org.opencontainers.image.description="Static server error pages in docker image" \
org.opencontainers.image.url="https://github.com/tarampampam/error-pages" \
org.opencontainers.image.source="https://github.com/tarampampam/error-pages" \
org.opencontainers.image.vendor="tarampampam" \
org.opencontainers.image.licenses="MIT"
# Import from builder
COPY --from=builder /tmp/rootfs /
# Docs: <https://docs.docker.com/engine/reference/builder/#healthcheck>
HEALTHCHECK --interval=15s --timeout=2s --retries=2 --start-period=2s CMD [ \
"wget", "--spider", "-q", "http://127.0.0.1:8080/health/live" \
]
RUN chown -R nginx:nginx /opt/html