55 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
| # This file is for running CI tests locally, mirroring .gitea/workflows/ci.yml
 | |
| services:
 | |
|   # This is the test database, mirroring the 'services' block in the CI job.
 | |
|   merchantsofhope-supplyanddemandportal-test-database:
 | |
|     image: postgres:15-alpine
 | |
|     container_name: merchantsofhope-supplyanddemandportal-test-database
 | |
|     environment:
 | |
|       POSTGRES_DB: merchantsofhope_test
 | |
|       POSTGRES_USER: postgres
 | |
|       POSTGRES_PASSWORD: postgres
 | |
|     ports:
 | |
|       - "55432:5432"
 | |
|     # Add a healthcheck to ensure the database is ready before tests run
 | |
|     healthcheck:
 | |
|       test: ["CMD-SHELL", "pg_isready -U postgres"]
 | |
|       interval: 10s
 | |
|       timeout: 5s
 | |
|       retries: 5
 | |
|     networks:
 | |
|       - merchantsofhope-supplyanddemandportal-network
 | |
| 
 | |
|   # This service runs the backend test suite.
 | |
|   backend-tester:
 | |
|     build:
 | |
|       context: ./backend
 | |
|       dockerfile: Dockerfile
 | |
|     container_name: merchantsofhope-supplyanddemandportal-backend-tester
 | |
|     command: >
 | |
|       sh -c "npm run migrate && npm test -- --runInBand"
 | |
|     environment:
 | |
|       NODE_ENV: test
 | |
|       DATABASE_URL: postgresql://postgres:postgres@merchantsofhope-supplyanddemandportal-test-database:5432/merchantsofhope_test
 | |
|       JWT_SECRET: merchantsofhope_test_secret
 | |
|     depends_on:
 | |
|       merchantsofhope-supplyanddemandportal-test-database:
 | |
|         condition: service_healthy
 | |
|     networks:
 | |
|       - merchantsofhope-supplyanddemandportal-network
 | |
| 
 | |
|   # This service runs the frontend test suite.
 | |
|   frontend-tester:
 | |
|     build:
 | |
|       context: ./frontend
 | |
|       dockerfile: Dockerfile
 | |
|     container_name: merchantsofhope-supplyanddemandportal-frontend-tester
 | |
|     command: npm test -- --watchAll=false
 | |
|     environment:
 | |
|       NODE_ENV: test
 | |
|     networks:
 | |
|       - merchantsofhope-supplyanddemandportal-network
 | |
| 
 | |
| networks:
 | |
|   merchantsofhope-supplyanddemandportal-network:
 | |
|     driver: bridge
 |