Skip to content

Commit 16db0a2

Browse files
authored
Merge pull request #227 from pirogramming/develop
[Fix] 배포 환경 수정
2 parents dedf05a + 58cb0ff commit 16db0a2

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,10 @@ COPY . .
3535
# 정적파일 및 미디어 디렉토리 생성
3636
RUN mkdir -p /app/staticfiles /app/media
3737

38+
# entrypoint 스크립트 복사 및 실행 권한 부여
39+
COPY entrypoint.sh /entrypoint.sh
40+
RUN chmod +x /entrypoint.sh
41+
3842
EXPOSE 8000
43+
ENTRYPOINT ["/entrypoint.sh"]
3944
CMD ["gunicorn", "config.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "2", "--timeout", "120", "--max-requests", "1000", "--max-requests-jitter", "50"]

entrypoint.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "🔄 Starting entrypoint script..."
5+
6+
echo "📦 Collecting static files..."
7+
python manage.py collectstatic --noinput
8+
9+
echo "🗄️ Running database migrations..."
10+
python manage.py migrate --noinput
11+
12+
echo "👥 Creating superuser if not exists..."
13+
python manage.py shell <<EOF
14+
from django.contrib.auth.models import User
15+
import os
16+
if not User.objects.filter(is_superuser=True).exists():
17+
User.objects.create_superuser(
18+
username=os.getenv('DJANGO_SUPERUSER_USERNAME', 'admin'),
19+
email=os.getenv('DJANGO_SUPERUSER_EMAIL', 'admin@example.com'),
20+
password=os.getenv('DJANGO_SUPERUSER_PASSWORD', 'admin')
21+
)
22+
print("✅ Superuser created")
23+
else:
24+
print("ℹ️ Superuser already exists")
25+
EOF
26+
27+
echo "🚀 Starting application..."
28+
exec "$@"

0 commit comments

Comments
 (0)