1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-19 12:59:36 +02:00

refactor docker startup to use supervisord

This commit is contained in:
ClumsyAdmin 2025-03-21 12:02:23 -04:00
parent dbd417ca87
commit 4ccfa6e42c
4 changed files with 22 additions and 6 deletions

View file

@ -12,7 +12,7 @@ WORKDIR /code
# Install system dependencies (Nginx included) # Install system dependencies (Nginx included)
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y git postgresql-client gdal-bin libgdal-dev nginx \ && apt-get install -y git postgresql-client gdal-bin libgdal-dev nginx supervisor \
&& apt-get clean \ && apt-get clean \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
@ -31,6 +31,9 @@ COPY ./server /code/
# Copy Nginx configuration # Copy Nginx configuration
COPY ./nginx.conf /etc/nginx/nginx.conf COPY ./nginx.conf /etc/nginx/nginx.conf
# Copy Supervisor configuration
COPY ./supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Collect static files # Collect static files
RUN python3 manage.py collectstatic --noinput --verbosity 2 RUN python3 manage.py collectstatic --noinput --verbosity 2
@ -41,5 +44,5 @@ RUN chmod +x /code/entrypoint.sh
# Expose ports for NGINX and Gunicorn # Expose ports for NGINX and Gunicorn
EXPOSE 80 8000 EXPOSE 80 8000
# Command to start Nginx and Gunicorn # Command to start Supervisor (which starts Nginx and Gunicorn)
CMD ["bash", "-c", "service nginx start && /code/entrypoint.sh"] CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

View file

@ -62,5 +62,8 @@ fi
cat /code/adventurelog.txt cat /code/adventurelog.txt
# Start gunicorn # Start Gunicorn in foreground
gunicorn main.wsgi:application --bind [::]:8000 --timeout 120 --workers 2 exec gunicorn main.wsgi:application \
--bind 0.0.0.0:8000 \
--workers 4 \
--timeout 120

10
backend/supervisord.conf Normal file
View file

@ -0,0 +1,10 @@
[supervisord]
nodaemon=true
[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
autorestart=true
[program:gunicorn]
command=/code/entrypoint.sh
autorestart=true

View file

@ -2,4 +2,4 @@
echo "The origin to be set is: $ORIGIN" echo "The origin to be set is: $ORIGIN"
# Start the application # Start the application
ORIGIN=$ORIGIN node build ORIGIN=$ORIGIN exec node build