mirror of
https://github.com/UniversityOfHelsinkiCS/ohtuilmo.git
synced 2026-10-12 19:03:41 +03:00
133 lines
3.0 KiB
YAML
133 lines
3.0 KiB
YAML
services:
|
|
db:
|
|
image: postgres:16-alpine
|
|
environment:
|
|
- POSTGRES_PASSWORD=postgres
|
|
- POSTGRES_DB=test_postgres
|
|
container_name: test-db
|
|
profiles: [db, test-setup, backend-test, cypress]
|
|
ports:
|
|
- 5432: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: [db]
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
volumes:
|
|
- ./backend:/usr/src/app
|
|
- /usr/src/app/node_modules
|
|
environment:
|
|
- DATABASE_URL=postgres://postgres:postgres@db:5432/test_postgres
|
|
- SECRET=testsecret
|
|
- EMAIL_ENABLED=false
|
|
- PORT=3001
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
cd /usr/src/app
|
|
npm install
|
|
npm run db:create
|
|
npm run db:migrate
|
|
|
|
backend:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile.dev
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
npm run db:migrate
|
|
npm run db:seed:all
|
|
npm run watch:test
|
|
while ! curl -fsS http://localhost:3001/api >/dev/null; sleep 1; done
|
|
echo "Test setup is now up!"
|
|
expose:
|
|
- 3001
|
|
volumes:
|
|
- ./backend:/usr/src/app
|
|
- /usr/src/app/node_modules
|
|
environment:
|
|
- PORT=3001
|
|
- SECRET=yoursecrethere
|
|
- EMAIL_ENABLED=false
|
|
- DATABASE_URL=postgres://postgres:postgres@db:5432/test_postgres
|
|
container_name: test-backend
|
|
profiles: [test-setup, cypress]
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
|
|
frontend:
|
|
build:
|
|
context: ./frontend
|
|
dockerfile: Dockerfile.dev
|
|
command: npm run dev
|
|
ports:
|
|
- 3002:3000
|
|
volumes:
|
|
- ./frontend:/usr/src/app
|
|
- /usr/src/app/node_modules
|
|
container_name: test-frontend
|
|
profiles: [test-setup, cypress]
|
|
depends_on:
|
|
- backend
|
|
- db
|
|
|
|
backend-test:
|
|
build:
|
|
context: './backend'
|
|
dockerfile: Dockerfile.dev
|
|
profiles: [backend-test]
|
|
restart: no
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
volumes:
|
|
- ./backend:/usr/src/app
|
|
- /usr/src/app/node_modules
|
|
environment:
|
|
- DATABASE_URL=postgres://postgres:postgres@db:5432/test_postgres
|
|
- SECRET=testsecret
|
|
- EMAIL_ENABLED=false
|
|
- PORT=3001
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
cd /usr/src/app
|
|
npm install
|
|
npm run db:migrate
|
|
npm run test
|
|
|
|
cypress:
|
|
image: cypress/included:13.8.0
|
|
container_name: cypress
|
|
profiles: [cypress]
|
|
volumes:
|
|
- ./frontend/e2e:/e2e
|
|
- ./frontend/cypress.config.js:/cypress.config.js
|
|
environment:
|
|
- CYPRESS_baseUrl=http://frontend:3000
|
|
- CYPRESS_VIDEO=false
|
|
depends_on:
|
|
- db
|
|
- backend
|
|
- frontend
|