diff --git a/ansible/post-deploy.yml b/ansible/post-deploy.yml new file mode 100644 index 0000000..7ca6cdb --- /dev/null +++ b/ansible/post-deploy.yml @@ -0,0 +1,33 @@ +--- +- hosts: all + gather_facts: false + tasks: + - name: Load variables + include_vars: + dir: "{{ dokku_lib_root }}/data/ansible/autonomic.zone/vars/" + extensions: + - yml + + - 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: 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: 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 30c7243..f37a1ba 100644 --- a/ansible/pre-deploy.yml +++ b/ansible/pre-deploy.yml @@ -56,30 +56,6 @@ - "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 diff --git a/sbin/entrypoint.sh b/sbin/entrypoint.sh index 4c3f367..1adc139 100755 --- a/sbin/entrypoint.sh +++ b/sbin/entrypoint.sh @@ -6,19 +6,10 @@ set -eu -o pipefail run_jekyll() { set -eu - local args="--port $JEKYLL_PORT --host $JEKYLL_HOST --trace" - - # Note(decentral1se): handle the case where the Dokku is deploying the app - # with HTTP support only before we have a chance to deploy the lets encrypt - # certificates and mount them into the container - if [ -f "$JEKYLL_SSL_CERT" ]; then - args="${args} --ssl-cert $JEKYLL_SSL_CERT" - fi - if [ -f "$JEKYLL_SSL_KEY" ]; then - args="${args} --ssl-key $JEKYLL_SSL_KEY" - fi - - jekyll serve "$args" + jekyll serve \ + --port "$JEKYLL_PORT" \ + --host "$JEKYLL_HOST" \ + --trace } # Main entrypoint