diff --git a/Dockerfile b/Dockerfile index 1e3ced4..f242b07 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,8 @@ COPY backend/requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY backend/ . COPY --from=frontend-builder /app/frontend/dist /app/dist +RUN chmod +x entrypoint.sh RUN mkdir -p uploads EXPOSE 8000 +ENTRYPOINT ["./entrypoint.sh"] CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/README.md b/README.md index b6c4071..58075b7 100644 --- a/README.md +++ b/README.md @@ -66,10 +66,53 @@ Frontend will be available at: http://localhost:5173 ## Demo Accounts -After seeding the database: +After seeding the database (runs automatically on container start): -- **Admin:** admin@example.com / adminpassword -- **User:** user@example.com / userpassword +| Email | Password | Role | +|-------|----------|------| +| admin@example.com | adminpassword | Superadmin | +| manager@example.com | managerpassword | Manager | +| user@example.com | userpassword | User | + +## Docker Compose (local) + +```bash +# Create .env from template +cp backend/.env.example backend/.env +# Edit .env with your values + +# Start all services +docker compose up --build +``` + +Frontend: http://localhost +Backend API: http://localhost:8000/docs + +## Deploy (Dokploy) + +``` +Dokploy UI → New Service → Docker Compose → Git: space-booking repo +``` + +### Environment Variables (Dokploy → Environment tab) + +| Variable | Required | Example | +|----------|----------|---------| +| `SECRET_KEY` | **Yes** | `python -c "import secrets; print(secrets.token_hex(32))"` | +| `FRONTEND_URL` | **Yes** | `https://space.roa.romfast.ro` | +| `SMTP_ENABLED` | No | `true` | +| `SMTP_HOST` | No* | `smtp.example.com` | +| `SMTP_PORT` | No* | `587` | +| `SMTP_USER` | No* | `user@example.com` | +| `SMTP_PASSWORD` | No* | `secret` | +| `SMTP_FROM_ADDRESS` | No* | `rezervari@romfast.ro` | + +*Required only if `SMTP_ENABLED=true` + +### Auto-seed + +`entrypoint.sh` runs `seed_db.py` automatically on every container start. +The script is idempotent — skips if data already exists. ## Development Commands diff --git a/backend/.env.example b/backend/.env.example index e59a843..715859c 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -25,3 +25,13 @@ FRONTEND_URL=http://localhost:5173 GOOGLE_CLIENT_ID=your_google_client_id_here GOOGLE_CLIENT_SECRET=your_google_client_secret_here GOOGLE_REDIRECT_URI=http://localhost:8000/api/integrations/google/callback + +# === PRODUCTION (Dokploy) === +# SECRET_KEY= +# FRONTEND_URL=https://space.roa.romfast.ro +# SMTP_ENABLED=true +# SMTP_HOST=smtp.example.com +# SMTP_PORT=587 +# SMTP_USER=user@example.com +# SMTP_PASSWORD=parola +# SMTP_FROM_ADDRESS=rezervari@romfast.ro diff --git a/backend/Dockerfile b/backend/Dockerfile index 02ab011..81a5059 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -7,8 +7,11 @@ RUN pip install --no-cache-dir -r requirements.txt COPY . . +RUN chmod +x entrypoint.sh + RUN mkdir -p uploads EXPOSE 8000 +ENTRYPOINT ["./entrypoint.sh"] CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/backend/entrypoint.sh b/backend/entrypoint.sh new file mode 100644 index 0000000..ebe3920 --- /dev/null +++ b/backend/entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e +echo "[entrypoint] Running database seed..." +python seed_db.py +echo "[entrypoint] Starting application..." +exec "$@" diff --git a/docker-compose.yml b/docker-compose.yml index 5d5389d..b4a93bd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,9 @@ services: - SMTP_HOST=${SMTP_HOST:-localhost} - SMTP_PORT=${SMTP_PORT:-1025} - SMTP_ENABLED=${SMTP_ENABLED:-false} + - SMTP_USER=${SMTP_USER:-} + - SMTP_PASSWORD=${SMTP_PASSWORD:-} + - SMTP_FROM_ADDRESS=${SMTP_FROM_ADDRESS:-noreply@space-booking.local} volumes: - backend_data:/data - uploads_data:/app/uploads