mirror of
https://github.com/UniversityOfHelsinkiCS/ohtuilmo.git
synced 2026-10-12 19:03:41 +03:00
149 lines
3.4 KiB
YAML
149 lines
3.4 KiB
YAML
services:
|
|
test-db:
|
|
image: postgres:16-alpine
|
|
environment:
|
|
- POSTGRES_PASSWORD=postgres
|
|
- POSTGRES_DB=test_postgres
|
|
container_name: test-db
|
|
profiles: [local-api, api, local-e2e, e2e]
|
|
ports:
|
|
- 6543:5432
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
|
interval: 1s
|
|
timeout: 10s
|
|
retries: 60
|
|
volumes:
|
|
# Uses a tmpfs volume to make tests extremely fast. The data in test
|
|
# databases is not persisted across restarts, nor does it need to be.
|
|
- type: tmpfs
|
|
target: /data/test
|
|
|
|
migrate-db:
|
|
build:
|
|
context: './backend'
|
|
dockerfile: Dockerfile.dev
|
|
restart: no
|
|
profiles: [local-api]
|
|
depends_on:
|
|
test-db:
|
|
condition: service_healthy
|
|
volumes:
|
|
- ./backend:/usr/src/app
|
|
- /usr/src/app/node_modules
|
|
environment:
|
|
- DATABASE_URL=postgres://postgres:postgres@test-db:5432/test_postgres
|
|
- SECRET=testsecret
|
|
- EMAIL_ENABLED=false
|
|
- PORT=5001
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
cd /usr/src/app
|
|
npm install
|
|
npm run db:nuke
|
|
npm run db:migrate
|
|
|
|
test-backend:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile.dev
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
npm run db:recreate
|
|
npm run watch:test
|
|
while ! curl -fsS http://localhost:3001/api >/dev/null; sleep 1; done
|
|
echo "Test setup is now up!"
|
|
ports:
|
|
- 5001:3001
|
|
volumes:
|
|
- ./backend:/usr/src/app
|
|
- /usr/src/app/node_modules
|
|
environment:
|
|
- PORT=3001
|
|
- SECRET=yoursecrethere
|
|
- EMAIL_ENABLED=false
|
|
- DATABASE_URL=postgres://postgres:postgres@test-db:5432/test_postgres
|
|
- NODE_ENV=test
|
|
container_name: test-backend
|
|
profiles: [local-e2e, e2e]
|
|
depends_on:
|
|
test-db:
|
|
condition: service_healthy
|
|
|
|
test-frontend:
|
|
build:
|
|
context: ./frontend
|
|
dockerfile: Dockerfile.dev
|
|
command: npm run dev
|
|
ports:
|
|
- 5000:3000
|
|
volumes:
|
|
- ./frontend:/usr/src/app
|
|
- /usr/src/app/node_modules
|
|
environment:
|
|
- VITE_PORT=3000
|
|
- VITE_BACKEND_URL=http://test-backend:3001
|
|
container_name: test-frontend
|
|
profiles: [local-e2e, e2e]
|
|
depends_on:
|
|
- test-backend
|
|
- test-db
|
|
|
|
api-test:
|
|
build:
|
|
context: './backend'
|
|
dockerfile: Dockerfile.dev
|
|
profiles: [api]
|
|
restart: no
|
|
depends_on:
|
|
test-db:
|
|
condition: service_healthy
|
|
volumes:
|
|
- ./backend:/usr/src/app
|
|
- /usr/src/app/node_modules
|
|
environment:
|
|
- DATABASE_URL=postgres://postgres:postgres@test-db:5432/test_postgres
|
|
- SECRET=testsecret
|
|
- EMAIL_ENABLED=false
|
|
- PORT=3001
|
|
- NODE_ENV=test
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
cd /usr/src/app
|
|
npm install
|
|
npm run db:migrate
|
|
npm run test
|
|
|
|
cypress:
|
|
image: cypress/included:15.6.0
|
|
container_name: cypress
|
|
profiles: [e2e]
|
|
volumes:
|
|
- ./frontend/e2e:/e2e
|
|
- ./frontend/cypress.config.js:/cypress.config.js
|
|
environment:
|
|
- CYPRESS_baseUrl=http://test-frontend:3000
|
|
- CYPRESS_VIDEO=false
|
|
depends_on:
|
|
- test-db
|
|
- test-backend
|
|
- test-frontend
|
|
|
|
adminer:
|
|
image: adminer
|
|
container_name: test-adminer
|
|
profiles: [local-api, local-e2e]
|
|
environment:
|
|
- ADMINER_DESIGN=galkaev
|
|
ports:
|
|
- 9090:8080
|
|
depends_on:
|
|
test-db:
|
|
condition: service_healthy
|