master
Quentin Duchemin 2021-05-27 03:38:08 +02:00
parent ad4fd14ab2
commit 8085f41cda
Signed by: Chosto
GPG Key ID: 0547178FEEDE7D6B
4 changed files with 95 additions and 0 deletions

View File

@ -43,3 +43,7 @@
- funwkhale - funwkhale
- music - music
- docker - docker
- role: hugo
tags:
- docker
- hugo

View File

@ -0,0 +1,37 @@
---
- name: Create Hugo directory
file:
path: "{{ hugo_folder_name }}"
state: directory
owner: "{{ base_user_name }}"
group: "{{ base_user_name }}"
mode: 0755
- name: Copy Hugo Compose file
template:
src: docker-compose.yml.j2
# Remove .j2 extension
dest: "{{ hugo_folder_name }}/docker-compose.yml"
owner: "{{ base_user_name }}"
group: "{{ base_user_name }}"
mode: 0644
- name: Clone blog
ansible.builtin.git:
repo: "{{ repository_url }}"
dest: "{{ hugo_website }}"
force: yes
ignore_errors: yes
- name: Pull new stuff
shell:
cmd: git pull
chdir: "{{ hugo_website }}"
- name: Ensure container is up to date
community.docker.docker_compose:
project_src: "{{ hugo_folder_name }}"
remove_orphans: yes
pull: yes
recreate: smart
state: present

View File

@ -0,0 +1,48 @@
version: "{{ compose_version }}"
networks:
proxy:
name: "{{ traefik_network }}"
# Use a bind mount for Hugo data, easier to pull new versions of blog
volumes:
website_files:
driver: local
driver_opts:
type: none
device: "{{ hugo_website }}"
o: bind
website_public:
driver: local
driver_opts:
type: none
device: "{{ hugo_website }}/public"
o: bind
services:
builder:
container_name: hugo_builder
image: "klakegg/hugo:{{ hugo_version }}"
volumes:
- website_files:/src
# Hugo will build only
# when triggered
restart: on-failure
front:
container_name: hugo_front
image: nginx:alpine
volumes:
- website_public:/usr/share/nginx/html:ro
labels:
traefik.http.routers.hugo.entrypoints: websecure
traefik.http.routers.hugo.rule: "Host(`blog.{{ domain_name }}`)"
traefik.http.services.hugo.loadbalancer.server.port: 80
traefik.enable: true
networks:
- proxy
read_only: true
tmpfs:
- /var/cache/nginx
- /run
restart: unless-stopped

View File

@ -0,0 +1,6 @@
hugo_folder_name: "{{ docker_files }}/hugo"
hugo_website: "{{ hugo_folder_name }}/website"
# Use extended edition with Git inside
# to read git info (useful for lastmod)
hugo_version: 0.83.1-ext-alpine
repository_url: https://git.chosto.me/Chosto/blog.git