Skip to content

Commit d0f1b17

Browse files
authored
Merge pull request #118 from caktus/develop
Production Release June 28, 2022
2 parents 65c2207 + e012ac0 commit d0f1b17

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+36327
-412
lines changed

.circleci/config.yml

-73
This file was deleted.

.github/workflows/deploy.yaml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: deploy
2+
3+
on:
4+
push:
5+
branches: [main, develop, 112-deploy-fix]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-20.04
10+
env:
11+
ENV: staging
12+
GITHUB_ENV: https://staging.nccopwatch.org/
13+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
14+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
15+
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0
20+
- name: Set env vars (production)
21+
if: endsWith(github.ref, '/main')
22+
run: |
23+
echo "ENV=production" >> $GITHUB_ENV
24+
echo "ENV_URL=https://nccopwatch.org/" >> $GITHUB_ENV
25+
- uses: actions/setup-python@v2
26+
with:
27+
python-version: '3.9'
28+
cache: 'pip'
29+
cache-dependency-path: 'requirements/*/*.txt'
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install pip-tools
33+
pip-sync requirements/base/base.txt requirements/dev/dev.txt
34+
- name: Start deployment
35+
uses: bobheadxi/deployments@v1
36+
id: deployment
37+
with:
38+
step: start
39+
token: ${{ secrets.GITHUB_TOKEN }}
40+
env: ${{ env.ENV }}
41+
- name: Login to Docker
42+
id: docker-login
43+
run: |
44+
echo "env is $ENV"
45+
inv $ENV aws.docker-login
46+
- name: Build, tag, push, and deploy image
47+
id: build-tag-push-deploy
48+
run: |
49+
echo "env is $ENV"
50+
inv $ENV image deploy --verbosity=0
51+
- name: Update deployment status
52+
uses: bobheadxi/deployments@v1
53+
if: always()
54+
with:
55+
step: finish
56+
token: ${{ secrets.GITHUB_TOKEN }}
57+
status: ${{ job.status }}
58+
env: ${{ env.ENV }}
59+
env_url: ${{ env.ENV_URL }}
60+
deployment_id: ${{ steps.deployment.outputs.deployment_id }}

.github/workflows/test.yaml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: test
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main, develop, actions-cd]
7+
8+
jobs:
9+
tests:
10+
runs-on: ubuntu-latest
11+
services:
12+
postgres:
13+
# From:
14+
# https://docs.github.com/en/actions/guides/creating-postgresql-service-containers
15+
image: postgres
16+
env:
17+
POSTGRES_PASSWORD: postgres
18+
POSTGRES_DB: traffic_stops
19+
# Set health checks to wait until postgres has started
20+
options: >-
21+
--health-cmd pg_isready
22+
--health-interval 10s
23+
--health-timeout 5s
24+
--health-retries 5
25+
ports:
26+
- 5432:5432
27+
steps:
28+
- uses: actions/checkout@v2
29+
- uses: actions/setup-python@v2
30+
with:
31+
python-version: '3.9'
32+
cache: 'pip'
33+
cache-dependency-path: 'requirements/*/*.txt'
34+
- name: Install dependencies
35+
run: |
36+
sudo apt update
37+
sudo apt install -y --no-install-recommends postgresql-client-12
38+
python -m pip install pip-tools
39+
pip-sync requirements/base/base.txt requirements/test/test.txt
40+
- name: Create NC database
41+
run: |
42+
psql $DATABASE_URL -c 'CREATE DATABASE traffic_stops_nc;'
43+
env:
44+
DATABASE_URL: postgres://postgres:postgres@localhost:5432/traffic_stops
45+
- name: Run tests
46+
run: |
47+
pytest
48+
env:
49+
DJANGO_SETTINGS_MODULE: traffic_stops.settings.dev
50+
DATABASE_URL: postgres://postgres:postgres@localhost:5432/traffic_stops
51+
DATABASE_URL_NC: postgres://postgres:postgres@localhost:5432/traffic_stops_nc

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 19.10b0
3+
rev: 22.3.0
44
hooks:
55
- id: black
66
language_version: python3.8

README.rst

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
NC CopWatch
22
================
33

4-
.. image:: https://circleci.com/gh/caktus/Traffic-Stops.svg?style=svg
5-
:target: https://circleci.com/gh/caktus/Traffic-Stops
6-
74
NC CopWatch is a website to monitor and identify racial profiling
85
practices by North Carolina law enforcement agencies. This project is lead by
96
`Forward Justice`_, a nonpartisan law, policy, and strategy center dedicated to advancing racial,

deploy/group_vars/all.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ k8s_papertrail_logspout_destination: "syslog+tls://logs2.papertrailapp.com:20851
9393
k8s_papertrail_logspout_memory_limit: 128Mi
9494

9595
# New Relic Infrastructure: admin+newrelic@caktusgroup.com
96-
k8s_newrelic_chart_version: "3.2.4"
96+
k8s_newrelic_chart_version: "3.5.1"
9797
k8s_newrelic_license_key: !vault |
9898
$ANSIBLE_VAULT;1.1;AES256
9999
37656631623333346263383231386165666531333961373931383661366338343634333362356430

deploy/group_vars/k8s.yml

+51-7
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,16 @@ k8s_migration_command:
3939
- migrate_all_dbs.sh
4040
k8s_collectstatic_enabled: false
4141

42+
# Auxillary pod configuration:
43+
k8s_worker_enabled: true
44+
k8s_worker_replicas: 1
45+
k8s_worker_celery_app: "traffic_stops"
46+
k8s_worker_beat_enabled: true
47+
k8s_memcached_enabled: false
48+
k8s_redis_enabled: true
49+
4250
# Shared environment variables:
51+
env_django_debug: false
4352
env_database_url: "postgres://{{ app_name }}_{{ env_name }}:{{ database_password }}@{{ DatabaseAddress }}:5432/{{ app_name }}_{{ env_name }}"
4453
env_database_url_nc: "postgres://{{ app_name }}_{{ env_name }}:{{ database_password }}@{{ DatabaseAddress }}:5432/{{ app_name }}_{{ env_name }}_nc"
4554
env_django_settings: "traffic_stops.settings.deploy"
@@ -83,13 +92,48 @@ env_email_host_password: !vault |
8392
3232353563333332396133636565626662366332356638303166
8493
env_email_use_tls: "true"
8594

86-
# Auxillary pod configuration:
87-
k8s_worker_enabled: true
88-
k8s_worker_replicas: 1
89-
k8s_worker_celery_app: "traffic_stops"
90-
k8s_worker_beat_enabled: true
91-
k8s_memcached_enabled: false
92-
k8s_redis_enabled: true
95+
k8s_environment_variables:
96+
DJANGO_DEBUG: "{{ env_django_debug | string | title | string }}"
97+
DATABASE_URL: "{{ env_database_url }}"
98+
DATABASE_URL_NC: "{{ env_database_url_nc }}"
99+
DJANGO_SETTINGS_MODULE: "{{ env_django_settings }}"
100+
# DOMAIN is the ALLOWED_HOST
101+
DOMAIN: "{{ k8s_domain_names[0] }}"
102+
ALLOWED_HOSTS: "{{ k8s_domain_names[0] }}"
103+
ENVIRONMENT: "{{ env_name }}"
104+
CACHE_HOST: "{{ env_cache_host }}"
105+
BROKER_URL: "{{ env_broker_url }}"
106+
# *** Uploaded media
107+
DEFAULT_FILE_STORAGE: "{{ env_default_file_storage }}"
108+
MEDIA_STORAGE_BUCKET_NAME: "{{ env_media_storage_bucket_name }}"
109+
AWS_DEFAULT_ACL: "{{ env_aws_default_acl }}"
110+
AWS_DEFAULT_REGION: "{{ aws_region }}"
111+
MEDIA_LOCATION: "{{ env_media_location }}"
112+
# *** Email
113+
# 'ses-smtp-user.20200921-084510' user in traffic-stops account
114+
EMAIL_HOST: "{{ env_email_host }}"
115+
EMAIL_HOST_USER: "{{ env_email_host_user }}"
116+
EMAIL_HOST_PASSWORD: "{{ env_email_host_password }}"
117+
EMAIL_USE_TLS: "{{ env_email_use_tls }}"
118+
# *** New Relic APM
119+
NEW_RELIC_APP_NAME: "{{ env_new_relic_app_name }}"
120+
NEW_RELIC_LICENSE_KEY: "{{ env_new_relic_license_key }}"
121+
SENTRY_DSN: "{{ env_sentry_dsn }}"
122+
DJANGO_SECRET_KEY: !vault |
123+
$ANSIBLE_VAULT;1.1;AES256
124+
35313432353232386662373534636239333765663936643639363266323337333936656462373962
125+
3766616464653266613234303331663934386462313238370a646532663834356266333765623763
126+
63633165383834303864613362623364653165623135323138346234313031393461653033306233
127+
3861323666306530640a346233653332356235623036653865383235626636623764613038653331
128+
61343666356364623132323230626430616261313463366462643632346132313331316561633764
129+
37646461333661316261363930626239643633323333633930636232616231326530656233396164
130+
613035323630616135653866373062303966
131+
# ** FTP_ACCESS
132+
NC_FTP_HOST: "{{ env_nc_ftp_host }}"
133+
NC_FTP_USER: "{{ env_nc_ftp_user }}"
134+
NC_FTP_PASSWORD: "{{ env_nc_ftp_password }}"
135+
# Contact form
136+
CONTACT_US_EMAILS: "{{ env_contact_us_emails|join(':') }}"
93137

94138
# S3 bucket configuration:
95139
k8s_s3_region: "{{ aws_region }}"

deploy/host_vars/production.yml

+22-50
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,28 @@ k8s_ingress_tls_domains_extra:
99
# - nccopwatch.com
1010
# - www.nccopwatch.com
1111

12+
env_contact_us_emails:
13+
- wcarpenter@forwardjustice.org
14+
15+
database_password: !vault |
16+
$ANSIBLE_VAULT;1.1;AES256
17+
31303862343062663437326263393631366262363939333135623034333633386233616431643866
18+
6564313439393663386438656334653430316365363462390a383834386462636664663861656536
19+
39333463653932393665333038353735303735366230623539613734393637633063336534633130
20+
3634653137623430320a373235636435363338353833636261613538386436643539323232373131
21+
36373833353534643936383734646537656238623839373161316139373132373332
22+
23+
# pwgen -s 64 1|tr -d '\n'|ansible-vault encrypt_string
24+
env_django_secret_key: !vault |
25+
$ANSIBLE_VAULT;1.1;AES256
26+
35313432353232386662373534636239333765663936643639363266323337333936656462373962
27+
3766616464653266613234303331663934386462313238370a646532663834356266333765623763
28+
63633165383834303864613362623364653165623135323138346234313031393461653033306233
29+
3861323666306530640a346233653332356235623036653865383235626636623764613038653331
30+
61343666356364623132323230626430616261313463366462643632346132313331316561633764
31+
37646461333661316261363930626239643633323333633930636232616231326530656233396164
32+
613035323630616135653866373062303966
33+
1234
k8s_auth_api_key: !vault |
1335
$ANSIBLE_VAULT;1.1;AES256
1436
63656266376132353139656233643430353262323431616436326435666333633664353533353261
@@ -65,56 +87,6 @@ k8s_auth_api_key: !vault |
6587
38323164663832643565653430326466663132626334303932313333313331343634666634383936
6688
3730
6789
68-
database_password: !vault |
69-
$ANSIBLE_VAULT;1.1;AES256
70-
31303862343062663437326263393631366262363939333135623034333633386233616431643866
71-
6564313439393663386438656334653430316365363462390a383834386462636664663861656536
72-
39333463653932393665333038353735303735366230623539613734393637633063336534633130
73-
3634653137623430320a373235636435363338353833636261613538386436643539323232373131
74-
36373833353534643936383734646537656238623839373161316139373132373332
75-
76-
k8s_environment_variables:
77-
DATABASE_URL: "{{ env_database_url }}"
78-
DATABASE_URL_NC: "{{ env_database_url_nc }}"
79-
DJANGO_SETTINGS_MODULE: "{{ env_django_settings }}"
80-
DJANGO_DEBUG: "False"
81-
# DOMAIN is the ALLOWED_HOST
82-
DOMAIN: "{{ k8s_domain_names[0] }}"
83-
ALLOWED_HOSTS: "{{ k8s_domain_names[0] }}"
84-
ENVIRONMENT: "{{ env_name }}"
85-
CACHE_HOST: "{{ env_cache_host }}"
86-
BROKER_URL: "{{ env_broker_url }}"
87-
# *** Uploaded media
88-
DEFAULT_FILE_STORAGE: "{{ env_default_file_storage }}"
89-
MEDIA_STORAGE_BUCKET_NAME: "{{ env_media_storage_bucket_name }}"
90-
AWS_DEFAULT_ACL: "{{ env_aws_default_acl }}"
91-
AWS_DEFAULT_REGION: "{{ aws_region }}"
92-
MEDIA_LOCATION: "{{ env_media_location }}"
93-
# *** Email
94-
# 'ses-smtp-user.20200921-084510' user in traffic-stops account
95-
EMAIL_HOST: "{{ env_email_host }}"
96-
EMAIL_HOST_USER: "{{ env_email_host_user }}"
97-
EMAIL_HOST_PASSWORD: "{{ env_email_host_password }}"
98-
EMAIL_USE_TLS: "{{ env_email_use_tls }}"
99-
# *** New Relic APM
100-
NEW_RELIC_APP_NAME: "{{ env_new_relic_app_name }}"
101-
NEW_RELIC_LICENSE_KEY: "{{ env_new_relic_license_key }}"
102-
SENTRY_DSN: "{{ env_sentry_dsn }}"
103-
DJANGO_SECRET_KEY: !vault |
104-
$ANSIBLE_VAULT;1.1;AES256
105-
35313432353232386662373534636239333765663936643639363266323337333936656462373962
106-
3766616464653266613234303331663934386462313238370a646532663834356266333765623763
107-
63633165383834303864613362623364653165623135323138346234313031393461653033306233
108-
3861323666306530640a346233653332356235623036653865383235626636623764613038653331
109-
61343666356364623132323230626430616261313463366462643632346132313331316561633764
110-
37646461333661316261363930626239643633323333633930636232616231326530656233396164
111-
613035323630616135653866373062303966
112-
# ** FTP_ACCESS
113-
NC_FTP_HOST: "{{ env_nc_ftp_host }}"
114-
NC_FTP_USER: "{{ env_nc_ftp_user }}"
115-
NC_FTP_PASSWORD: "{{ env_nc_ftp_password }}"
116-
117-
11890
# ** TS_BACKUPS
11991
k8s_hosting_services_project_name: "{{ app_name }}"
12092
k8s_hosting_services_aws_secret_access_key: !vault |

0 commit comments

Comments
 (0)