From b20661dc20a6a768839191c4f0f39979c8883720 Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Fri, 19 May 2023 18:08:58 +0200 Subject: [PATCH] Dockerfile & nginx configurations --- Dockerfile | 27 ++++++++++++++++++++++++ nginx.conf | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 Dockerfile create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2ebb6d8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM ruby:3.1-slim-bullseye as jekyll + +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + git \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /opt + +COPY . . + +RUN gem update --system && gem install jekyll bundler +# RUN gem update --system && gem install jekyll && gem cleanup +RUN bundle install && jekyll build + +ENTRYPOINT [ "jekyll" ] + +CMD [ "--help" ] + +# build from the image we just built with different metadata +FROM nginx:alpine + +WORKDIR /app + +COPY nginx.conf /etc/nginx +COPY --from=jekyll /opt/_site . + diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..36cbdc5 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,60 @@ + +user nginx; +worker_processes auto; + +error_log /var/log/nginx/error.log notice; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + gzip on; + gzip_vary on; + gzip_types text/html text/plain text/css text/xml text/javascript application/javascript application/xml; + + server { + listen 4000; + listen [::]:4000; + server_name localhost; + + #access_log /var/log/nginx/host.access.log main; + + location / { + root /app; + default_type "text/html"; + index index.html index.htm; + + if ($request_uri ~ ^/(.*)\.html(\?|$)) { + return 302 /$1; + } + + try_files $uri $uri.html $uri/ =404; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + } +}