|
| 1 | +--- |
| 2 | +title: Deploy with Docker |
| 3 | +description: Build and run Open Self Service using Docker and Docker Compose. |
| 4 | +--- |
| 5 | + |
| 6 | +This project ships with production-ready Dockerfiles for both apps and a `docker-compose.yml` at the repository root. |
| 7 | + |
| 8 | +Prerequisites: |
| 9 | + |
| 10 | +- Docker 24+ |
| 11 | +- Docker Compose v2+ |
| 12 | + |
| 13 | +Recommended approach: use the provided `docker-compose.yml` to run both services together. |
| 14 | + |
| 15 | +Create a shared network (first time only): |
| 16 | + |
| 17 | +```bash |
| 18 | +docker network create app_network |
| 19 | +``` |
| 20 | + |
| 21 | +Start both services: |
| 22 | + |
| 23 | +```bash |
| 24 | +docker compose up -d --build |
| 25 | +``` |
| 26 | + |
| 27 | +This will: |
| 28 | + |
| 29 | +- Build `apps/frontend/Dockerfile` and expose it on `http://localhost:3000` |
| 30 | +- Build `apps/api-harmonization/Dockerfile` and expose it on `http://localhost:3001` |
| 31 | + |
| 32 | +Environment variables |
| 33 | + |
| 34 | +The `docker-compose.yml` includes sane defaults. Adjust as needed (especially external API keys). |
| 35 | + |
| 36 | +- Frontend (Next.js): |
| 37 | + - `NEXT_PUBLIC_BASE_URL` (e.g. `http://localhost:3000`) |
| 38 | + - `NEXT_PUBLIC_API_URL` (public API URL, e.g. `http://localhost:3001/api`) |
| 39 | + - `NEXT_PUBLIC_API_URL_INTERNAL` (internal container URL, e.g. `http://api-harmonization:3001/api`) |
| 40 | + - `NEXT_PUBLIC_DEFAULT_LOCALE`, `NEXT_PUBLIC_SUPPORTED_LOCALES` |
| 41 | + - Optional logging: `NEXT_PUBLIC_LOG_LEVEL`, `NEXT_PUBLIC_LOG_FORMAT`, `NEXT_PUBLIC_LOG_COLORS_ENABLED` |
| 42 | + - Auth (optional): `AUTH_SECRET`, `AUTH_TRUST_HOST`, `AUTH_GITHUB_ID`, `AUTH_GITHUB_SECRET`, `AUTH_GOOGLE_ID`, `AUTH_GOOGLE_SECRET`, `AUTH_DATABASE_URL`, `AUTH_DEFAULT_USER_ROLE` |
| 43 | + |
| 44 | +- API (NestJS): |
| 45 | + - `PORT` (e.g. `3001`) |
| 46 | + - `API_PREFIX` (e.g. `api`) |
| 47 | + - `FRONT_BASE_URLS` (comma-separated, e.g. `http://localhost:3000`) |
| 48 | + - Optional logging: `LOG_LEVEL`, `LOG_FORMAT`, `LOG_COLORS_ENABLED` |
| 49 | + - Integrations: see `/docs/integrations` for provider-specific variables (e.g. `CMS_STRAPI_BASE_URL`, `ALGOLIA_*`, `MEDUSAJS_*`, `CACHE_*`, etc.) |
| 50 | + |
| 51 | +Useful commands |
| 52 | + |
| 53 | +```bash |
| 54 | +# View logs |
| 55 | +docker compose logs -f frontend |
| 56 | +docker compose logs -f api-harmonization |
| 57 | + |
| 58 | +# Rebuild after changes |
| 59 | +docker compose build --no-cache frontend api-harmonization |
| 60 | + |
| 61 | +# Stop |
| 62 | +docker compose down |
| 63 | +``` |
| 64 | + |
| 65 | +Build images manually (optional) |
| 66 | + |
| 67 | +```bash |
| 68 | +# from repo root |
| 69 | +docker build -t o2s-frontend -f apps/frontend/Dockerfile . |
| 70 | +docker build -t o2s-api -f apps/api-harmonization/Dockerfile . |
| 71 | + |
| 72 | +docker run --rm -p 3000:3000 --network app_network \ |
| 73 | + -e NEXT_PUBLIC_BASE_URL=http://localhost:3000 \ |
| 74 | + -e NEXT_PUBLIC_API_URL=http://localhost:3001/api \ |
| 75 | + -e NEXT_PUBLIC_API_URL_INTERNAL=http://api-harmonization:3001/api \ |
| 76 | + o2s-frontend |
| 77 | + |
| 78 | +docker run --rm -p 3001:3001 --network app_network \ |
| 79 | + -e PORT=3001 -e API_PREFIX=api -e FRONT_BASE_URLS=http://localhost:3000 \ |
| 80 | + o2s-api |
| 81 | +``` |
| 82 | + |
| 83 | +**Note:** The Dockerfiles use Turborepo's `turbo prune` with `@dxp/frontend` and `@dxp/api-harmonization` package names internally. This is handled automatically by the build process. |
| 84 | + |
| 85 | +Example Dockerfiles |
| 86 | + |
| 87 | +See the repository for maintained examples: |
| 88 | + |
| 89 | +- `apps/frontend/Dockerfile` |
| 90 | +- `apps/api-harmonization/Dockerfile` |
| 91 | + |
| 92 | + |
0 commit comments