From d0c36adba889b3bd14ab73e069b62d0205442f0b Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 10 Apr 2020 11:31:01 +0100 Subject: [PATCH] =?UTF-8?q?Self=20host=20my=20website=20=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../files/theorangeone.net/docker-compose.yml | 13 +++++++++ .../files/watchtower/docker-compose.yml | 1 + ansible/roles/docker/tasks/main.yml | 3 ++ .../roles/docker/tasks/theorangeone.net.yml | 29 +++++++++++++++++++ terraform/theorangeone.net.tf | 8 ++--- 5 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 ansible/roles/docker/files/theorangeone.net/docker-compose.yml create mode 100644 ansible/roles/docker/tasks/theorangeone.net.yml diff --git a/ansible/roles/docker/files/theorangeone.net/docker-compose.yml b/ansible/roles/docker/files/theorangeone.net/docker-compose.yml new file mode 100644 index 0000000..02c7acf --- /dev/null +++ b/ansible/roles/docker/files/theorangeone.net/docker-compose.yml @@ -0,0 +1,13 @@ +version: "2.3" +services: + website: + image: docker.pkg.github.com/realorangeone/theorangeone.net/theorangeone.net:latest + container_name: theorangeone.net + environment: + - TZ=Europe/London + restart: unless-stopped + labels: + - "traefik.enable=true" + - "traefik.http.routers.website.rule=Host(`theorangeone.net`) || Host(`www.theorangeone.net`)" + - "traefik.http.routers.website.tls=true" + - "traefik.http.routers.website.tls.certresolver=le" diff --git a/ansible/roles/docker/files/watchtower/docker-compose.yml b/ansible/roles/docker/files/watchtower/docker-compose.yml index 64420b5..c88894e 100644 --- a/ansible/roles/docker/files/watchtower/docker-compose.yml +++ b/ansible/roles/docker/files/watchtower/docker-compose.yml @@ -4,4 +4,5 @@ services: image: containrrr/watchtower:latest volumes: - /var/run/docker.sock:/var/run/docker.sock + - "{{ home }}/.docker/config.json:/config.json:ro" command: --cleanup --interval 300 diff --git a/ansible/roles/docker/tasks/main.yml b/ansible/roles/docker/tasks/main.yml index e5b40d5..89b1e28 100644 --- a/ansible/roles/docker/tasks/main.yml +++ b/ansible/roles/docker/tasks/main.yml @@ -69,3 +69,6 @@ - name: Install pihole include: pihole.yml + +- name: Install theorangeone.net + include: theorangeone.net.yml diff --git a/ansible/roles/docker/tasks/theorangeone.net.yml b/ansible/roles/docker/tasks/theorangeone.net.yml new file mode 100644 index 0000000..0784095 --- /dev/null +++ b/ansible/roles/docker/tasks/theorangeone.net.yml @@ -0,0 +1,29 @@ +- name: Create theorangeone.net directory + file: + path: /opt/theorangeone.net + state: directory + owner: "{{ docker_user.name }}" + mode: "{{ docker_compose_directory_mask }}" + become: true + +- name: Install theorangeone.net compose file + template: + src: files/theorangeone.net/docker-compose.yml + dest: /opt/theorangeone.net/docker-compose.yml + mode: "{{ docker_compose_file_mask }}" + owner: "{{ docker_user.name }}" + validate: /usr/bin/docker-compose -f %s config + register: compose_file + become: true + +- name: Cycle theorangeone.net container + docker_compose: + project_src: /opt/theorangeone.net + pull: true + remove_orphans: true + remove_volumes: true + state: "{{ item }}" + when: compose_file.changed + loop: + - absent + - present diff --git a/terraform/theorangeone.net.tf b/terraform/theorangeone.net.tf index b14996b..61de17a 100644 --- a/terraform/theorangeone.net.tf +++ b/terraform/theorangeone.net.tf @@ -87,16 +87,16 @@ resource "cloudflare_record" "theorangeonenet_dkim_fm3" { resource "cloudflare_record" "theorangeonenet_www" { zone_id = cloudflare_zone.theorangeonenet.id name = "www" - value = "theorangeone-net.netlify.com" - type = "CNAME" + value = vultr_server.casey.main_ip + type = "A" ttl = 1 } resource "cloudflare_record" "theorangeonenet_apex" { zone_id = cloudflare_zone.theorangeonenet.id name = "@" - value = "theorangeone-net.netlify.com" - type = "CNAME" + value = vultr_server.casey.main_ip + type = "A" ttl = 1 }