nginx compatibility added to serve static files on server; whitenoise installed to catch static file serving in local docker container, also added to core.settings middleware; console logs & print statements removed from dashboard.js & functional_tests.container_commands; ansible playbook and nginx config file support nginx w.in deployment workflow
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
- hosts: staging
|
||||
- hosts: all
|
||||
|
||||
tasks:
|
||||
- name: Debug django_allowed_host
|
||||
@@ -12,6 +12,34 @@
|
||||
update_cache: true
|
||||
become: true
|
||||
|
||||
- name: Install nginx
|
||||
ansible.builtin.apt:
|
||||
name: nginx
|
||||
state: latest
|
||||
become: true
|
||||
|
||||
- name: Deploy nginx config
|
||||
ansible.builtin.template:
|
||||
src: nginx.conf.j2
|
||||
dest: /etc/nginx/sites-available/gamearray
|
||||
become: true
|
||||
notify: Restart nginx
|
||||
|
||||
- name: Enable nginx site
|
||||
ansible.builtin.file:
|
||||
src: /etc/nginx/sites-available/gamearray
|
||||
dest: /etc/nginx/sites-enabled/gamearray
|
||||
state: link
|
||||
become: true
|
||||
notify: Restart nginx
|
||||
|
||||
- name: Remove default nginx site
|
||||
ansible.builtin.file:
|
||||
path: /etc/nginx/sites-enabled/default
|
||||
state: absent
|
||||
become: true
|
||||
notify: Restart nginx
|
||||
|
||||
- name: Add our user to the docker group, so we don't need sudo/become
|
||||
ansible.builtin.user:
|
||||
name: '{{ ansible_user }}'
|
||||
@@ -88,9 +116,29 @@
|
||||
EMAIL_HOST_PASSWORD: "{{ email_host_password }}"
|
||||
MAILGUN_API_KEY: "{{ mailgun_api_key }}"
|
||||
ports:
|
||||
80:8888 # container port 80 (standard http port) maps to server port 8888 (arbitrary internal port)
|
||||
127.0.0.1:8888:8888
|
||||
|
||||
- name: Create static files directory
|
||||
ansible.builtin.file:
|
||||
path: /var/www/gamearray/static
|
||||
state: directory
|
||||
owner: www-data
|
||||
group: www-data
|
||||
become: true
|
||||
|
||||
- name: Copy static files from container to host
|
||||
ansible.builtin.command:
|
||||
cmd: docker cp gamearray:/src/static/. /var/www/gamearray/static/
|
||||
become: true
|
||||
|
||||
- name: Run migration inside container
|
||||
community.docker.docker_container_exec:
|
||||
container: gamearray
|
||||
command: ./manage.py migrate
|
||||
command: ./manage.py migrate
|
||||
|
||||
handlers:
|
||||
- name: Restart nginx
|
||||
ansible.builtin.service:
|
||||
name: nginx
|
||||
state: restarted
|
||||
become: true
|
||||
Reference in New Issue
Block a user