本番デプロイ用設定ファイルを追加
- 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:
28
frontend/Dockerfile.prod
Normal file
28
frontend/Dockerfile.prod
Normal file
@@ -0,0 +1,28 @@
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY . .
|
||||
|
||||
# NEXT_PUBLIC_API_URL はビルド時に埋め込まれる
|
||||
ARG NEXT_PUBLIC_API_URL=https://main.keinafarm.net
|
||||
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
||||
|
||||
RUN npm run build
|
||||
|
||||
# --- 実行ステージ ---
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/package*.json ./
|
||||
COPY --from=builder /app/.next ./.next
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["npm", "start"]
|
||||
Reference in New Issue
Block a user