feat(docker): add Docker Compose deployment for Dokploy
- backend/Dockerfile: Python 3.12-slim, uvicorn on port 8000 - frontend/Dockerfile: multi-stage Node build + nginx:alpine serve - frontend/nginx.conf: proxy /api to backend, SPA routing for Vue Router - docker-compose.yml: backend+frontend services with Traefik labels - fix(cors): use settings.frontend_url instead of hardcoded localhost Fixes Nixpacks detection failure (requirements.txt/package.json not at root). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
14
backend/Dockerfile
Normal file
14
backend/Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN mkdir -p uploads
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
@@ -34,7 +34,7 @@ app = FastAPI(title=settings.app_name)
|
||||
# CORS middleware
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["http://localhost:5173"], # Frontend dev server
|
||||
allow_origins=[settings.frontend_url, "http://localhost:5173"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
|
||||
42
docker-compose.yml
Normal file
42
docker-compose.yml
Normal file
@@ -0,0 +1,42 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
backend:
|
||||
build: ./backend
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- SECRET_KEY=${SECRET_KEY:-change-me-in-production}
|
||||
- DATABASE_URL=sqlite:////data/space_booking.db
|
||||
- FRONTEND_URL=${FRONTEND_URL:-http://localhost}
|
||||
- SMTP_HOST=${SMTP_HOST:-localhost}
|
||||
- SMTP_PORT=${SMTP_PORT:-1025}
|
||||
- SMTP_ENABLED=${SMTP_ENABLED:-false}
|
||||
volumes:
|
||||
- backend_data:/data
|
||||
- uploads_data:/app/uploads
|
||||
networks:
|
||||
- internal
|
||||
|
||||
frontend:
|
||||
build: ./frontend
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- internal
|
||||
- dokploy-network
|
||||
depends_on:
|
||||
- backend
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.space-booking.rule=Host(`${DOMAIN:-space-booking.roa.romfast.ro}`)"
|
||||
- "traefik.http.routers.space-booking.tls=true"
|
||||
- "traefik.http.services.space-booking.loadbalancer.server.port=80"
|
||||
|
||||
volumes:
|
||||
backend_data:
|
||||
uploads_data:
|
||||
|
||||
networks:
|
||||
internal:
|
||||
driver: bridge
|
||||
dokploy-network:
|
||||
external: true
|
||||
13
frontend/Dockerfile
Normal file
13
frontend/Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:alpine
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
EXPOSE 80
|
||||
21
frontend/nginx.conf
Normal file
21
frontend/nginx.conf
Normal file
@@ -0,0 +1,21 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# Proxy API requests to backend service
|
||||
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;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# SPA routing - all other routes serve index.html
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user