feat: Host an internal proxy to get around CORs issues

This commit is contained in:
jamesread 2024-09-22 13:49:56 +01:00
parent 3b9d951ed5
commit bcaade98f9
4 changed files with 28 additions and 3 deletions

View File

@ -14,17 +14,20 @@ ENV NPM_CONFIG_UPDATE_NOTIFIER=false
ENV NEXT_TELEMETRY_DISABLED=1
RUN apk add --no-cache \
caddy \
bash=5.2.21-r0 \
supervisor=4.2.5-r4
WORKDIR /app
EXPOSE 4200
EXPOSE 3000
EXPOSE 4200
EXPOSE 5000
COPY var/docker/entrypoint.sh /app/entrypoint.sh
COPY var/docker/supervisord.conf /etc/supervisord.conf
COPY var/docker/supervisord /app/supervisord_available_configs/
COPY var/docker/Caddyfile /app/Caddyfile
COPY .env.example /config/postiz.env
VOLUME /config

9
var/docker/Caddyfile Normal file
View File

@ -0,0 +1,9 @@
:5000/ {
handle_path /api/* {
reverse_proxy * localhost:3000
}
handle {
reverse_proxy * localhost:4200
}
}

View File

@ -5,13 +5,18 @@ set -o xtrace
if [[ "$SKIP_CONFIG_CHECK" != "true" ]]; then
echo "Entrypoint: Copying /config/postiz.env into /app/.env"
if [ ! -f /config/.env ]; then
echo "Entrypoint: WARNING: No .env file found in /config/postiz.env"
if [ ! -f /config/postiz.env ]; then
echo "Entrypoint: WARNING: No postiz.env file found in /config/postiz.env"
fi
cp -vf /config/postiz.env /app/.env
fi
if [[ "$INTERNAL_PROXY_ENABLED" != "false" ]]; then
echo "Entrypoint: Starting internal proxy"
cp -vf /app/supervisord_available_configs/caddy.conf /etc/supervisor.d/
fi
if [[ "$POSTIZ_APPS" -eq "" ]]; then
echo "Entrypoint: POSTIZ_APPS is not set, starting everything!"
POSTIZ_APPS="frontend workers cron backend"

View File

@ -0,0 +1,8 @@
[program:backend]
directory=/app
command=caddy run --config /app/Caddyfile
autostart=true
autorestart=false
redirect_stderr=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0