diff --git a/{{cookiecutter.project_slug}}/.env b/{{cookiecutter.project_slug}}/.env index 231d2adcbf..95fc3abfcd 100644 --- a/{{cookiecutter.project_slug}}/.env +++ b/{{cookiecutter.project_slug}}/.env @@ -1,5 +1,5 @@ COMPOSE_PATH_SEPARATOR=: -COMPOSE_FILE=docker-compose.test.yml:docker-compose.shared.admin.yml:docker-compose.shared.base-images.yml:docker-compose.shared.depends.yml:docker-compose.shared.env.yml:docker-compose.dev.build.yml:docker-compose.dev.command.yml:docker-compose.dev.env.yml:docker-compose.dev.labels.yml:docker-compose.dev.networks.yml:docker-compose.dev.ports.yml:docker-compose.dev.volumes.yml +COMPOSE_FILE=docker-compose.shared.admin.yml:docker-compose.shared.base-images.yml:docker-compose.shared.depends.yml:docker-compose.shared.env.yml:docker-compose.dev.build.yml:docker-compose.dev.command.yml:docker-compose.dev.env.yml:docker-compose.dev.labels.yml:docker-compose.dev.networks.yml:docker-compose.dev.ports.yml:docker-compose.dev.volumes.yml DOMAIN=localhost # DOMAIN=local.dockertoolbox.tiangolo.com diff --git a/{{cookiecutter.project_slug}}/backend/app/tests-start.sh b/{{cookiecutter.project_slug}}/backend/app/tests-start.sh index a500dfb2e5..a3ee2fd863 100644 --- a/{{cookiecutter.project_slug}}/backend/app/tests-start.sh +++ b/{{cookiecutter.project_slug}}/backend/app/tests-start.sh @@ -3,4 +3,4 @@ set -e python /app/app/tests_pre_start.py -pytest $* /app/app/tests/ +pytest "$@" /app/app/tests/ diff --git a/{{cookiecutter.project_slug}}/backend/tests.dockerfile b/{{cookiecutter.project_slug}}/backend/tests.dockerfile deleted file mode 100644 index 46c6661cd0..0000000000 --- a/{{cookiecutter.project_slug}}/backend/tests.dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -FROM python:3.7 - -WORKDIR /app/ - -# Install Poetry -RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \ - cd /usr/local/bin && \ - ln -s /opt/poetry/bin/poetry && \ - poetry config virtualenvs.create false - -# Copy poetry.lock* in case it doesn't exist in the repo -COPY ./app/pyproject.toml ./app/poetry.lock* /app/ -RUN poetry install --no-dev --no-root - -# For development, Jupyter remote kernel, Hydrogen -# Using inside the container: -# jupyter lab --ip=0.0.0.0 --allow-root --NotebookApp.custom_display_url=http://127.0.0.1:8888 -ARG env=prod -RUN bash -c "if [ $env == 'dev' ] ; then pip install jupyterlab ; fi" -EXPOSE 8888 - -COPY ./app /app - -ENV PYTHONPATH=/app - -COPY ./app/tests-start.sh /tests-start.sh - -RUN chmod +x /tests-start.sh - -# This will make the container wait, doing nothing, but alive -CMD ["bash", "-c", "while true; do sleep 1; done"] - -# Afterwards you can exec a command /tests-start.sh in the live container, like: -# docker exec -it backend-tests /tests-start.sh diff --git a/{{cookiecutter.project_slug}}/docker-compose.dev.build.yml b/{{cookiecutter.project_slug}}/docker-compose.dev.build.yml index 6f06338c21..20c45cd030 100644 --- a/{{cookiecutter.project_slug}}/docker-compose.dev.build.yml +++ b/{{cookiecutter.project_slug}}/docker-compose.dev.build.yml @@ -12,12 +12,6 @@ services: dockerfile: celeryworker.dockerfile args: env: dev - backend-tests: - build: - context: ./backend - dockerfile: tests.dockerfile - args: - env: dev frontend: build: context: ./frontend diff --git a/{{cookiecutter.project_slug}}/docker-compose.dev.env.yml b/{{cookiecutter.project_slug}}/docker-compose.dev.env.yml index 3748481df0..78681312b1 100644 --- a/{{cookiecutter.project_slug}}/docker-compose.dev.env.yml +++ b/{{cookiecutter.project_slug}}/docker-compose.dev.env.yml @@ -9,7 +9,3 @@ services: - RUN=celery worker -A app.worker -l info -Q main-queue -c 1 - JUPYTER=jupyter lab --ip=0.0.0.0 --allow-root --NotebookApp.custom_display_url=http://127.0.0.1:8888 - SERVER_HOST=http://${DOMAIN} - backend-tests: - environment: - - JUPYTER=jupyter lab --ip=0.0.0.0 --allow-root --NotebookApp.custom_display_url=http://127.0.0.1:8888 - - SERVER_HOST=http://${DOMAIN} diff --git a/{{cookiecutter.project_slug}}/docker-compose.dev.volumes.yml b/{{cookiecutter.project_slug}}/docker-compose.dev.volumes.yml index 97564960b3..f332614096 100644 --- a/{{cookiecutter.project_slug}}/docker-compose.dev.volumes.yml +++ b/{{cookiecutter.project_slug}}/docker-compose.dev.volumes.yml @@ -6,6 +6,3 @@ services: celeryworker: volumes: - ./backend/app:/app - backend-tests: - volumes: - - ./backend/app:/app diff --git a/{{cookiecutter.project_slug}}/docker-compose.shared.env.yml b/{{cookiecutter.project_slug}}/docker-compose.shared.env.yml index e7d6e1c32f..bd970e548e 100644 --- a/{{cookiecutter.project_slug}}/docker-compose.shared.env.yml +++ b/{{cookiecutter.project_slug}}/docker-compose.shared.env.yml @@ -11,9 +11,13 @@ services: environment: - SERVER_NAME=${DOMAIN} - SERVER_HOST=https://${DOMAIN} + # Allow explicit env var override for tests + - SMTP_HOST=${SMTP_HOST} celeryworker: env_file: - .env environment: - SERVER_NAME=${DOMAIN} - SERVER_HOST=https://${DOMAIN} + # Allow explicit env var override for tests + - SMTP_HOST=${SMTP_HOST} diff --git a/{{cookiecutter.project_slug}}/docker-compose.test.yml b/{{cookiecutter.project_slug}}/docker-compose.test.yml deleted file mode 100644 index df874e53e2..0000000000 --- a/{{cookiecutter.project_slug}}/docker-compose.test.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: '3.3' -services: - backend-tests: - build: - context: ./backend - dockerfile: tests.dockerfile - command: bash -c "while true; do sleep 1; done" - env_file: - - .env - environment: - - SERVER_NAME=backend - - SERVER_HOST=http://${DOMAIN} - backend: - environment: - # Don't send emails during testing - - SMTP_HOST= diff --git a/{{cookiecutter.project_slug}}/scripts/test-local.sh b/{{cookiecutter.project_slug}}/scripts/test-local.sh index 221d15a12f..da69063961 100644 --- a/{{cookiecutter.project_slug}}/scripts/test-local.sh +++ b/{{cookiecutter.project_slug}}/scripts/test-local.sh @@ -9,7 +9,6 @@ if [ $(uname -s) = "Linux" ]; then fi docker-compose \ - -f docker-compose.test.yml \ -f docker-compose.shared.admin.yml \ -f docker-compose.shared.base-images.yml \ -f docker-compose.shared.depends.yml \ diff --git a/{{cookiecutter.project_slug}}/scripts/test.sh b/{{cookiecutter.project_slug}}/scripts/test.sh index c226f73891..305b5015b5 100644 --- a/{{cookiecutter.project_slug}}/scripts/test.sh +++ b/{{cookiecutter.project_slug}}/scripts/test.sh @@ -3,17 +3,16 @@ # Exit in case of error set -e -DOMAIN=backend \ +DOMAIN=backend SMTP_HOST="" \ docker-compose \ -f docker-compose.shared.base-images.yml \ -f docker-compose.shared.env.yml \ -f docker-compose.shared.depends.yml \ -f docker-compose.deploy.build.yml \ --f docker-compose.test.yml \ config > docker-stack.yml docker-compose -f docker-stack.yml build docker-compose -f docker-stack.yml down -v --remove-orphans # Remove possibly previous broken stacks left hanging after an error docker-compose -f docker-stack.yml up -d -docker-compose -f docker-stack.yml exec -T backend-tests /tests-start.sh "$@" +docker-compose -f docker-stack.yml exec -T backend bash /app/tests-start.sh "$@" docker-compose -f docker-stack.yml down -v --remove-orphans