diff --git a/README.md b/README.md index 8e8005c0c..dae09a7b7 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,11 @@ CAC_APP_SHARED_FOLDER_TYPE=virtualbox vagrant up Note that if there is an existing build Graph.obj in `otp_data`, vagrant provisioning in development mode will not attempt to rebuild the graph, but will use the one already present. +Django migrations are run as part of app provisioning, [here](https://github.com/azavea/cac-tripplanner/blob/develop/deployment/ansible/roles/cac-tripplanner.app/tasks/main.yml#L67-L72), but there may be instances where you need to manually run migrations outside of provisioning, in which case use the command: +``` +vagrant ssh app -c 'cd /opt/app/python/cac_tripplanner && python3 manage.py migrate' +``` + Building AMIs ------------------------ diff --git a/Vagrantfile b/Vagrantfile index d3418240a..d0eae035b 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -71,7 +71,7 @@ VAGRANT_PROXYCONF_ENDPOINT = ENV["VAGRANT_PROXYCONF_ENDPOINT"] VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - config.vm.box = "bento/ubuntu-18.04" + config.vm.box = "bento/ubuntu-22.04" # Wire up the proxy if: # @@ -86,6 +86,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| end config.vm.define "database" do |database| + # SSH issues bringing up DB VM with base box 22.04 + # Explicitly define downgraded version for use by database until fix + database.vm.box = "bento/ubuntu-20.04" database.vm.hostname = "database" database.vm.network "private_network", ip: "192.168.56.25" diff --git a/deployment/ansible/group_vars/all b/deployment/ansible/group_vars/all index edda281ce..f7964c08d 100644 --- a/deployment/ansible/group_vars/all +++ b/deployment/ansible/group_vars/all @@ -9,7 +9,7 @@ postgres_user: "cac_tripplanner" postgres_password: "cac_tripplanner" postgres_host: "192.168.56.25" -postgresql_support_psycopg2_version: "2.8.*" +postgresql_support_psycopg2_version: "2.9.*" 'postgis_version': [3, 0, 1] packer_version: "1.5.4" diff --git a/deployment/ansible/roles.yml b/deployment/ansible/roles.yml index 04cfe7286..68c03534b 100644 --- a/deployment/ansible/roles.yml +++ b/deployment/ansible/roles.yml @@ -1,9 +1,6 @@ - src: azavea.opentripplanner version: 2.0.1 -- src: azavea.nginx - version: 1.0.0 - - src: azavea.nodejs version: 0.4.0 @@ -12,5 +9,3 @@ - src: azavea.papertrail version: 2.0.0 - - diff --git a/deployment/ansible/roles/cac-tripplanner.app/meta/main.yml b/deployment/ansible/roles/cac-tripplanner.app/meta/main.yml index 04c53cc7e..cc206e8ca 100644 --- a/deployment/ansible/roles/cac-tripplanner.app/meta/main.yml +++ b/deployment/ansible/roles/cac-tripplanner.app/meta/main.yml @@ -1,8 +1,8 @@ --- dependencies: - { role: "azavea.git" } - - { role: "azavea.nginx" } - { role: "azavea.nodejs" } - { role: "azavea.packer" } + - { role: "cac-tripplanner.nginx" } - { role: "cac-tripplanner.papertrail", when: production } - { role: "cac-tripplanner.python3" } diff --git a/deployment/ansible/roles/cac-tripplanner.nginx/defaults/main.yml b/deployment/ansible/roles/cac-tripplanner.nginx/defaults/main.yml new file mode 100644 index 000000000..bcb9c0025 --- /dev/null +++ b/deployment/ansible/roles/cac-tripplanner.nginx/defaults/main.yml @@ -0,0 +1,2 @@ +--- +nginx_delete_default_site: False diff --git a/deployment/ansible/roles/cac-tripplanner.nginx/handlers/main.yml b/deployment/ansible/roles/cac-tripplanner.nginx/handlers/main.yml new file mode 100644 index 000000000..159596ed1 --- /dev/null +++ b/deployment/ansible/roles/cac-tripplanner.nginx/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: Restart Nginx + service: name=nginx state=restarted diff --git a/deployment/ansible/roles/cac-tripplanner.nginx/tasks/main.yml b/deployment/ansible/roles/cac-tripplanner.nginx/tasks/main.yml new file mode 100644 index 000000000..6086c06aa --- /dev/null +++ b/deployment/ansible/roles/cac-tripplanner.nginx/tasks/main.yml @@ -0,0 +1,32 @@ +--- +# Tasks and related artifacts copied from azavea.nginx role +# Customized to use Nginx Stable PPA that works with Ubuntu 22.04 +- name: Configure the Nginx PPA + apt_repository: repo=ppa:ondrej/nginx state=present + +- name: Install Nginx + apt: pkg=nginx-full state=present + +- name: Delete default site + file: path=/etc/nginx/sites-enabled/default state=absent + register: delete_default_site + when: nginx_delete_default_site | bool + notify: + - Restart Nginx + +- name: Delete default web root + file: path=/var/www/html state=absent + when: nginx_delete_default_site | bool and delete_default_site is changed + +- name: Check Nginx Upstart service definition exists + stat: path=/etc/init/nginx.conf + register: nginx_upstart + +- name: Configure Nginx log rotation + template: src=logrotate_nginx.j2 dest=/etc/logrotate.d/nginx + when: nginx_upstart.stat.exists + +- name: Configure Nginx + template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf + notify: + - Restart Nginx diff --git a/deployment/ansible/roles/cac-tripplanner.nginx/templates/logrotate_nginx.j2 b/deployment/ansible/roles/cac-tripplanner.nginx/templates/logrotate_nginx.j2 new file mode 100644 index 000000000..92e628ec3 --- /dev/null +++ b/deployment/ansible/roles/cac-tripplanner.nginx/templates/logrotate_nginx.j2 @@ -0,0 +1,18 @@ +/var/log/nginx/*.log { + weekly + missingok + rotate 52 + compress + delaycompress + notifempty + create 0640 www-data adm + sharedscripts + prerotate + if [ -d /etc/logrotate.d/httpd-prerotate ]; then \ + run-parts /etc/logrotate.d/httpd-prerotate; \ + fi \ + endscript + postrotate + service nginx rotate >/dev/null 2>&1 + endscript +} diff --git a/deployment/ansible/roles/cac-tripplanner.nginx/templates/nginx.conf.j2 b/deployment/ansible/roles/cac-tripplanner.nginx/templates/nginx.conf.j2 new file mode 100644 index 000000000..541317b03 --- /dev/null +++ b/deployment/ansible/roles/cac-tripplanner.nginx/templates/nginx.conf.j2 @@ -0,0 +1,34 @@ +user www-data; +worker_processes {{ ansible_processor_count }}; +pid /run/nginx.pid; + +events { + worker_connections 768; +} + +http { + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + + server_tokens off; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + gzip on; + gzip_vary on; + gzip_proxied any; + gzip_comp_level 6; + gzip_buffers 16 8k; + gzip_http_version 1.1; + gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript; + + include /etc/nginx/conf.d/*.conf; + include /etc/nginx/sites-enabled/*; +} diff --git a/python/cac_tripplanner/requirements.txt b/python/cac_tripplanner/requirements.txt index 6c580b483..f870faef1 100644 --- a/python/cac_tripplanner/requirements.txt +++ b/python/cac_tripplanner/requirements.txt @@ -10,7 +10,7 @@ easy-thumbnails==2.8.1 gunicorn==20.0.4 lxml==4.9.2 Pillow==7.2.0 -psycopg2-binary==2.8.6 +psycopg2-binary==2.9.0 pytz==2020.1 PyYAML==5.3.1 requests==2.24.0