-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created docker compose scripts to easily run py.test
- Loading branch information
1 parent
6e76521
commit a9c8d35
Showing
6 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM python:2.7 | ||
|
||
WORKDIR /app | ||
|
||
COPY requirements.txt /app | ||
COPY dev-requirements.txt /app | ||
|
||
RUN pip install --upgrade setuptools && \ | ||
pip install --upgrade pip && \ | ||
pip install -r requirements.txt && \ | ||
pip install -r dev-requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
version: '3.1' | ||
services: | ||
pytest_citation_capture_pipeline: | ||
build: . | ||
image: pytest_citation_capture_pipeline:latest | ||
container_name: pytest_citation_capture_pipeline | ||
volumes: | ||
- ./:/app | ||
networks: | ||
- pytest_citation_capture_pipeline | ||
stdin_open: true | ||
tty: true | ||
entrypoint: scripts/support/pytest.sh | ||
#entrypoint: bash | ||
depends_on: | ||
- pytest_citation_capture_db | ||
environment: | ||
- SQLALCHEMY_URL='postgres://citation_capture_pipeline:citation_capture_pipeline@pytest_citation_capture_db:5432/citation_capture_pipeline' | ||
# When 'True', no events are emitted to the broker via the webhook | ||
- TESTING_MODE=True | ||
# When 'True', it converts all the asynchronous calls into synchronous, | ||
# thus no need for rabbitmq, it does not forward to master | ||
# and it allows debuggers to run if needed: | ||
- CELERY_ALWAYS_EAGER=True | ||
- CELERY_EAGER_PROPAGATES_EXCEPTIONS=True | ||
pytest_citation_capture_db: | ||
container_name: pytest_citation_capture_db | ||
image: postgres:9.6 | ||
restart: always | ||
environment: | ||
- POSTGRES_USER=postgres | ||
- POSTGRES_PASSWORD=postgres | ||
- POSTGRES_DB=postgres | ||
volumes: | ||
- ./scripts/support/init-db.sh:/docker-entrypoint-initdb.d/initdb.sh | ||
networks: | ||
- pytest_citation_capture_pipeline | ||
networks: | ||
pytest_citation_capture_pipeline: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
set -x | ||
docker-compose rm -fsv | ||
docker rmi pytest_citation_capture_pipeline:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
set -x | ||
docker-compose up --force-recreate --abort-on-container-exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
psql "postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DB?sslmode=disable" <<-EOSQL | ||
CREATE USER citation_capture_pipeline WITH ENCRYPTED PASSWORD 'citation_capture_pipeline'; | ||
CREATE DATABASE citation_capture_pipeline; | ||
CREATE DATABASE citation_capture_pipeline_test; | ||
GRANT ALL PRIVILEGES ON DATABASE citation_capture_pipeline TO citation_capture_pipeline; | ||
GRANT ALL PRIVILEGES ON DATABASE citation_capture_pipeline_test TO citation_capture_pipeline; | ||
EOSQL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
USER=root | ||
GROUP=root | ||
|
||
cd /app | ||
if [ -e alembic.ini ]; then | ||
if [ "${DISABLE_ALEMBIC_UPGRADE}" != True ] && [ "${DISABLE_ALEMBIC_UPGRADE}" != true ]; then | ||
su -s /bin/bash -c "mkdir -p alembic/versions/" -g ${GROUP} ${USER} | ||
su -s /bin/bash -c "alembic -c ./alembic.ini upgrade head" -g ${GROUP} ${USER} | ||
fi | ||
fi | ||
|
||
py.test | ||
|
||
echo "For interactive access, run in a diferent terminal:" | ||
echo " docker exec -it pytest_citation_capture_pipeline bash" | ||
echo "Press CTRL+c to stop" | ||
tail -f /dev/null |