From b0bea7ec8f542db3db6226e74ace1c8b29411153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Mon, 31 Aug 2026 13:22:09 -0300 Subject: [PATCH] chore: make root compose file the Portainer stack --- BACKEND.md | 2 +- PORTAINER.md | 2 +- docker-compose.dev.yml | 19 ++++++++++++++++ docker-compose.portainer.yml | 43 ------------------------------------ docker-compose.yml | 38 +++++++++++++++++++++++++------ 5 files changed, 52 insertions(+), 52 deletions(-) create mode 100644 docker-compose.dev.yml delete mode 100644 docker-compose.portainer.yml diff --git a/BACKEND.md b/BACKEND.md index a12b3fa..a282e6b 100644 --- a/BACKEND.md +++ b/BACKEND.md @@ -5,7 +5,7 @@ The project now has a small API and a PostgreSQL schema. Video delivery is provi ## Local setup 1. Copy `.env.example` to `.env` and use the default local values. -2. Start PostgreSQL with `docker compose up -d postgres`. +2. Start PostgreSQL with `docker compose -f docker-compose.dev.yml up -d postgres`. 3. Install dependencies with `npm install`. 4. Apply the versioned schema with `npm run db:migrate`. 5. Run the API with `npm run dev:api` and the frontend with `npm run dev`. diff --git a/PORTAINER.md b/PORTAINER.md index a5fce79..15bdd8f 100644 --- a/PORTAINER.md +++ b/PORTAINER.md @@ -1,6 +1,6 @@ # Portainer deployment -Use `docker-compose.portainer.yml` as a Portainer Stack from this repository. It deploys the frontend, API, and PostgreSQL as one internal Docker network. Only the web container exposes a port; it proxies `/api` to the API container. +Use `docker-compose.yml` as a Portainer Stack from this repository. It deploys the frontend, API, and PostgreSQL as one internal Docker network. Only the web container exposes a port; it proxies `/api` to the API container. ## Required Portainer environment variables diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..e5afdd2 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,19 @@ +services: + postgres: + image: postgres:16-alpine + environment: + POSTGRES_DB: compor_hub + POSTGRES_USER: compor + POSTGRES_PASSWORD: compor_local_password + ports: + - "5433:5432" + volumes: + - compor_postgres_data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U compor -d compor_hub"] + interval: 5s + timeout: 5s + retries: 10 + +volumes: + compor_postgres_data: diff --git a/docker-compose.portainer.yml b/docker-compose.portainer.yml deleted file mode 100644 index 90e5035..0000000 --- a/docker-compose.portainer.yml +++ /dev/null @@ -1,43 +0,0 @@ -services: - postgres: - image: postgres:16-alpine - restart: unless-stopped - environment: - POSTGRES_DB: ${POSTGRES_DB:-compor_hub} - POSTGRES_USER: ${POSTGRES_USER:-compor} - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in Portainer} - volumes: - - compor_postgres_data:/var/lib/postgresql/data - healthcheck: - test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] - interval: 10s - timeout: 5s - retries: 10 - - api: - build: - context: . - dockerfile: Dockerfile.api - restart: unless-stopped - environment: - APP_ENV: production - API_PORT: 3001 - FRONTEND_ORIGIN: ${FRONTEND_ORIGIN:?Set the public https URL in Portainer} - DATABASE_URL: postgresql://${POSTGRES_USER:-compor}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-compor_hub} - JWT_SECRET: ${JWT_SECRET:?Set a long random JWT_SECRET in Portainer} - depends_on: - postgres: - condition: service_healthy - - web: - build: - context: . - dockerfile: Dockerfile.web - restart: unless-stopped - ports: - - "${WEB_PORT:-8080}:80" - depends_on: - - api - -volumes: - compor_postgres_data: diff --git a/docker-compose.yml b/docker-compose.yml index e5afdd2..90e5035 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,19 +1,43 @@ services: postgres: image: postgres:16-alpine + restart: unless-stopped environment: - POSTGRES_DB: compor_hub - POSTGRES_USER: compor - POSTGRES_PASSWORD: compor_local_password - ports: - - "5433:5432" + POSTGRES_DB: ${POSTGRES_DB:-compor_hub} + POSTGRES_USER: ${POSTGRES_USER:-compor} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in Portainer} volumes: - compor_postgres_data:/var/lib/postgresql/data healthcheck: - test: ["CMD-SHELL", "pg_isready -U compor -d compor_hub"] - interval: 5s + test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] + interval: 10s timeout: 5s retries: 10 + api: + build: + context: . + dockerfile: Dockerfile.api + restart: unless-stopped + environment: + APP_ENV: production + API_PORT: 3001 + FRONTEND_ORIGIN: ${FRONTEND_ORIGIN:?Set the public https URL in Portainer} + DATABASE_URL: postgresql://${POSTGRES_USER:-compor}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-compor_hub} + JWT_SECRET: ${JWT_SECRET:?Set a long random JWT_SECRET in Portainer} + depends_on: + postgres: + condition: service_healthy + + web: + build: + context: . + dockerfile: Dockerfile.web + restart: unless-stopped + ports: + - "${WEB_PORT:-8080}:80" + depends_on: + - api + volumes: compor_postgres_data: