Skip to content

Commit

Permalink
feat: add basic setup for running tests from within docker-compose.yml.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhiiva committed Nov 12, 2021
1 parent 5d9fb2e commit 7d72267
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
52 changes: 52 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# docker-compose setup for a development environment.
# To use this file, populate config-docker.env with the following:
#
# MYSQL_PASSWORD - a password for the mysql user
# MYSQL_ROOT_PASSWORD - a password for the mysql *root* user
#
# Then you can run:
# - docker-compose build
# - docker-compose up

version: '3.5'

services:
app:
build: ./
restart: always
environment:
DB_HOST: db
DB_PORT: 3306
APP_DB_NAME: agagd
AGAGD_USER: agagd
MYSQL_PASSWORD: "${MYSQL_PASSWORD}"
SECRET_KEY: insecure-key-for-testing
DEBUG: "true"
LOAD_FIXTURES: "false"
volumes:
- ./agagd/agagd:/srv/agagd
- ./agagd/agagd_core:/srv/agagd_core
- ./agagd/media:/srv/media
- ./agagd/static:/srv/static
- ./agagd/jinja2:/srv/jinja2
- ./agagd/templates:/srv/templates
depends_on:
- "db"
db:
build:
context: ./
dockerfile: Dockerfile.mysql
restart: always
volumes:
- database:/var/lib/mysql
environment:
# This is safer than it looks, since without a 'ports' section, docker-compose
# isolates this app to a network local to this compose file.
MYSQL_ROOT_HOST: "%"
MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}"
MYSQL_USER: agagd
MYSQL_DATABASE: test_agagd
MYSQL_PASSWORD: "${MYSQL_PASSWORD}"

volumes:
database:
4 changes: 3 additions & 1 deletion scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ function wait_for_db() {
exit 1
}

wait_for_db
if [ "$3" != "test" ]; then
wait_for_db
fi

if $LOAD_FIXTURES == "true"; then
python make_fake_fixtures.py 1000 1000 1000 > /tmp/fake_agagd_data.json
Expand Down

0 comments on commit 7d72267

Please sign in to comment.