feat: Add Docker support with Dockerfile and entrypoint script.
This commit is contained in:
@@ -202,7 +202,7 @@ case "$1" in
|
||||
run_migrations
|
||||
create_platform_admin
|
||||
echo "Starting Gunicorn..."
|
||||
exec gunicorn myproject.wsgi:application \
|
||||
exec gosu appuser gunicorn myproject.wsgi:application \
|
||||
--bind 0.0.0.0:8000 \
|
||||
--workers 3 \
|
||||
--threads 2 \
|
||||
@@ -216,7 +216,7 @@ case "$1" in
|
||||
wait_for_redis
|
||||
setup_directories
|
||||
echo "Starting Celery Worker for photo processing and product import..."
|
||||
exec celery -A myproject worker \
|
||||
exec gosu appuser celery -A myproject worker \
|
||||
-l info \
|
||||
--concurrency=4
|
||||
;;
|
||||
@@ -224,18 +224,28 @@ case "$1" in
|
||||
wait_for_postgres
|
||||
wait_for_redis
|
||||
echo "Starting Celery Beat..."
|
||||
exec celery -A myproject beat -l info
|
||||
exec gosu appuser celery -A myproject beat -l info
|
||||
;;
|
||||
migrate)
|
||||
wait_for_postgres
|
||||
run_migrations
|
||||
# Миграции тоже запускаем от gosu
|
||||
gosu appuser python manage.py migrate_schemas --shared
|
||||
gosu appuser python manage.py migrate_schemas --tenant
|
||||
gosu appuser python manage.py collectstatic --noinput
|
||||
|
||||
# Права уже выставлены setup_directories (который запускается перед этим в case web/celery,
|
||||
# но для migrate мы можем вызвать его явно или просто поправить права на статику)
|
||||
# В данном блоке setup_directories не вызывался в оригинальном скрипте, но лучше вызвать если хотим гарантий
|
||||
# setup_directories
|
||||
|
||||
# Для migrate обычно важно просто создать схемы.
|
||||
create_platform_admin
|
||||
;;
|
||||
collectstatic)
|
||||
wait_for_postgres
|
||||
setup_directories
|
||||
echo "Collecting static files..."
|
||||
python manage.py collectstatic --noinput
|
||||
gosu appuser python manage.py collectstatic --noinput
|
||||
echo "Setting permissions on static files..."
|
||||
STATIC_ROOT="/app/myproject/staticfiles"
|
||||
find "$STATIC_ROOT" -type d -exec chmod 755 {} \; 2>/dev/null || true
|
||||
@@ -243,7 +253,7 @@ case "$1" in
|
||||
echo "Static files collected and permissions set."
|
||||
;;
|
||||
shell)
|
||||
exec python manage.py shell
|
||||
exec gosu appuser python manage.py shell
|
||||
;;
|
||||
*)
|
||||
exec "$@"
|
||||
|
||||
Reference in New Issue
Block a user