diff --git a/.env.example b/.env.example index 2ad29defc..8fc027198 100644 --- a/.env.example +++ b/.env.example @@ -2,6 +2,8 @@ # Copy this to `.env` and adapt to your needs. # Which docker-compose to load (ON PRODUCTION, USE ONLY docker-compose.yml !!) +# If you need to connect to thumbor image service, simply use: +# COMPOSE_FILE=docker-compose.yml:docker-compose.thumbor.yml COMPOSE_FILE=docker-compose.yml:docker-compose.dev.yml COMPOSE_PATH_SEPARATOR=: @@ -93,6 +95,7 @@ LOCAL_TIME_ZONE_UTC=+1 SITE_DOMAIN=None # Use thumbor service to resize images (used by Agenda module) USE_THUMBOR=false -# Geocity network in order to communicate with other docker services on same host -# This has to be unique for multiple instance on same docker host -GEOCITY_NETWORK_NAME=geocity_network_dev +# URL of the thumbor service to use +# For dockerized thumbor service not exposed over the Internet, attache Geocity to its network with this override on top of this file: +# COMPOSE_FILE=docker-compose.yml:docker-compose.thumbor.yml +THUMBOR_SERVICE_URL="http://nginx-proxy" diff --git a/docker-compose.thumbor.yml b/docker-compose.thumbor.yml new file mode 100644 index 000000000..5bd58558e --- /dev/null +++ b/docker-compose.thumbor.yml @@ -0,0 +1,13 @@ +# Simple override in order to setup network for using thumbor image service +volumes: + static_root: + +services: + web: # Name of this container should not be changed + networks: + - thumbor_network +networks: + # Use this network to communicate with thumbor image resize service + # More information here: https://gitlab.com/geocity/thumbor-service + thumbor_network: + external: true diff --git a/docker-compose.yml b/docker-compose.yml index 2c1a20580..58cd0bbc2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -73,12 +73,13 @@ services: PAYMENT_CURRENCY: LOCAL_TIME_ZONE_UTC: SITE_DOMAIN: + USE_THUMBOR: + THUMBOR_SERVICE_URL: ports: - "${DJANGO_DOCKER_PORT}:9000" networks: - isolated - default - - geocity_network # Builder for the geocity_qgis image. qgis: @@ -114,6 +115,3 @@ networks: # Use this for containers that should only be able to communicate with Django isolated: name: ${ISOLATED_NETWORK_NAME} - geocity_network: - name: ${GEOCITY_NETWORK_NAME} - driver: bridge diff --git a/geocity/apps/api/views.py b/geocity/apps/api/views.py index 159f4aaf4..bc7cd4a25 100644 --- a/geocity/apps/api/views.py +++ b/geocity/apps/api/views.py @@ -3,7 +3,6 @@ import os import requests -from constance import config from django.conf import settings from django.contrib.auth.models import AnonymousUser, User from django.db.models import F, Prefetch, Q @@ -523,7 +522,7 @@ def image_thumbor_display(request, submission_id, image_name): if settings.USE_THUMBOR: try: response = requests.get( - f"{config.THUMBOR_SERVICE_URL}/{thumbor_params}/{image_url}" + f"{settings.THUMBOR_SERVICE_URL}/{thumbor_params}/{image_url}" ) except requests.exceptions.RequestException as e: response = requests.get(image_url) diff --git a/geocity/settings.py b/geocity/settings.py index 28cd904d5..98037b77a 100644 --- a/geocity/settings.py +++ b/geocity/settings.py @@ -117,8 +117,9 @@ # Allow REMOTE_USER Authentication ALLOW_REMOTE_USER_AUTH = os.getenv("ALLOW_REMOTE_USER_AUTH", "false").lower() == "true" -# IBAN for UserProfile model -USE_THUMBOR = os.getenv("USE_THUMBOR", "false").lower() == "true" +# Thumbor image service +USE_THUMBOR = os.getenv("USE_THUMBOR", "true").lower() == "true" +THUMBOR_SERVICE_URL = os.getenv("THUMBOR_SERVICE_URL", "None") SITE_HTTPS = ENV == "PROD" @@ -271,7 +272,6 @@ "IP_WHITELIST", "NETWORK_WHITELIST", "LOGOUT_REDIRECT_HOSTNAME_WHITELIST", - "THUMBOR_SERVICE_URL", ), } @@ -417,11 +417,6 @@ "localhost,geocity.ch", "Domaines autorisés à la redirection après logout", ), - "THUMBOR_SERVICE_URL": ( - "http://nginx-proxy", - "URL du service thumbor (https://github.com/thumbor/thumbor), recommandé pour l'optimisation des images du module Agenda", - str, - ), } TEMPLATES = [