반응형
1. docker-compose.yml 파일 수정하기
web:
build: .
command: gunicorn do_it.wsgi:application --bind 0.0.0.0:8000
2. gunicorn 설치 및 requirements.txt 파일 갱신
$ pip install gunicorn
Collecting gunicorn
Downloading gunicorn-20.1.0-py3-none-any.whl (79 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.5/79.5 KB 2.5 MB/s eta 0:00:00
Requirement already satisfied: setuptools>=3.0 in ./venv/lib/python3.8/site-packages (from gunicorn) (57.0.0)
Installing collected packages: gunicorn
Successfully installed gunicorn-20.1.0
$ pip freeze > requirements.txt
3. docker 이미지 생성 및 컨테이너 실행
docker-compose up --build
4. settings.py에 static 부분 추가하기
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, '_static')
5. urls.py에 STATIC_ROOT 추가하기
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
6. 정적파일 수집하기
$ python manage.py collectstatic
147 static files copied to '***/doit/_static'.
반응형
'기타-프로그래밍' 카테고리의 다른 글
docker 컨테이너 내리기 (0) | 2022.03.07 |
---|---|
docker compose에서 특정 파일로 실행 시키기 (0) | 2022.03.06 |
PostgreSQL Docker 적용하기 (0) | 2022.03.06 |
Django venv를 Docker로 옮기기 (0) | 2022.03.05 |
Bootstrap 시작하기 (0) | 2022.02.08 |