Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New host setup #78

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ start:
@echo "------------------------------------------------------------------"
@docker-compose -f docker-compose-production-ssl.yml up -d

dbrestore:
@echo
@echo "------------------------------------------------------------------"
@echo "Restore dump from /backups/latest-qgisfeed.dmp and /backups/latest-metabase.dmp in production mode"
@echo "------------------------------------------------------------------"
@docker-compose -f docker-compose-production-ssl.yml exec postgis su - postgres -c "pg_restore -c /backups/latest-qgisfeed.dmp -d qgisfeed"
@docker-compose -f docker-compose-production-ssl.yml exec postgis su - postgres -c "pg_restore -c /backups/latest-metabase.dmp -d metabase"

updatemigrations:
@echo
@echo "------------------------------------------------------------------"
Expand Down
24 changes: 14 additions & 10 deletions docker-compose-production-ssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3.7"
services:

postgis:
image: kartoza/postgis:11.0-2.5
image: kartoza/postgis:16-3.4
ports:
- "5432"
environment:
Expand All @@ -16,13 +16,15 @@ services:
max-size: "200k"
max-file: "10"
restart: always
healthcheck:
test: "POSTGRES_PASS=$${QGISFEED_DOCKER_DBPASSWORD} pg_isready -h 127.0.0.1 -U ${QGISFEED_DOCKER_DBUSER} -d ${QGISFEED_DOCKER_DBNAME}"
volumes:
- ${QGISFEED_DOCKER_SHARED_VOLUME}:/var/lib/postgresql
networks:
internal:

metabase:
image: metabase/metabase:v0.46.6.1
image: metabase/metabase:v0.49.0
hostname: metabase-secrets
volumes:
- /dev/urandom:/dev/random:ro
Expand All @@ -47,7 +49,7 @@ services:
qgisfeed:
# Note you cannot scale if you use container_name
container_name: qgisfeed
image: qgisfeed:production-1.3
image: qgisfeed:production
build:
context: .
dockerfile: Dockerfile.production
Expand All @@ -68,7 +70,7 @@ services:
- "8000"
volumes:
- ${QGISFEED_DOCKER_SHARED_VOLUME}:/shared-volume
- /home/web/qgis-feed:/code
- ../qgis-feed:/code
depends_on:
- postgis
logging:
Expand Down Expand Up @@ -118,15 +120,17 @@ services:
DUMPPREFIX: PG_QGIS_FEED
POSTGRES_DATABASE: ${QGISFEED_DOCKER_DBNAME}
POSTGRES_HOST: postgis
POSTGRES_PASSWORD: ${QGISFEED_DOCKER_DBPASSWORD}
POSTGRES_PASS: ${QGISFEED_DOCKER_DBPASSWORD}
POSTGRES_PORT: '5432'
POSTGRES_USER: ${QGISFEED_DOCKER_DBUSER}
volumes:
- /mnt/backups/:/backups
links:
- postgis:postgis
command:
- /start.sh
- ${QGISFEED_BACKUP_VOLUME}:/backups
restart: on-failure
depends_on:
postgis:
condition: service_healthy
networks:
internal:

networks:
internal:
Expand Down
27 changes: 19 additions & 8 deletions docker-compose-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ services:
max-size: "200k"
max-file: "10"
restart: always
healthcheck:
test: "POSTGRES_PASS=$${QGISFEED_DOCKER_DBPASSWORD} pg_isready -h 127.0.0.1 -U ${QGISFEED_DOCKER_DBUSER} -d ${QGISFEED_DOCKER_DBNAME}"
volumes:
- ${QGISFEED_DOCKER_SHARED_VOLUME}:/var/lib/postgresql
- ../qgis-feed:/code
- ${QGISFEED_BACKUP_VOLUME}:/backups
networks:
internal:

metabase:
image: metabase/metabase:v0.46.6.1
image: metabase/metabase:v0.49.0
hostname: metabase-secrets
volumes:
- /dev/urandom:/dev/random:ro
Expand All @@ -48,19 +50,28 @@ services:
qgisfeed:
# Note you cannot scale if you use container_name
container_name: qgisfeed
image: xpirix/qgisfeed:production-1.4
image: qgisfeed:production
build:
context: .
dockerfile: Dockerfile.production
environment:
- QGISFEED_DOCKER_DBNAME
- QGISFEED_DOCKER_DBUSER
- QGISFEED_DOCKER_DBPASSWORD
QGISFEED_DOCKER_DBNAME: ${QGISFEED_DOCKER_DBNAME}
QGISFEED_DOCKER_DBUSER: ${QGISFEED_DOCKER_DBUSER}
QGISFEED_DOCKER_DBPASSWORD: ${QGISFEED_DOCKER_DBPASSWORD}
QGIS_FEED_PROD_URL: ${QGIS_FEED_PROD_URL}
QGISFEED_FROM_EMAIL: ${QGISFEED_FROM_EMAIL:-automation}
EMAIL_BACKEND: ${EMAIL_BACKEND}
EMAIL_HOST: ${EMAIL_HOST}
EMAIL_PORT: ${EMAIL_PORT}
EMAIL_USE_TLS: ${EMAIL_USE_TLS}
EMAIL_HOST_USER: ${EMAIL_HOST_USER:-automation}
EMAIL_HOST_PASSWORD: ${EMAIL_HOST_PASSWORD}
command: /code/entrypoint_production.sh
expose:
- "8000"
volumes:
- ${QGISFEED_DOCKER_SHARED_VOLUME}:/shared-volume
- ../qgis-feed:/code
depends_on:
- postgis
logging:
Expand All @@ -75,7 +86,7 @@ services:
nginx:
image: nginx:latest
ports:
- "80:8000"
- "80:80"
logging:
driver: "json-file"
options:
Expand All @@ -98,7 +109,7 @@ services:
POSTGRES_PORT: '5432'
POSTGRES_USER: ${QGISFEED_DOCKER_DBUSER}
volumes:
- /mnt/backups/:/backups
- ${QGISFEED_BACKUP_VOLUME}:/backups
restart: on-failure
depends_on:
postgis:
Expand Down
3 changes: 3 additions & 0 deletions env.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# the user from the Docker containers.
QGISFEED_DOCKER_SHARED_VOLUME=/shared-volume

# Backup Volume
QGISFEED_BACKUP_VOLUME=/mnt/backups/

# Number of Gunicorn workers (usually: number of cores * 2 + 1)
QGISFEED_GUNICORN_WORKERS=4

Expand Down
4 changes: 4 additions & 0 deletions settings_docker_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@
# settings for enabling https forwarding
USE_X_FORWARDED_PORT = True
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")

QGIS_FEED_PROD_URL = os.environ.get('QGIS_FEED_PROD_URL', False)
CSRF_TRUSTED_ORIGINS = [p + QGIS_FEED_PROD_URL for p in ['http://', 'https://'] if QGIS_FEED_PROD_URL]
CORS_ORIGIN_WHITELIST = CSRF_TRUSTED_ORIGINS
Loading