chore: add Docker Compose dev environment
This commit is contained in:
commit
214bf0e5a1
5 changed files with 139 additions and 0 deletions
0
.claude/settings.json
Normal file
0
.claude/settings.json
Normal file
28
Makefile
Normal file
28
Makefile
Normal file
|
|
@ -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
|
||||||
69
docker/docker-compose.yml
Normal file
69
docker/docker-compose.yml
Normal file
|
|
@ -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
|
||||||
27
docker/nginx/default.conf
Normal file
27
docker/nginx/default.conf
Normal file
|
|
@ -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";
|
||||||
|
}
|
||||||
|
}
|
||||||
15
docker/php/Dockerfile
Normal file
15
docker/php/Dockerfile
Normal file
|
|
@ -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
|
||||||
Loading…
Reference in a new issue