mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-12-13 14:43:03 +00:00
fix: enable plugins to implement the "caddyfile" patch
When nginx was removed in favour of caddy, we decided that plugin implementations of the "caddyfile" patch should make use of the "port" local variable. However, local variables are not available from inside plugin patches, which are rendered outside of the context of the parent templates. For a more extensive description of the problem, see: https://github.com/overhangio/tutor-mfe/pull/23#issuecomment-964016190 We still want to make it easy for developers to decide what should the port be for caddy hosts. To do so, we make use of environment variables that are passed at runtime to the caddy container. Thus, a regular plugin patch should look like this: {{ PLUGIN_HOST }}{$default_site_port} { import proxy "myplugin:8000" }
This commit is contained in:
parent
f251cd7a3e
commit
72baae0e27
@ -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.
|
||||
|
@ -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$
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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 %}
|
||||
|
Loading…
Reference in New Issue
Block a user