Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #900 from yverdon/thumbor_variables
Browse files Browse the repository at this point in the history
Thumbor variables
  • Loading branch information
AlexandreJunod authored Dec 5, 2023
2 parents a35ca88 + c168c18 commit 096c2e5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
9 changes: 6 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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=:

Expand Down Expand Up @@ -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"
13 changes: 13 additions & 0 deletions docker-compose.thumbor.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 2 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
3 changes: 1 addition & 2 deletions geocity/apps/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 3 additions & 8 deletions geocity/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -271,7 +272,6 @@
"IP_WHITELIST",
"NETWORK_WHITELIST",
"LOGOUT_REDIRECT_HOSTNAME_WHITELIST",
"THUMBOR_SERVICE_URL",
),
}

Expand Down Expand Up @@ -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 = [
Expand Down

0 comments on commit 096c2e5

Please sign in to comment.