プロジェクト

全般

プロフィール

バグ #949

未完了

【948-1】環境構築・基盤整備 - Docker/Nginx/SSL設定

Redmine Admin さんが22日前に追加.

ステータス:
新規
優先度:
急いで
担当者:
-
開始日:
2025-07-31
期日:
進捗率:

0%

予定工数:

説明

【子チケット1】環境構築・基盤整備

🎯 目的

formauto.call2arm.comの基盤環境を構築し、Claude Codeでの開発準備を完了する。

📋 作業内容

1. インフラ基盤確認・整備

# VPS-ROOT環境確認
ssh -i ~/.ssh/003-key.pem root@85.131.243.51

# 現在のシステム構成確認
systemctl status nginx
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
ls -la /etc/nginx/sites-available/ | grep call2arm

# 利用可能リソース確認
df -h
free -m
docker system df

2. ドメイン・SSL設定確認

# ドメイン設定確認
cat /etc/nginx/sites-available/formauto.call2arm.com.conf

# SSL証明書確認
openssl x509 -in /etc/letsencrypt/live/call2arm.com/fullchain.pem -text -noout | grep -A2 "Subject Alternative Name"

# 設定テスト
nginx -t
systemctl reload nginx

# 接続テスト
curl -I https://formauto.call2arm.com

3. プロジェクトディレクトリ作成

# メインプロジェクトディレクトリ
mkdir -p /root/form-automation-system
cd /root/form-automation-system

# ディレクトリ構造作成
mkdir -p {frontend,backend,docker,nginx,scripts,docs,tests}
mkdir -p docker/{development,production}
mkdir -p nginx/{conf.d,ssl}
mkdir -p scripts/{deploy,backup,monitoring}

4. Docker環境準備

# プロキシネットワーク確認・作成
docker network ls | grep proxy-network || docker network create proxy-network

# ベースDockerfile準備
# frontend/Dockerfile.dev
# backend/Dockerfile
# docker-compose.yml(開発用)
# docker-compose.prod.yml(本番用)

5. 開発環境設定

# Git初期化
git init
git remote add origin [REPOSITORY_URL]

# 基本設定ファイル作成
touch .env.example
touch .gitignore
touch README.md
touch Makefile

# 権限設定
chmod +x scripts/*.sh

🔧 設定ファイル詳細

Nginx設定(/etc/nginx/sites-available/formauto.call2arm.com.conf)

server {
    listen 80;
    server_name formauto.call2arm.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name formauto.call2arm.com;

    # SSL Configuration
    ssl_certificate /etc/letsencrypt/live/call2arm.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/call2arm.com/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384;
    ssl_prefer_server_ciphers off;

    # Security Headers
    add_header X-Frame-Options DENY;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";

    # Proxy Settings
    location / {
        proxy_pass http://form-automation-frontend:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_cache_bypass $http_upgrade;
    }

    location /api/ {
        proxy_pass http://form-automation-backend:8000/;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    location /ws/ {
        proxy_pass http://form-automation-backend:8000/ws/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    # Static Files
    location /static/ {
        alias /var/www/formauto/static/;
        expires 1y;
        add_header Cache-Control "public, immutable";
    }

    # Logging
    access_log /var/log/nginx/formauto.call2arm.com.access.log;
    error_log /var/log/nginx/formauto.call2arm.com.error.log;
}

Docker Compose(開発用)

version: '3.8'

services:
  # Frontend Development Server
  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile.dev
    container_name: form-automation-frontend
    volumes:
      - ./frontend:/app
      - /app/node_modules
    environment:
      - VITE_API_URL=https://formauto.call2arm.com/api
      - VITE_WS_URL=wss://formauto.call2arm.com/ws
    networks:
      - proxy-network
      - form-automation-network
    depends_on:
      - backend

  # Backend API Server
  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    container_name: form-automation-backend
    volumes:
      - ./backend:/app
    environment:
      - DATABASE_URL=postgresql://form_user:${DB_PASSWORD}@postgres:5432/form_automation
      - REDIS_URL=redis://redis:6379/0
      - SECRET_KEY=${SECRET_KEY}
      - ENVIRONMENT=development
    networks:
      - proxy-network
      - form-automation-network
    depends_on:
      - postgres
      - redis

  # Database
  postgres:
    image: postgres:15-alpine
    container_name: form-automation-postgres
    environment:
      - POSTGRES_DB=form_automation
      - POSTGRES_USER=form_user
      - POSTGRES_PASSWORD=${DB_PASSWORD}
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./docker/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql
    networks:
      - form-automation-network

  # Redis
  redis:
    image: redis:7-alpine
    container_name: form-automation-redis
    command: redis-server --appendonly yes
    volumes:
      - redis_data:/data
    networks:
      - form-automation-network

networks:
  proxy-network:
    external: true
  form-automation-network:
    driver: bridge

volumes:
  postgres_data:
  redis_data:

Makefile

.PHONY: setup dev build test clean deploy

# Colors
BLUE=\033[0;34m
GREEN=\033[0;32m
YELLOW=\033[1;33m
NC=\033[0m

# Setup development environment
setup:
	@echo -e "$(BLUE)Setting up Form Automation System...$(NC)"
	@cp .env.example .env
	@echo -e "$(YELLOW)Please edit .env file with your configuration$(NC)"
	@docker network ls | grep proxy-network || docker network create proxy-network
	@echo -e "$(GREEN)Setup complete!$(NC)"

# Start development environment
dev:
	@echo -e "$(BLUE)Starting development environment...$(NC)"
	@docker-compose up -d
	@echo -e "$(GREEN)Development environment started!$(NC)"
	@echo -e "$(YELLOW)Access: https://formauto.call2arm.com$(NC)"

# Build production images
build:
	@echo -e "$(BLUE)Building production images...$(NC)"
	@docker-compose -f docker-compose.prod.yml build

# Run tests
test:
	@echo -e "$(BLUE)Running tests...$(NC)"
	@docker-compose exec backend pytest
	@docker-compose exec frontend npm test

# Clean up
clean:
	@echo -e "$(BLUE)Cleaning up...$(NC)"
	@docker-compose down -v
	@docker system prune -f

# Deploy to production
deploy:
	@echo -e "$(BLUE)Deploying to production...$(NC)"
	@./scripts/deploy/deploy.sh

✅ 完了条件

基盤環境確認

  • VPS-ROOT環境の詳細確認完了
  • 既存インフラとの競合なし確認
  • ドメイン・SSL設定動作確認

プロジェクト構造作成

  • プロジェクトディレクトリ構造作成
  • 基本設定ファイル配置
  • Git初期化・リモート設定

Docker環境構築

  • Docker Compose設定完了
  • proxy-network接続確認
  • 基本コンテナ起動確認

接続確認

🔄 次のステップ

環境構築完了後、子チケット2(フロントエンド基盤実装)に移行。

⚠️ 注意事項

  • 既存の稼働中サービスに影響を与えないよう慎重に作業
  • 設定変更前は必ずバックアップを取得
  • システムレベルnginxの設定変更は段階的に実施
  • Docker Composeの起動前にポート競合確認

Claude Code実行プロンプト:

VPS-ROOT(85.131.243.51)にSSH接続し、formauto.call2arm.comのフォーム自動化システム基盤環境を構築してください。システムレベルnginx使用、Docker Compose管理、proxy-network統合で既存環境への影響を回避しながら実装してください。段階的確認を行い、各ステップの完了を報告してください。

表示するデータがありません

他の形式にエクスポート: Atom PDF