docker setup
This commit is contained in:
89
docker-compose.test.yml
Normal file
89
docker-compose.test.yml
Normal file
@@ -0,0 +1,89 @@
|
||||
services:
|
||||
deps:
|
||||
image: node:20-alpine
|
||||
working_dir: /app
|
||||
environment:
|
||||
- NODE_ENV=development
|
||||
- NPM_CONFIG_FUND=false
|
||||
- NPM_CONFIG_AUDIT=false
|
||||
- NPM_CONFIG_UPDATE_NOTIFIER=false
|
||||
volumes:
|
||||
- ./:/app
|
||||
- test_node_modules:/app/node_modules
|
||||
- test_npm_cache:/root/.npm
|
||||
command:
|
||||
[
|
||||
"sh",
|
||||
"-lc",
|
||||
"set -e; LOCK_HASH=\"$$(sha1sum package-lock.json | awk '{print $$1}')\"; MARKER=\"node_modules/.gridpilot_lock_hash_test\"; if [ -f \"$$MARKER\" ] && [ \"$$(cat \"$$MARKER\")\" = \"$$LOCK_HASH\" ]; then echo \"[deps] node_modules up-to-date\"; else echo \"[deps] installing api+website deps\"; npm install --no-package-lock --workspace=./apps/api --workspace=./apps/website --include-workspace-root --no-audit --fund=false --prefer-offline; echo \"$$LOCK_HASH\" > \"$$MARKER\"; fi",
|
||||
]
|
||||
networks:
|
||||
- gridpilot-test-network
|
||||
restart: "no"
|
||||
|
||||
api:
|
||||
image: node:20-alpine
|
||||
environment:
|
||||
- NODE_ENV=test
|
||||
ports:
|
||||
- "3001:3000"
|
||||
command:
|
||||
[
|
||||
"sh",
|
||||
"-lc",
|
||||
"node -e \"const http=require('http'); const baseCors={ 'Access-Control-Allow-Credentials':'true','Access-Control-Allow-Headers':'Content-Type','Access-Control-Allow-Methods':'GET,POST,PUT,PATCH,DELETE,OPTIONS' }; const server=http.createServer((req,res)=>{ const origin=req.headers.origin||'http://localhost:3000'; res.setHeader('Access-Control-Allow-Origin', origin); res.setHeader('Vary','Origin'); for(const [k,v] of Object.entries(baseCors)){ res.setHeader(k,v); } if(req.method==='OPTIONS'){ res.statusCode=204; return res.end(); } const url=new URL(req.url,'http://localhost'); const send=(code,obj)=>{ res.statusCode=code; res.setHeader('content-type','application/json'); res.end(JSON.stringify(obj)); }; if(url.pathname==='/health'){ return send(200,{status:'ok'});} if(url.pathname==='/auth/session'){ res.statusCode=200; res.setHeader('content-type','application/json'); return res.end('null'); } if(url.pathname==='/races/page-data'){ return send(200,{races:[]}); } if(url.pathname==='/leagues/all-with-capacity'){ return send(200,{leagues:[], totalCount:0}); } if(url.pathname==='/teams/all'){ return send(200,{teams:[], totalCount:0}); } return send(404,{message:'Not Found', path:url.pathname}); }); server.listen(3000,()=>console.log('[api-mock] listening on 3000'));\"",
|
||||
]
|
||||
networks:
|
||||
- gridpilot-test-network
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test:
|
||||
[
|
||||
"CMD",
|
||||
"node",
|
||||
"-e",
|
||||
"fetch('http://localhost:3000/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))",
|
||||
]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 30
|
||||
|
||||
website:
|
||||
image: gridpilot-website-test
|
||||
build:
|
||||
context: .
|
||||
dockerfile: apps/website/Dockerfile.dev
|
||||
environment:
|
||||
- NEXT_TELEMETRY_DISABLED=1
|
||||
- NODE_ENV=development
|
||||
- DOCKER=true
|
||||
- NEXT_PUBLIC_GRIDPILOT_MODE=alpha
|
||||
- API_BASE_URL=http://api:3000
|
||||
- NEXT_PUBLIC_API_BASE_URL=http://localhost:3001
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- ./:/app
|
||||
- test_node_modules:/app/node_modules
|
||||
- test_npm_cache:/root/.npm
|
||||
command: ["sh", "-lc", "npm run dev --workspace=@gridpilot/website"]
|
||||
depends_on:
|
||||
api:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- gridpilot-test-network
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test:
|
||||
["CMD", "node", "-e", "fetch('http://localhost:3000').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 20
|
||||
|
||||
networks:
|
||||
gridpilot-test-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
test_node_modules:
|
||||
test_npm_cache:
|
||||
Reference in New Issue
Block a user