本番デプロイ用設定ファイルを追加
- backend/Dockerfile.prod: gunicorn で起動する本番用 Dockerfile - frontend/Dockerfile.prod: マルチステージビルドの本番用 Dockerfile - docker-compose.prod.yml: Traefik 連携・本番用 compose 設定 - main.keinafarm.net でフロントエンド・バックエンドを公開 - /api/ はバックエンド(priority=10)、それ以外はフロントエンド(priority=5) - .env.production.example: 本番環境変数のサンプル - settings.py: ALLOWED_HOSTS・CORS_ALLOWED_ORIGINS を環境変数から設定可能に Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
31
backend/Dockerfile.prod
Normal file
31
backend/Dockerfile.prod
Normal file
@@ -0,0 +1,31 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
gcc \
|
||||
g++ \
|
||||
postgresql-client \
|
||||
libpq-dev \
|
||||
libgdal-dev \
|
||||
libgeos-dev \
|
||||
libproj-dev \
|
||||
fonts-noto-cjk \
|
||||
libgirepository1.0-dev \
|
||||
libcairo2 \
|
||||
libpango-1.0-0 \
|
||||
libpangocairo-1.0-0 \
|
||||
gir1.2-pango-1.0 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV CPLUS_INCLUDE_PATH=/usr/include/gdal
|
||||
ENV C_INCLUDE_PATH=/usr/include/gdal
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
CMD ["gunicorn", "keinasystem.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "2", "--timeout", "120"]
|
||||
@@ -20,7 +20,8 @@ SECRET_KEY = os.environ.get('SECRET_KEY', 'django-insecure-default-key')
|
||||
|
||||
DEBUG = os.environ.get('DEBUG', 'True') == 'True'
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
_allowed_hosts = os.environ.get('ALLOWED_HOSTS', '*')
|
||||
ALLOWED_HOSTS = [h.strip() for h in _allowed_hosts.split(',')]
|
||||
|
||||
|
||||
# Application definition
|
||||
@@ -145,12 +146,16 @@ SIMPLE_JWT = {
|
||||
'REFRESH_TOKEN_LIFETIME': timedelta(days=7),
|
||||
}
|
||||
|
||||
CORS_ALLOWED_ORIGINS = [
|
||||
"http://localhost:3000",
|
||||
"http://127.0.0.1:3000",
|
||||
"http://localhost:3001",
|
||||
"http://127.0.0.1:3001",
|
||||
]
|
||||
_cors_origins = os.environ.get('CORS_ALLOWED_ORIGINS', '')
|
||||
if _cors_origins:
|
||||
CORS_ALLOWED_ORIGINS = [o.strip() for o in _cors_origins.split(',')]
|
||||
else:
|
||||
CORS_ALLOWED_ORIGINS = [
|
||||
"http://localhost:3000",
|
||||
"http://127.0.0.1:3000",
|
||||
"http://localhost:3001",
|
||||
"http://127.0.0.1:3001",
|
||||
]
|
||||
|
||||
# メールフィルタリング機能
|
||||
MAIL_API_KEY = os.environ.get('MAIL_API_KEY', '')
|
||||
|
||||
Reference in New Issue
Block a user