From caa1e521ad902ddf2a5ee07f32e6a1fb73f43d38 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Mon, 6 Apr 2020 10:58:55 +0200 Subject: [PATCH] Experiment with full pre-deploy setup --- Dockerfile | 2 ++ ansible/post-deploy.yml | 40 --------------------------------- ansible/pre-deploy.yml | 49 +++++++++++++++++++++++++++++++++++++++++ ansible/vars/all.yml | 2 ++ 4 files changed, 53 insertions(+), 40 deletions(-) delete mode 100644 ansible/post-deploy.yml diff --git a/Dockerfile b/Dockerfile index 28dac02..fed9fa4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,8 @@ WORKDIR /usr/src/app COPY . ${WORKDIR} +COPY sbin/* /sbin/ + RUN bundle config --global frozen 1 RUN bundle install diff --git a/ansible/post-deploy.yml b/ansible/post-deploy.yml deleted file mode 100644 index e7b31d7..0000000 --- a/ansible/post-deploy.yml +++ /dev/null @@ -1,40 +0,0 @@ ---- -- hosts: all - gather_facts: false - tasks: - - name: Load variables - include_vars: - dir: "{{ dokku_lib_root }}/data/ansible/autonomic.zone/vars/" - extensions: - - yml - - - name: Set HTTP 80 port proxy - dokku_ports: - app: autonomic.zone - mappings: - - "http:80:{{ http_port }}" - state: present - - - name: Setup LE certificates - shell: dokku letsencrypt autonomic.zone - args: - creates: /home/dokku/autonomic.zone/letsencrypt/certs - - - name: Setup LE certificates renew cron job - shell: dokku letsencrypt:cron-job --add - args: - creates: /home/dokku/autonomic.zone/letsencrypt/cron-job - - - name: Remove automatically configured ports - dokku_ports: - app: autonomic.zone - mappings: - - "http:4000:4000" - state: absent - - - name: Set HTTP 443 port - dokku_ports: - app: autonomic.zone - mappings: - - "https:443:{{ http_port }}" - state: present diff --git a/ansible/pre-deploy.yml b/ansible/pre-deploy.yml index 1bc2d87..30c7243 100644 --- a/ansible/pre-deploy.yml +++ b/ansible/pre-deploy.yml @@ -35,9 +35,58 @@ - "{{ domain }}" state: present + - name: Ensure default app configured domains go away + dokku_domains: + app: autonomic.zone + domains: + - autonomic.zone.dokku.autonomic.zone + state: absent + + - name: Set HTTP 80 port proxy + dokku_ports: + app: autonomic.zone + mappings: + - "http:80:{{ http_port }}" + state: present + + - name: Remove automatically configured ports + dokku_ports: + app: autonomic.zone + mappings: + - "http:4000:4000" + state: absent + + - name: Setup LE certificates + shell: dokku letsencrypt autonomic.zone + args: + creates: /home/dokku/autonomic.zone/letsencrypt/certs + + - name: Setup LE certificates renew cron job + shell: dokku letsencrypt:cron-job --add + args: + creates: /home/dokku/autonomic.zone/letsencrypt/cron-job + + - name: Set HTTP 443 port + dokku_ports: + app: autonomic.zone + mappings: + - "https:443:{{ http_port }}" + state: present + + - name: Specify docker volume mounts + dokku_storage: + app: autonomic.zone + mounts: + - /home/dokku/autonomic.zone/letsencrypt/certs/current/key.pem:/etc/x509/https/tls.key + - /home/dokku/autonomic.zone/letsencrypt/certs/current/cert.pem:/etc/x509/https/tls.crt + - name: Configure the dokku app environment dokku_config: app: autonomic.zone restart: false config: DOKKU_LETSENCRYPT_EMAIL: "{{ autonomic_admin_mail }}" + JEKYLL_HOST: "{{ domain }}" + JEKYLL_PORT: "{{ http_port }}" + JEKYLL_SSL_CERT: "{{ ssl_cert_path }}" + JEKYLL_SSL_KEY: "{{ ssl_key_path }}" diff --git a/ansible/vars/all.yml b/ansible/vars/all.yml index 33257b2..4b87015 100644 --- a/ansible/vars/all.yml +++ b/ansible/vars/all.yml @@ -4,3 +4,5 @@ autonomic_admin_mail: "helo@autonomic.zone" dokku_domain_ipv4: "94.130.105.60" domain: "site.autonomic.zone" http_port: "4000" +ssl_cert_path: "/etc/x509/https/tls.crt" +ssl_key_path: "/etc/x509/https/tls.key"