error-pages/Dockerfile

46 lines
1.6 KiB
Docker
Raw Normal View History

2020-07-08 11:12:21 +00:00
# Image page: <https://hub.docker.com/_/node>
2021-04-13 13:55:03 +00:00
FROM node:15.14-alpine as builder
2020-07-08 11:12:21 +00:00
2021-04-13 13:55:03 +00:00
# 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
2020-07-08 11:12:21 +00:00
2021-04-13 13:55:03 +00:00
# run generator
WORKDIR /src
RUN ./generator/generator.js -c ./config.json -o ./out
2020-07-08 11:12:21 +00:00
2021-04-13 13:55:03 +00:00
# prepare rootfs for runtime
RUN mkdir /tmp/rootfs
WORKDIR /tmp/rootfs
2020-07-08 11:12:21 +00:00
RUN set -x \
2021-04-13 13:55:03 +00:00
&& 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
2020-07-08 11:12:21 +00:00
# Image page: <https://hub.docker.com/_/nginx>
2021-04-13 13:55:03 +00:00
FROM --platform=${TARGETPLATFORM:-linux/amd64} nginx:1.19-alpine as runtime
2020-07-08 11:12:21 +00:00
2021-04-13 13:55:03 +00:00
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"
2020-07-08 11:12:21 +00:00
2021-04-13 13:55:03 +00:00
# Import from builder
COPY --from=builder --chown=nginx /tmp/rootfs /