geschichtenfabio/Dockerfile

44 lines
1.5 KiB
Docker
Raw Normal View History

2024-06-28 23:05:30 +02:00
# geschichtenfabio-dockerized/Dockerfile
2024-06-28 23:21:56 +02:00
# https://git.openvisor.ch/Rider/geschichtenfabio/Dockerfile
2024-06-28 23:05:30 +02:00
# BUILD STAGE
#FROM node:22.1.0-alpine3.19 as build-stage
#WORKDIR /app
# add resources required to build the web application
#COPY . .
# PRODUCTION STAGE
FROM nginx:1.26.0-alpine3.19 as production-stage
WORKDIR /usr/share/nginx/html
# use custom error code websites instead
#RUN rm -f /usr/share/nginx/html/50x.html
# update default.conf nginx file with necessary try_files statement
RUN rm -f /etc/nginx/conf.d/default.conf
RUN mkdir ./geschichten
RUN mkdir ./images
# enable the nginx user to be able to launch the web application, so root is not required
RUN touch /var/run/nginx.pid && \
chown -R nginx:nginx /var/cache/nginx /var/run/nginx.pid
USER nginx
COPY --chown=nginx:nginx ./default.conf /etc/nginx/conf.d/default.conf
# add the previously built web application
COPY --chown=www-data:www-data ./app/geschichten/ ./geschichten/
COPY --chown=www-data:www-data ./app/images/ ./images/
COPY --chown=www-data:www-data ./app/style.css ./style.css
COPY --chown=www-data:www-data ./app/index.html ./index.html
EXPOSE 80
# check every minute whether the website is still locally reachable; if not, the docker process displays "unhealthy"
HEALTHCHECK --interval=1m CMD wget --no-verbose --tries=1 http://localhost:80 -q -O /dev/null || exit 1
# runs nginx in the foreground which means the docker container only runs as long as nginx is running (good practice)
CMD ["nginx", "-g", "daemon off;"]