[#55776] create proxy without static assets (#83)

* [#55776] added custom image for proxy

- based on caddy:2
- copy assets from openproject image into proxy image

* [#55776] removed static asset serving from proxy

- https://community.openproject.org/wp/55776
- apparently caddy correctly redirects asset requests to the web service
This commit is contained in:
Eric Schubert
2024-07-16 11:46:15 +02:00
committed by GitHub
parent 9a9b458a2f
commit 6b10106a0f
5 changed files with 17 additions and 28 deletions

2
compose/.gitignore vendored
View File

@@ -1 +1,3 @@
.env
docker-compose.override.yml

View File

@@ -5,7 +5,6 @@ networks:
volumes:
pgdata:
opdata:
assets:
x-op-restart-policy: &restart_policy
restart: unless-stopped
@@ -25,6 +24,8 @@ x-op-app: &app
RAILS_MAX_THREADS: ${RAILS_MAX_THREADS:-16}
# set to true to enable the email receiving feature. See ./docker/cron for more options
IMAP_ENABLED: "${IMAP_ENABLED:-false}"
volumes:
- "${OPDATA:-opdata}:/var/openproject/assets"
services:
db:
@@ -46,21 +47,18 @@ services:
- backend
proxy:
image: caddy:2
build:
context: ./proxy
args:
APP_HOST: web
image: openproject/proxy:${TAG:-14-slim}
<<: *restart_policy
command: "/usr/local/bin/proxy-entrypoint.sh"
ports:
- "${PORT:-8080}:80"
environment:
APP_HOST: web
depends_on:
- web
networks:
- frontend
volumes:
- ./Caddyfile.template:/etc/caddy/Caddyfile.template:ro
- ./proxy-entrypoint.sh:/usr/local/bin/proxy-entrypoint.sh:ro
- assets:/public:ro
web:
<<: *app
@@ -80,9 +78,6 @@ services:
timeout: 3s
retries: 3
start_period: 30s
volumes:
- "${OPDATA:-opdata}:/var/openproject/assets"
- assets:/app/public
autoheal:
image: willfarrell/autoheal:1.2.0
@@ -102,8 +97,6 @@ services:
- db
- cache
- seeder
volumes:
- "${OPDATA:-opdata}:/var/openproject/assets"
cron:
<<: *app
@@ -114,8 +107,6 @@ services:
- db
- cache
- seeder
volumes:
- "${OPDATA:-opdata}:/var/openproject/assets"
seeder:
<<: *app
@@ -123,6 +114,3 @@ services:
restart: on-failure
networks:
- backend
volumes:
- "${OPDATA:-opdata}:/var/openproject/assets"

View File

@@ -1,7 +0,0 @@
#!/bin/sh
set -e
sed 's|${APP_HOST}|'"$APP_HOST"'|g' /etc/caddy/Caddyfile.template > /etc/caddy/Caddyfile
caddy run --config /etc/caddy/Caddyfile

View File

@@ -1,6 +1,4 @@
:80 {
root * /public
reverse_proxy * http://${APP_HOST}:8080 {
# The following directives are needed to make the proxy forward explicitly the X-Forwarded-* headers. If unset,
# Caddy will reset them. See: https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#defaults

8
compose/proxy/Dockerfile Normal file
View File

@@ -0,0 +1,8 @@
FROM caddy:2
COPY ./Caddyfile.template /etc/caddy/Caddyfile.template
ARG APP_HOST
RUN sed 's|${APP_HOST}|'"$APP_HOST"'|g' /etc/caddy/Caddyfile.template > /etc/caddy/Caddyfile
ENTRYPOINT ["caddy", "run", "--config", "/etc/caddy/Caddyfile"]