From 9e539545b8250a9e7dd3412016de8eab4b483fce Mon Sep 17 00:00:00 2001 From: Yax <1949284+kianby@users.noreply.github.com> Date: Fri, 30 Jul 2021 19:26:21 +0200 Subject: [PATCH] dockerfile --- Dockerfile | 30 ++++++++++++++++++++++++++++++ docker/docker-init.sh | 15 +++++++++++++++ docker/nginx.conf | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 Dockerfile create mode 100644 docker/docker-init.sh create mode 100644 docker/nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..93ad9c9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM nginx:1.19.0-alpine + +RUN apk update && apk add bash git python3 make tzdata && rm -rf /var/cache/apk/* +RUN python3 -m pip install requests mistune pygments toml +COPY docker/nginx.conf /etc/nginx/nginx.conf + +# install locales +ENV MUSL_LOCALE_DEPS cmake make musl-dev gcc gettext-dev libintl +ENV MUSL_LOCPATH /usr/share/i18n/locales/musl + +RUN apk add --no-cache \ + $MUSL_LOCALE_DEPS \ + && wget https://gitlab.com/rilian-la-te/musl-locales/-/archive/master/musl-locales-master.zip \ + && unzip musl-locales-master.zip \ + && cd musl-locales-master \ + && cmake -DLOCALE_PROFILE=OFF -D CMAKE_INSTALL_PREFIX:PATH=/usr . && make && make install \ + && cd .. && rm -r musl-locales-master + +# set timezone and locale +RUN cp /usr/share/zoneinfo/Europe/Paris /etc/localtime +RUN echo "Europe/Paris" > /etc/timezone +ENV TZ Europe/Paris +ENV LANG fr_FR.UTF-8 +ENV LANGUAGE fr_FR.UTF-8 +ENV LC_ALL fr_FR.UTF-8 + +COPY docker/docker-init.sh /usr/local/bin/ +RUN chmod +x usr/local/bin/docker-init.sh + +CMD ["docker-init.sh"] \ No newline at end of file diff --git a/docker/docker-init.sh b/docker/docker-init.sh new file mode 100644 index 0000000..b0905d7 --- /dev/null +++ b/docker/docker-init.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# clone and build blog +cd / +rm -rf /blog +git clone https://github.com/kianby/blog.git +cd /blog +make + +# nginx serve +#nginx -g 'daemon off;' +nginx + +# exit on change in stacosys or Git repo +python3 monitor.py \ No newline at end of file diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 0000000..1e12392 --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,42 @@ +user nginx; +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + sendfile off; + send_timeout 20; + keepalive_timeout 60; + + gzip on; + gzip_static on; + gzip_min_length 512; + gzip_buffers 16 8k; + gzip_http_version 1.1; + gzip_vary on; + gzip_comp_level 6; + gzip_proxied any; + gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js; + gzip_disable "MSIE [1-6]\.(?!.*SV1)"; + + server { + listen 80 default_server; + listen [::]:80 default_server; + server_name _; + + root /blog/_site; + index index.html; + add_header Cache-Control "no-cache"; + + location /newcomment { + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_pass http://stacosys:8100/newcomment; + } + } +}