diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..decfc0d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM nginx:alpine +COPY ./public /var/www/html + +# Literally copy nginx.conf file from the Dockerfile directory into /etc/nginx/conf.d/default.conf of the container +COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 diff --git a/README.md b/README.md index 9ccfbfc..5915d32 100644 --- a/README.md +++ b/README.md @@ -1,64 +1,19 @@ +# HUGO SITE AVEC DOCKER -![Build Status](https://gitlab.com/pages/hugo/badges/master/build.svg) +Cette branche à pour but de conteneurisé un site HUGO compilé avec un server NGINX. +La configuration pour le NGINX reverse proxy en front se trouve dans le dossir nginx-proxy. ---- +## Attention, le nom de domaine est à configuré dans les deux fichier de NGINX ! -Example [Hugo] website using GitLab Pages. +### DOCKER -Learn more about GitLab Pages at https://pages.gitlab.io and the official -documentation https://docs.gitlab.com/ce/user/project/pages/. +```bash +docker build -t hugo/hugo-site . +docker run -d -p 6666:80 --name hugo-site hugo/hugo-site +``` ---- +### DOCKER-COMPOSE -## GitLab CI - -This project's static Pages are built by [GitLab CI][ci], following the steps -defined in [`.gitlab-ci.yml`](.gitlab-ci.yml). - -## Building locally - -To work locally with this project, you'll have to follow the steps below: - -1. Fork, clone or download this project -1. [Install][] Hugo -1. Preview your project: `hugo server` -1. Add content -1. Generate the website: `hugo` (optional) - -Read more at Hugo's [documentation][]. - -### Preview your site - -If you clone or download this project to your local computer and run `hugo server`, -your site can be accessed under `localhost:1313/hugo/`. - -The theme used is adapted from http://themes.gohugo.io/beautifulhugo/. - -## GitLab User or Group Pages - -To use this project as your user/group website, you will need one additional -step: just rename your project to `namespace.gitlab.io`, where `namespace` is -your `username` or `groupname`. This can be done by navigating to your -project's **Settings**. - -You'll need to configure your site too: change this line -in your `config.toml`, from `"https://pages.gitlab.io/hugo/"` to `baseurl = "https://namespace.gitlab.io"`. -Proceed equally if you are using a [custom domain][post]: `baseurl = "http(s)://example.com"`. - -Read more about [user/group Pages][userpages] and [project Pages][projpages]. - -## Troubleshooting - -1. CSS is missing! That means two things: - - Either that you have wrongly set up the CSS URL in your templates, or - your static generator has a configuration option that needs to be explicitly - set in order to serve static assets under a relative URL. - -[ci]: https://about.gitlab.com/gitlab-ci/ -[hugo]: https://gohugo.io -[install]: https://gohugo.io/overview/installing/ -[documentation]: https://gohugo.io/overview/introduction/ -[userpages]: http://doc.gitlab.com/ee/pages/README.html#user-or-group-pages -[projpages]: http://doc.gitlab.com/ee/pages/README.html#project-pages -[post]: https://about.gitlab.com/2016/04/07/gitlab-pages-setup/#custom-domains +```bash +docker-compose up -d +``` diff --git a/config.toml b/config.toml index d18f5aa..8d6087c 100644 --- a/config.toml +++ b/config.toml @@ -1,5 +1,5 @@ # Configuration de l'adresse, titre (onglet) et des chemins vers les contenus -baseurl = "https://greglebreton.gitlab.io/hugo-site/" +baseurl = "https://hugo.gregandev.fr" contentdir = "content" layoutdir = "layouts" publishdir = "public" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..dd28576 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.9' +services: + hugo2: + image: nginx:alpine + container_name: hugo-site2 + volumes: + - ./nginx:/etc/nginx/conf.d + - ./public:/var/www/html + ports: + - 6666:80 diff --git a/nginx-docker/nginx.conf b/nginx-docker/nginx.conf new file mode 100644 index 0000000..be80632 --- /dev/null +++ b/nginx-docker/nginx.conf @@ -0,0 +1,23 @@ +# config pour le nginx dans le caontainer +server { + listen 80; + listen [::]:80; + server_name localhost; + + location / { + root /var/www/html; + index index.html index.htm; + } + + error_page 404 /404.html; # Here and below is 404 error handling docs tried to describe + location = /404.html { + root /var/www/html; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /var/www/html; + } + +} + diff --git a/nginx-proxy/nginx-proxy.conf b/nginx-proxy/nginx-proxy.conf new file mode 100644 index 0000000..5b1a620 --- /dev/null +++ b/nginx-proxy/nginx-proxy.conf @@ -0,0 +1,43 @@ +server { + listen 80; + listen [::]:80; + + server_name example.com; + + client_max_body_size 64M; + + # Redirection HTTP -> HTTPS + return 301 https://$host$request_uri; + +} + +server{ + listen 443 ssl http2; + listen [::]:443 ssl http2; + + server_name example.com; + + location / { + proxy_buffering off; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $server_name; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://127.0.0.1:6666; + } + + # Nécessaire pour les redirections inetrnes à Hugo + location /feed { + return 302 https://example.com/index.xml; + } + + ssl on; + ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; + + access_log /var/log/nginx/hugo_access.log; + error_log /var/log/nginx/hugo_error.log; + +} diff --git a/themes/beautifulhugo/i18n/fr.yaml b/themes/beautifulhugo/i18n/fr.yaml index 3ffece1..b0338ee 100644 --- a/themes/beautifulhugo/i18n/fr.yaml +++ b/themes/beautifulhugo/i18n/fr.yaml @@ -2,7 +2,7 @@ - id: dateFormat translation: "2 Janvier, 2006" - id: postedOnDate - #translation: "Posté le {{ .Count }}" + translation: "Posté le " - id: translationsLabel translation: "Autres langues: " - id: translationsSeparator