desker/DOCKER_SETUP.md

60 lines
1.8 KiB
Markdown

# Docker Setup Guide
This guide describes how to deploy the application using Docker and Docker Compose.
## Prerequisites
- Docker (20.10+)
- Docker Compose (v2.0+)
## Environment Variables
Create a `.env` file in the root directory. The following variables are supported (with their default values shown):
| Variable | Description | Default |
|----------|-------------|---------|
| `DB_USER` | PostgreSQL username | `postgres` |
| `DB_PASSWORD` | PostgreSQL password | `postgres` |
| `DB_NAME` | PostgreSQL database name | `hotdesking` |
| `DB_PORT_EXTERNAL` | External port for PostgreSQL | `5433` |
| `API_PORT_EXTERNAL` | External port for the API | `3000` |
| `WEB_PORT_EXTERNAL` | External port for the Web app | `5173` |
| `JWT_SECRET` | Secret key for JWT signing | `super-secret-change-me` |
| `WEB_ORIGIN` | The origin of the web app (required by SvelteKit) | `http://localhost:5173` |
| `VITE_API_BASE_URL` | The URL of the API (for the web app) | `http://localhost:3000` |
## Deployment Steps
1. **Build and start the containers:**
```bash
docker-compose up -d --build
```
2. **Run Database Migrations:**
Since the API uses Prisma, you need to run migrations to set up the database schema:
```bash
docker exec -it hotdesking_api npx prisma migrate deploy
```
3. **(Optional) Seed the Database:**
If you have a seed script defined in `apps/api/prisma/seed.ts`:
```bash
docker exec -it hotdesking_api npx prisma db seed
```
4. **Access the Applications:**
- Web App: [http://localhost:5173](http://localhost:5173)
- API: [http://localhost:3000](http://localhost:3000)
- pgAdmin: [http://localhost:5051](http://localhost:5051) (Login: `admin@local.dev` / `admin`)
## Development with Docker
To watch logs:
```bash
docker-compose logs -f
```
To stop the applications:
```bash
docker-compose down
```