Working docker compose
This commit is contained in:
parent
d3845ba668
commit
4686a5561a
3 changed files with 79 additions and 36 deletions
|
|
@ -1,17 +1,15 @@
|
||||||
version: "3.8"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
db:
|
web:
|
||||||
image: mysql:8.0
|
image: nginx:alpine
|
||||||
container_name: dishplanner-db
|
container_name: dishplanner-nginx
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
depends_on:
|
||||||
MYSQL_ROOT_PASSWORD: rootpassword
|
- backend
|
||||||
MYSQL_DATABASE: dishplanner
|
|
||||||
MYSQL_USER: dishuser
|
|
||||||
MYSQL_PASSWORD: dishpass
|
|
||||||
volumes:
|
volumes:
|
||||||
- db_data:/var/lib/mysql
|
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||||
|
command: /bin/sh -c "until nslookup backend. ; do sleep 2; done && nginx -g 'daemon off;'"
|
||||||
|
ports:
|
||||||
|
- "3000:80"
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
image: jochent/dishplanner-backend:latest
|
image: jochent/dishplanner-backend:latest
|
||||||
|
|
@ -27,19 +25,31 @@ services:
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
ports:
|
ports:
|
||||||
- "9000:9000" # Only needed if exposing php-fpm, otherwise remove
|
- "8080:8080"
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
image: jochent/dishplanner-frontend:latest
|
image: jochent/dishplanner-frontend:latest
|
||||||
container_name: dishplanner-frontend
|
container_name: dishplanner-frontend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
|
||||||
NEXT_PUBLIC_API_URL: http://localhost:9000 # or backend:9000 if hitting directly
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
ports:
|
# ports:
|
||||||
- "3000:3000"
|
# - "3000:3000"
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: mysql:8.0
|
||||||
|
container_name: dishplanner-db
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: rootpassword
|
||||||
|
MYSQL_DATABASE: dishplanner
|
||||||
|
MYSQL_USER: dishuser
|
||||||
|
MYSQL_PASSWORD: dishpass
|
||||||
|
volumes:
|
||||||
|
- db_data:/var/lib/mysql
|
||||||
volumes:
|
volumes:
|
||||||
db_data:
|
db_data:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
name: dishplanner-net
|
||||||
|
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
|
|
||||||
# Route API requests to Laravel
|
|
||||||
location /api/ {
|
|
||||||
proxy_pass http://backend:80/;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Route all other requests to React
|
|
||||||
location / {
|
|
||||||
proxy_pass http://frontend:3000/;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
try_files $uri /index.html;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
53
nginx/nginx.conf
Normal file
53
nginx/nginx.conf
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
|
||||||
|
# === FRONTEND ===
|
||||||
|
location / {
|
||||||
|
proxy_pass http://frontend:3000;
|
||||||
|
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;
|
||||||
|
|
||||||
|
# WebSocket support (optional but good for Next.js dev tools etc.)
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
}
|
||||||
|
|
||||||
|
# === BACKEND API ===
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://backend:80;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
# === Sanctum (Laravel token auth) ===
|
||||||
|
location /sanctum/ {
|
||||||
|
proxy_pass http://backend:80;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
# === Client-side routing fallback (Next.js or SPA mode) ===
|
||||||
|
error_page 404 /index.html;
|
||||||
|
location = /index.html {
|
||||||
|
proxy_pass http://frontend:3000/index.html;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue