diff --git a/CHANGELOG-nightly.md b/CHANGELOG-nightly.md index 4ae842e..16bb0ff 100644 --- a/CHANGELOG-nightly.md +++ b/CHANGELOG-nightly.md @@ -2,6 +2,7 @@ Note: Breaking changes between versions are indicated by "💥". +- [Bugfix] Make it possible for plugins to implement the "caddyfile" patch without relying on the "port" local variable. - 💥[Improvement] Move the Open edX forum to a [dedicated plugin](https://github.com/overhangio/tutor-forum/) (#450). - 💥[Improvement] Get rid of the "tutor-openedx" package, which is no longer supported. - [Bugfix] Fix running Caddy container in k8s, which should always be the case even if `ENABLE_WEB_PROXY` is false. diff --git a/tutor/templates/apps/caddy/Caddyfile b/tutor/templates/apps/caddy/Caddyfile index b8c22ae..ae92508 100644 --- a/tutor/templates/apps/caddy/Caddyfile +++ b/tutor/templates/apps/caddy/Caddyfile @@ -25,14 +25,7 @@ } } -{% if ENABLE_HTTPS and ENABLE_WEB_PROXY %} -{% set port = "" %} -{# listening to https is disabled and we must only listen to http #} -{% else %} -{% set port = ":80" %} -{% endif %} - -{{ LMS_HOST }}{{ port }}, {{ PREVIEW_LMS_HOST }}{{ port }} { +{{ LMS_HOST }}{$default_site_port}, {{ PREVIEW_LMS_HOST }}{$default_site_port} { @favicon_matcher { path_regexp ^(.*)/favicon.ico$ } @@ -51,7 +44,7 @@ {{ patch("caddyfile-lms")|indent(4) }} } -{{ CMS_HOST }}{{ port }} { +{{ CMS_HOST }}{$default_site_port} { @favicon_matcher { path_regexp ^(.*)/favicon.ico$ } diff --git a/tutor/templates/k8s/deployments.yml b/tutor/templates/k8s/deployments.yml index 3841d78..0694c21 100644 --- a/tutor/templates/k8s/deployments.yml +++ b/tutor/templates/k8s/deployments.yml @@ -17,6 +17,9 @@ spec: containers: - name: caddy image: {{ DOCKER_IMAGE_CADDY }} + env: + - name: default_site_port + value: "{% if not ENABLE_HTTPS or not ENABLE_WEB_PROXY %}:80{% endif %}" volumeMounts: - mountPath: /etc/caddy/ name: config diff --git a/tutor/templates/local/docker-compose.prod.yml b/tutor/templates/local/docker-compose.prod.yml index 5f670e1..b753bfa 100644 --- a/tutor/templates/local/docker-compose.prod.yml +++ b/tutor/templates/local/docker-compose.prod.yml @@ -7,6 +7,8 @@ services: ports: - "{{ CADDY_HTTP_PORT }}:80" {% if ENABLE_HTTPS and ENABLE_WEB_PROXY %}- "443:443"{% endif %} + environment: + default_site_port: "{% if not ENABLE_HTTPS or not ENABLE_WEB_PROXY %}:80{% endif %}" volumes: - ../apps/caddy/Caddyfile:/etc/caddy/Caddyfile:ro {% if ENABLE_HTTPS and ENABLE_WEB_PROXY %}- ../../data/caddy:/data{% endif %}