-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[story/EDROP-14] #15
[story/EDROP-14] #15
Changes from 1 commit
c9a6cc9
56bfb4a
dba1d29
e2f61cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM python:3.13 | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
WORKDIR /edrop | ||
|
||
RUN apt-get update && apt-get install -y supervisor && \ | ||
apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf | ||
COPY supervisor.service /etc/systemd/system/supervisor.service | ||
|
||
COPY edrop-gunicorn.sh /edrop/edrop-gunicorn.sh | ||
|
||
RUN ["chmod", "+x", "/edrop/edrop-gunicorn.sh"] | ||
|
||
ENTRYPOINT ["./edrop-gunicorn.sh"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. neither should this |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's create a separate docker compose file for production and leave this the way it was |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ version: "3.9" | |
|
||
services: | ||
db: | ||
image: postgres | ||
image: postgres:14 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. while we should have a postgres version here, let's use the latest (16 I believe) |
||
platform: linux/amd64 | ||
volumes: | ||
- ./data/db:/var/lib/postgresql/data | ||
|
@@ -13,7 +13,9 @@ services: | |
ports: | ||
- "5432:5432" | ||
web: | ||
build: . | ||
build: | ||
context: . | ||
dockerfile: Dockerfile-prod | ||
platform: linux/amd64 | ||
command: tail -f /dev/null | ||
volumes: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
NAME="edrop" # Name of the application | ||
DJANGODIR=/edrop # Django project directory | ||
NUM_WORKERS=3 # Number of Gunicorn workers | ||
DJANGO_SETTINGS_MODULE=edrop.settings # Django settings module | ||
DJANGO_WSGI_MODULE=edrop.wsgi # WSGI module name | ||
|
||
echo "Starting $NAME as `whoami`" | ||
|
||
# Activate the virtual environment | ||
cd $DJANGODIR | ||
source .env_app | ||
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE | ||
export PYTHONPATH=$DJANGODIR:$PYTHONPATH | ||
mkdir -p /edrop/logs | ||
python -m pip install -r requirements.txt | ||
python manage.py migrate | ||
python manage.py collectstatic --noinput | ||
service supervisor start | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should not be needed here (and would actually lead to an infinite loop of starting supervisor (or error out maybe), since this is the script that supervisor runs to start gunicorn. |
||
|
||
# Start your Django Unicorn | ||
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon) | ||
exec gunicorn ${DJANGO_WSGI_MODULE}:application \ | ||
--name $NAME \ | ||
--workers $NUM_WORKERS \ | ||
--bind=0.0.0.0:8000 \ | ||
--log-level=info \ | ||
--log-file=- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needs to log to files not stdout |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
django==5.1 | ||
gunicorn==22.0.0 | ||
psycopg2==2.9.10 | ||
dj-static==0.0.6 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# /etc/systemd/system/supervisor.service | ||
|
||
[Unit] | ||
Description=Supervisor | ||
After=syslog.target network.target | ||
|
||
[Service] | ||
ExecStart=/usr/bin/supervisord --configuration=/etc/supervisor/conf.d/supervisord.conf --logfile=./edrop/logs/edrop_supervisor.log | ||
ExecStop=/usr/bin/supervisorctl shutdown | ||
ExecReload=/usr/bin/supervisorctl reload all | ||
Restart=always | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[supervisord] | ||
nodaemon=true | ||
|
||
[program:edrop] | ||
command=/edrop/edrop-gunicorn.sh | ||
directory=/edrop | ||
autostart=true | ||
autorestart=true | ||
stdout_logfile=/edrop/logs/edrop_supervisor.log | ||
stderr_logfile=/edrop/logs/edrop_supervisor.log | ||
environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8 | ||
|
||
; Need to wait for currently executing tasks to finish at shutdown. | ||
; Increase this if you have very long running tasks. | ||
stopwaitsecs = 600 | ||
|
||
; When resorting to send SIGKILL to the program to terminate it | ||
; send SIGKILL to its whole process group instead, | ||
; taking care of its children as well. | ||
killasgroup=true | ||
|
||
; if rabbitmq is supervised, set its priority higher | ||
; so it starts first | ||
priority=998 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we want supervisor to manage gunicorn, so this should not be necessary. instead just make sure supervisor is running.