Skip to content

Commit 2b9b689

Browse files
authored
Merge pull request #10 from Xpirix/pre-deployment-setup
Pre deployment setup
2 parents 0041c37 + 7a1a06e commit 2b9b689

File tree

17 files changed

+677
-36
lines changed

17 files changed

+677
-36
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ max-line-length = 79
55
# E12x continuation line indentation
66
# E251 no spaces around keyword / parameter equals
77
# E303 too many blank lines (3)
8-
ignore = E125,E126,E251,E303,W504,W60,F405,E501
8+
ignore = E125,E126,E251,E303,W504,W60,F405,E501,E111,E121

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ So as to create your admin account:
8181
make superuser
8282
```
8383

84+
To fix missing dates on releases, run:
85+
```
86+
make uwsgi-shell
87+
python manage.py update-versions-release-date
88+
# Exit the shell with CTRL+D
89+
```
90+
8491
**intercom.io**
8592

8693
If you wish to make use of [intercom.io](https://www.intercom.io), include a

deployment/.env.example

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,18 @@ VALID_DOMAIN=["localhost", "changelog.qgis.org", "staging.changelog.qgis.org"]
4949

5050
# Email
5151
EMAIL_BACKEND='django.core.mail.backends.smtp.EmailBackend'
52-
EMAIL_HOST=''
53-
EMAIL_PORT=25
52+
EMAIL_HOST='smtp.resend.com'
53+
EMAIL_PORT=465
5454
EMAIL_USE_TLS=True
55-
EMAIL_HOST_USER=''
56-
EMAIL_HOST_PASSWORD=''
57-
EMAIL_SUBJECT_PREFIX=''
55+
EMAIL_HOST_USER="resend" # e.g., no-reply@yourdomain.com
56+
EMAIL_HOST_PASSWORD="your_resend_api_key" # Your Resend API key
57+
EMAIL_SUBJECT_PREFIX='[QGIS Changelog]'
5858
MAILDOMAIN=''
5959
SERVER_EMAIL=''
6060
ADMIN_EMAIL=''
61-
DEFAULT_FROM_EMAIL=''
61+
DEFAULT_FROM_EMAIL='no-reply@yourdomain.com'
62+
# Resend email
63+
RESEND_EMAIL_API_KEY=''
6264

6365
# Stripe
6466
STRIPE_LIVE_SECRET_KEY='sk_live_key'
@@ -68,3 +70,9 @@ DJSTRIPE_WEBHOOK_SECRET='whsec_'
6870
# SENTRY
6971
SENTRY_DSN=''
7072
SENTRY_RATE=0.2
73+
74+
# Deployment environment: dev, staging, prod or prod-ssl
75+
WEB_ENV=prod-ssl
76+
77+
# UWSGI Docker Image
78+
UWSGI_DOCKER_IMAGE=qgis/qgis-changelog-uwsgi:latest

deployment/docker-compose.override.example.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ volumes:
77
type: none
88
device: ${PWD}/pg/postgres_data
99
o: bind
10-
db-backups:
11-
driver_opts:
12-
type: none
13-
device: ${PWD}/backups
14-
o: bind
1510
static-data:
1611
driver_opts:
1712
type: none
@@ -34,27 +29,30 @@ volumes:
3429
o: bind
3530
services:
3631
uwsgi:
32+
image: ${UWSGI_DOCKER_IMAGE}
3733
build:
3834
context: ${PWD}/../
3935
dockerfile: deployment/docker/Dockerfile
4036
target: prod
4137
volumes:
4238
- ../django_project:/home/web/django_project
39+
- ${MEDIA_VOLUME}:/home/web/media:rw
4340
- ./logs:/var/log
4441

4542
web:
4643
volumes:
4744
- ./logs:/var/log/nginx
45+
- ${MEDIA_VOLUME}:/home/web/media:ro
4846
ports:
49-
- "${HTTP_PORT}:8080"
47+
- "${HTTP_PORT}:80"
5048
- "${HTTPS_PORT}:443"
5149

5250
devweb:
53-
image: kartoza/project-uwsgi:dev-latest
5451
build:
5552
context: ${PWD}/../
5653
dockerfile: deployment/docker/Dockerfile
5754
target: dev
5855
volumes:
5956
- ../django_project:/home/web/django_project
57+
- ${MEDIA_VOLUME}:/home/web/media:rw
6058
- ./logs:/var/log

deployment/docker-compose.yml

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ volumes:
1414
reports-data:
1515
nginx-conf:
1616
services:
17-
# smtp:
18-
# image: catatnight/postfix
19-
# hostname: postfix
20-
# environment:
21-
# # You could change this to something more suitable
22-
# - maildomain=kartoza.com
23-
# - smtp_user=noreply:docker
24-
# restart: unless-stopped
2517

2618
db:
2719
image: kartoza/postgis:16-3.4
@@ -35,12 +27,17 @@ services:
3527
restart: unless-stopped
3628
ports:
3729
- "7543:5432"
30+
networks:
31+
internal:
3832

3933
uwsgi: &uwsgi-common
34+
image: ${UWSGI_DOCKER_IMAGE}
4035
build:
4136
context: ${PWD}/../
4237
dockerfile: deployment/docker/Dockerfile
4338
target: prod
39+
expose:
40+
- "8080"
4441
environment:
4542
- DATABASE_NAME=${DATABASE_NAME}
4643
- DATABASE_USERNAME=${DATABASE_USERNAME}
@@ -71,6 +68,7 @@ services:
7168
- static-data:/home/web/static:rw
7269
- media-data:/home/web/media:rw
7370
- reports-data:/home/web/reports
71+
- ./docker/uwsgi.conf:/uwsgi.conf
7472
command: bash -c "npm install && npm run build && uwsgi --ini /uwsgi.conf"
7573
links:
7674
- db:db
@@ -82,6 +80,8 @@ services:
8280
options:
8381
max-size: "10m"
8482
max-file: "10"
83+
networks:
84+
internal:
8585

8686
dbbackups:
8787
image: kartoza/pg-backup:16-3.4
@@ -102,14 +102,25 @@ services:
102102
- POSTGRES_HOST=${DATABASE_HOST}
103103
- PGDATABASE=${DATABASE_NAME}
104104
restart: unless-stopped
105+
networks:
106+
internal:
105107

106108
# This is normally the main entry point for a production server
107109
web:
108110
image: nginx
111+
entrypoint:
112+
- /etc/nginx/sites-available/docker-entrypoint.sh
113+
ports:
114+
- "80:80"
115+
- "443:443"
116+
command:
117+
- ${WEB_ENV}
109118
volumes:
110-
- nginx-conf:/etc/nginx/conf.d:ro
119+
- nginx-conf:/etc/nginx/sites-available/:ro
111120
- static-data:/home/web/static:ro
112121
- media-data:/home/web/media:ro
122+
- ./webroot:/var/www/webroot
123+
- ./certbot-etc:/etc/letsencrypt
113124
links:
114125
- uwsgi:uwsgi
115126
restart: unless-stopped
@@ -118,6 +129,8 @@ services:
118129
options:
119130
max-size: "10m"
120131
max-file: "10"
132+
networks:
133+
internal:
121134

122135
# This is the entry point for a development server.
123136
# Run with --no-deps to run attached to the services
@@ -130,6 +143,8 @@ services:
130143
target: dev
131144
ports:
132145
- "62202:8000"
146+
networks:
147+
internal:
133148

134149
webpack:
135150
build:
@@ -142,5 +157,21 @@ services:
142157
- ../django_project:/home/web/django_project
143158
- static-data:/home/web/static:rw
144159
- ${MEDIA_VOLUME}:/home/web/media:rw
160+
networks:
161+
internal:
162+
163+
certbot:
164+
image: certbot/certbot
165+
container_name: certbot
166+
volumes:
167+
- ./webroot:/var/www/webroot
168+
- ./certbot-etc:/etc/letsencrypt
169+
depends_on:
170+
- web
171+
command: certonly --webroot --webroot-path=/var/www/webroot --email admin@qgis.org --agree-tos --no-eff-email --force-renewal -d ${VIRTUAL_HOST:-changelog.qgis.org}
172+
networks:
173+
internal:
145174

146175

176+
networks:
177+
internal:

deployment/docker/REQUIREMENTS.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,7 @@ pyjwt~=2.8
5757
# New dependencies
5858
# Webpack
5959
django-webpack-loader~=3.1
60-
sorl-thumbnail~=12.11
60+
sorl-thumbnail~=12.11
61+
62+
# Resend email
63+
resend~=2.7

deployment/docker/uwsgi.conf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@ module = core.wsgi
77
master = true
88
pidfile=/tmp/django.pid
99
socket = 0.0.0.0:8080
10-
http-socket = 0.0.0.0:80
1110
workers = 4
1211
cheaper = 2
1312
env = DJANGO_SETTINGS_MODULE=core.settings.prod_docker
1413
# disabled so we run in the foreground for docker
1514
#daemonize = /tmp/django.log
1615
req-logger = file:/var/log/uwsgi-requests.log
1716
logger = file:/var/log/uwsgi-errors.log
18-
log
19-
reload-os-env
20-
#uid = 1000
21-
#gid = 1000
2217
memory-report = true
2318
harakiri = 100
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ server {
1616
error_log /var/log/nginx/error.log;
1717

1818
# the port your site will be served on
19-
listen 8080;
19+
listen 80;
2020
# the domain name it will serve for
2121
server_name "";
2222
charset utf-8;
@@ -84,5 +84,8 @@ server {
8484
uwsgi_param REMOTE_PORT $remote_port;
8585
uwsgi_param SERVER_PORT $server_port;
8686
uwsgi_param SERVER_NAME $server_name;
87+
88+
# Redirect changelog, sustaining members and certification to the new location
89+
include redirections.conf;
8790
}
8891
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
3+
# Clean up sites-enabled
4+
echo "Clean sites-enabled"
5+
rm -rf /etc/nginx/conf.d/*.conf
6+
mkdir -p /etc/nginx/conf.d
7+
8+
if [ $# -eq 1 ]; then
9+
case $1 in
10+
# Debug mode, enable dev.conf
11+
[Dd][Ee][Vv])
12+
echo "Run in debug mode"
13+
CONF_FILE=dev.conf
14+
ln -s /etc/nginx/sites-available/$CONF_FILE /etc/nginx/conf.d/$CONF_FILE
15+
ln -s /etc/nginx/sites-available/redirections.conf /etc/nginx/redirections.conf
16+
exec nginx -g "daemon off;"
17+
;;
18+
# Production mode, run using uwsgi
19+
[Pp][Rr][Oo][Dd])
20+
echo "Run in prod mode"
21+
CONF_FILE=prod.conf
22+
ln -s /etc/nginx/sites-available/$CONF_FILE /etc/nginx/conf.d/$CONF_FILE
23+
ln -s /etc/nginx/sites-available/redirections.conf /etc/nginx/redirections.conf
24+
exec nginx -g "daemon off;"
25+
;;
26+
# Production SSL mode, run using uwsgi
27+
[Pp][Rr][Oo][Dd][-][Ss][Ss][Ll])
28+
echo "Run in prod SSL mode"
29+
CONF_FILE=prod-ssl.conf
30+
ln -s /etc/nginx/sites-available/$CONF_FILE /etc/nginx/conf.d/$CONF_FILE
31+
ln -s /etc/nginx/sites-available/redirections.conf /etc/nginx/redirections.conf
32+
exec nginx -g "daemon off;"
33+
;;
34+
# Staging SSL mode, run using uwsgi
35+
[Ss][Tt][Aa][Gg][Ii][Nn][Gg])
36+
echo "Run in staging SSL mode"
37+
CONF_FILE=staging.conf
38+
ln -s /etc/nginx/sites-available/$CONF_FILE /etc/nginx/conf.d/$CONF_FILE
39+
ln -s /etc/nginx/sites-available/redirections.conf /etc/nginx/redirections.conf
40+
exec nginx -g "daemon off;"
41+
;;
42+
esac
43+
fi
44+
45+
# Run as bash entrypoint
46+
exec "$@"

0 commit comments

Comments
 (0)