commit 214bf0e5a115269cb3e19116e7ee2e4195c16933 Author: Tim Stollberg Date: Tue Jun 23 15:26:59 2026 +0700 chore: add Docker Compose dev environment diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..e69de29 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b2a3e52 --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +PHONY: dev stop test lint migrate fresh shell-php shell-node build + +dev: + docker compose -f docker/docker-compose.yml up -d + +stop: + docker compose -f docker/docker-compose.yml down + +test: + docker compose -f docker/docker-compose.yml exec backend composer test + +lint: + docker compose -f docker/docker-compose.yml exec backend composer static-analysis + +migrate: + docker compose -f docker/docker-compose.yml exec backend php artisan migrate + +fresh: + docker compose -f docker/docker-compose.yml exec backend php artisan migrate:fresh --seed + +shell-php: + docker compose -f docker/docker-compose.yml exec backend bash + +shell-node: + docker compose -f docker/docker-compose.yml exec frontend sh + +build: + docker compose -f docker/docker-compose.yml exec frontend npm run build diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..96c5ea0 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,69 @@ +services: + backend: + build: + context: . + dockerfile: php/Dockerfile + working_dir: /var/www/html + volumes: + - ../backend:/var/www/html + command: php artisan serve --host=0.0.0.0 --port=8000 + environment: + APP_ENV: local + DB_HOST: mysql + DB_DATABASE: mandantcrm + DB_USERNAME: mandantcrm + DB_PASSWORD: secret + depends_on: + mysql: + condition: service_healthy + networks: + - mandant + + frontend: + image: node:20-alpine + working_dir: /app + volumes: + - ../frontend:/app + command: sh -c "npm install && npm run dev" + environment: + - HOST=0.0.0.0 + networks: + - mandant + + nginx: + image: nginx:alpine + ports: + - "80:80" + volumes: + - ./nginx/default.conf:/etc/nginx/conf.d/default.conf + depends_on: + - backend + - frontend + networks: + - mandant + + mysql: + image: mysql:8.0 + environment: + MYSQL_DATABASE: mandantcrm + MYSQL_USER: mandantcrm + MYSQL_PASSWORD: secret + MYSQL_ROOT_PASSWORD: rootsecret + volumes: + - mysql_data:/var/lib/mysql + ports: + - "3306:3306" + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "mandantcrm", "-psecret"] + interval: 5s + timeout: 5s + retries: 10 + networks: + - mandant + +volumes: + mysql_data: + +networks: + mandant: + driver: bridge diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf new file mode 100644 index 0000000..6c98b62 --- /dev/null +++ b/docker/nginx/default.conf @@ -0,0 +1,27 @@ +server { + listen 80; + server_name localhost; + client_max_body_size 10M; + + location /api/ { + proxy_pass http://backend:8000; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /sanctum/ { + proxy_pass http://backend:8000; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + + location / { + proxy_pass http://frontend:3000; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } +} diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile new file mode 100644 index 0000000..5039eb4 --- /dev/null +++ b/docker/php/Dockerfile @@ -0,0 +1,15 @@ +FROM php:8.2-cli-alpine + +RUN apk add --no-cache \ + curl \ + libpng-dev \ + libxml2-dev \ + zip \ + unzip \ + git \ + sqlite-dev \ + && docker-php-ext-install pdo pdo_mysql pdo_sqlite gd + +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +WORKDIR /var/www/html