From b6bbc3a4110dfd694e69c0be6162c8115bd68177 Mon Sep 17 00:00:00 2001 From: Valerian Saliou Date: Wed, 28 Aug 2024 16:56:39 +0200 Subject: [PATCH] feat: add docker file --- Dockerfile | 8 ++++++++ env/nginx/cors.conf | 5 +++++ env/nginx/mime.types | 21 +++++++++++++++++++++ env/nginx/nginx.conf | 17 +++++++++++++++++ env/nginx/site.conf | 21 +++++++++++++++++++++ 5 files changed, 72 insertions(+) create mode 100644 Dockerfile create mode 100644 env/nginx/cors.conf create mode 100644 env/nginx/mime.types create mode 100644 env/nginx/nginx.conf create mode 100644 env/nginx/site.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..875382e1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM nginx:1.27-alpine-slim as web + +RUN rm -rf /etc/nginx/ /var/www/ + +COPY ./env/nginx /etc/nginx/ +COPY ./build/public /var/www/ + +EXPOSE 8080/tcp diff --git a/env/nginx/cors.conf b/env/nginx/cors.conf new file mode 100644 index 00000000..076cea49 --- /dev/null +++ b/env/nginx/cors.conf @@ -0,0 +1,5 @@ +add_header Access-Control-Allow-Headers "Content-Type, Origin" always; +add_header Access-Control-Allow-Methods "HEAD, GET, OPTIONS" always; +add_header Access-Control-Allow-Credentials "false" always; +add_header Access-Control-Allow-Origin "*" always; +add_header Access-Control-Max-Age "300" always; diff --git a/env/nginx/mime.types b/env/nginx/mime.types new file mode 100644 index 00000000..b8f0eb71 --- /dev/null +++ b/env/nginx/mime.types @@ -0,0 +1,21 @@ +types { + text/html html; + text/css css; + text/xml xml; + text/plain txt; + + application/javascript js; + application/json json; + + image/jpeg jpeg jpg; + image/gif gif; + image/png png; + image/svg+xml svg; + image/webp webp; + image/x-icon ico; + + audio/webm weba; + + font/woff woff; + font/woff2 woff2; +} diff --git a/env/nginx/nginx.conf b/env/nginx/nginx.conf new file mode 100644 index 00000000..f5107575 --- /dev/null +++ b/env/nginx/nginx.conf @@ -0,0 +1,17 @@ +worker_processes 1; +error_log /dev/stdout info; + +events {} + +http { + include mime.types; + charset utf-8; + access_log /dev/stdout; + + server { + listen 8080; + server_name localhost; + + include site.conf; + } +} diff --git a/env/nginx/site.conf b/env/nginx/site.conf new file mode 100644 index 00000000..1b31afdc --- /dev/null +++ b/env/nginx/site.conf @@ -0,0 +1,21 @@ +root /var/www/; + +error_page 404 /404.html; + +location ~ ^/((favicon\.ico)|(favicon(-\d+x\d+)?\.png)) { + rewrite ^/(.*) /favicons/$1 break; +} + +location = /.well-known/host-meta { + default_type application/xrd+xml; + + include cors.conf; +} + +location = /.well-known/host-meta.json { + default_type application/jrd+json; + + include cors.conf; +} + +expires 3h;