Skip to content

Commit

Permalink
update docker files to run db tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Behzad-rabiei committed Mar 14, 2024
1 parent cdc5650 commit 9a3dcf8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ COPY . .
RUN npm ci

FROM base AS test
CMD [ "npx", "jest", "--coverage" ]
CMD [ "npx", "jest", "--runInBand", "--coverage" ]

FROM base AS build
RUN npm run build

FROM build AS prod
RUN npm ci --omit=dev
CMD ["npm", "run", "start"]
CMD ["npm", "run", "start"]
26 changes: 24 additions & 2 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
---
version: '3.9'
version: "3.9"

services:
app:
build:
context: .
target: test
dockerfile: Dockerfile
environment:
- DB_HOST=mongo
- DB_PORT=27017
- DB_USER=root
- DB_PASSWORD=pass
- DB_NAME=RnDAO
volumes:
- ./coverage:/project/coverage
depends_on:
mongo:
condition: service_healthy
mongo:
image: "mongo:5.0.10"
environment:
- MONGO_INITDB_DATABASE=RnDAO
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=pass
healthcheck:
test: echo 'db.stats().ok' | mongosh localhost:27017/test --quiet
interval: 60s
timeout: 10s
retries: 2
start_period: 40s


0 comments on commit 9a3dcf8

Please sign in to comment.