diff --git a/Dockerfile b/Dockerfile index 46619784b..08d6d8468 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,9 @@ EXPOSE 3000 RUN mkdir -p /config +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 .env.example /config/.env VOLUME /config @@ -28,10 +31,7 @@ COPY nx.json tsconfig.base.json package.json package-lock.json /app/ COPY apps /app/apps/ COPY libraries /app/libraries/ -RUN npm ci --no-fund && npm run build - -COPY var/docker/entrypoint.sh /app/entrypoint.sh -COPY var/docker/supervisord/* /app/supervisord_configs/ +RUN npm ci --no-fund && npx nx run-many --target=build --projects=frontend,backend,workers,cron LABEL org.opencontainers.image.title="Postiz App (DevContainer)" diff --git a/var/docker/entrypoint.sh b/var/docker/entrypoint.sh index 609fa7d04..2e98950e4 100755 --- a/var/docker/entrypoint.sh +++ b/var/docker/entrypoint.sh @@ -1,36 +1,36 @@ #!/bin/bash -if [[ "$SKIP_CONFIG_CHECK" -ne "true" ]]; then +if [[ "$SKIP_CONFIG_CHECK" != "true" ]]; then + echo "symlinking /config/.env into /app/.env" + if [ ! -f /config/.env ]; then echo "ERROR: No .env file found in /config/.env" fi - ln -s /config/env /app/.env + ln -sf /config/.env /app/.env fi if [[ "$POSTIZ_APPS" -eq "" ]]; then echo "POSTIZ_APPS is not set, starting everything!" - POSTIZ_APPS="frontend workers cron" + POSTIZ_APPS="frontend workers cron backend" fi mkdir -p /etc/supervisor.d/ -cp /app/supervisord_configs/base.conf /etc/supervisor.d/ - if [[ "$POSTIZ_APPS" == *"frontend"* ]]; then - cp /app/supervisord_configs/frontend.conf /etc/supervisor.d/ + ln -sf /app/supervisord_available_configs/frontend.conf /etc/supervisor.d/ fi if [[ $POSTIZ_APPS == *"workers"* ]]; then - cp /app/supervisord_configs/workers.conf /etc/supervisor.d/ + ln -sf /app/supervisord_available_configs/workers.conf /etc/supervisor.d/ fi if [[ $POSTIZ_APPS == *"cron"* ]]; then - cp /app/supervisord_configs/cron.conf /etc/supervisor.d/ + ln -sf /app/supervisord_available_configs/cron.conf /etc/supervisor.d/ fi if [[ $POSTIZ_APPS == *"backend"* ]]; then - cp /app/supervisord_configs/backend.conf /etc/supervisor.d/ + ln -sf /app/supervisord_available_configs/backend.conf /etc/supervisor.d/ fi /usr/bin/supervisord diff --git a/var/docker/supervisord.conf b/var/docker/supervisord.conf new file mode 100644 index 000000000..c74f511b3 --- /dev/null +++ b/var/docker/supervisord.conf @@ -0,0 +1,10 @@ +[supervisord] +nodaemon=true +logfile=/dev/null +logfile_maxbytes=0 + +[unix_http_server] +file=/run/supervisord.sock + +[include] +files = /etc/supervisor.d/*.conf diff --git a/var/docker/supervisord/backend.ini b/var/docker/supervisord/backend.conf similarity index 56% rename from var/docker/supervisord/backend.ini rename to var/docker/supervisord/backend.conf index 8e56645cb..be803a93e 100644 --- a/var/docker/supervisord/backend.ini +++ b/var/docker/supervisord/backend.conf @@ -3,3 +3,6 @@ directory=/app command=npm run start:prod autostart=true autorestart=false +redirect_stderr=true +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 diff --git a/var/docker/supervisord/base.ini b/var/docker/supervisord/base.ini deleted file mode 100644 index b220a9839..000000000 --- a/var/docker/supervisord/base.ini +++ /dev/null @@ -1,6 +0,0 @@ -[supervisord] -nodaemon=true -logfile=/dev/null -logfile_maxbytes=0 - - diff --git a/var/docker/supervisord/cron.ini b/var/docker/supervisord/cron.conf similarity index 56% rename from var/docker/supervisord/cron.ini rename to var/docker/supervisord/cron.conf index ef22047a1..ab653f5aa 100644 --- a/var/docker/supervisord/cron.ini +++ b/var/docker/supervisord/cron.conf @@ -3,3 +3,6 @@ directory=/app command=npm run start:prod:cron autostart=true autorestart=false +redirect_stderr=true +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 diff --git a/var/docker/supervisord/frontend.ini b/var/docker/supervisord/frontend.conf similarity index 58% rename from var/docker/supervisord/frontend.ini rename to var/docker/supervisord/frontend.conf index 737aedd97..c157a2050 100644 --- a/var/docker/supervisord/frontend.ini +++ b/var/docker/supervisord/frontend.conf @@ -3,3 +3,6 @@ directory=/app command=npm run start:prod:frontend autostart=true autorestart=false +redirect_stderr=true +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 diff --git a/var/docker/supervisord/workers.ini b/var/docker/supervisord/workers.conf similarity index 58% rename from var/docker/supervisord/workers.ini rename to var/docker/supervisord/workers.conf index fd84a708e..5653ec8b6 100644 --- a/var/docker/supervisord/workers.ini +++ b/var/docker/supervisord/workers.conf @@ -3,3 +3,6 @@ directory=/app command=npm run start:prod:workers autostart=true autorestart=false +redirect_stderr=true +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0