Skip to content

Instantly share code, notes, and snippets.

@dcmcand
Created February 2, 2021 15:08
Show Gist options
  • Save dcmcand/b97a9493e5c58151150ca4841ec5bd98 to your computer and use it in GitHub Desktop.
Save dcmcand/b97a9493e5c58151150ca4841ec5bd98 to your computer and use it in GitHub Desktop.
proposed docker-compose for tests.
version: "3.5"
services:
test-backend:
build:
context: .
container_name: test-backend
command: yarn server
user: ${CURRENT_USER:-root}
depends_on:
- test-db
environment:
- POSTGRES_HOST=test-db
volumes:
- ".:/app:rw"
test-frontend:
build:
context: .
command: yarn start
user: ${CURRENT_USER:-root}
stdin_open: true
volumes:
- "./frontend:/app:rw"
- "./scripts:/app/scripts"
environment:
- BACKEND_PROXY=http://test-backend:8000
test-db:
env_file: .env
image: postgres:12.4
#!/bin/bash
echo "Running tests in using test config 'docker-compose.test.yml'"
# Start containers
docker-compose -f 'docker-compose.test.yml' up -d
# Let postgres initialize
sleep 5
# Migrate and seed db
docker exec test-backend bash -c "yarn db:migrate"
docker exec test-backend bash -c "yarn db:seed;"
# Test backend
docker exec test-backend bash -c "yarn test:ci"
#Test frontend
docker exec test-backend bash -c "yarn --cwd frontend run test:ci"
wait
docker-compose \
-f 'docker-compose.test.yml' \
down --volumes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment