diff --git a/Dockerfile.test b/Dockerfile.test new file mode 100644 index 0000000..22db476 --- /dev/null +++ b/Dockerfile.test @@ -0,0 +1,17 @@ +FROM python:3.11-slim +ARG APP_VERSION=dev +ENV APP_VERSION=${APP_VERSION} +ENV APP_NAME=modal_backend +ENV APP_MODULE=${APP_NAME}.routes.base:app + +COPY ./requirements.txt ./requirements.dev.txt /${APP_NAME}/ +WORKDIR /${APP_NAME}/ +RUN ["/bin/sh", "-c", "pip install -U -r requirements.txt -r requirements.dev.txt"] +CMD ["-l", "-v"] +ENTRYPOINT ["pytest"] + +COPY ./pyproject.toml /${APP_NAME}/ +COPY ./alembic.ini /${APP_NAME}/ +COPY ./migrations /${APP_NAME}/migrations +COPY ./${APP_NAME} /${APP_NAME}/${APP_NAME} +COPY ./tests /${APP_NAME}/tests/ diff --git a/Makefile b/Makefile index 1284cce..04978c3 100644 --- a/Makefile +++ b/Makefile @@ -23,3 +23,32 @@ db: migrate: source ./venv/bin/activate && alembic upgrade head + +pytest-container-build: + docker build -f Dockerfile.test -t pytest-container . + +pytest-container-run: + docker run -it \ + -v /var/run/docker.sock:/var/run/docker.sock \ + --rm \ + --add-host host.docker.internal:host-gateway \ + -e TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal \ + --network host \ + pytest-container \ + $(ARGS) + +pytest-rerun: + docker build -f Dockerfile.test -t pytest-container . \ + && \ + docker run -it \ + -v /var/run/docker.sock:/var/run/docker.sock \ + --rm \ + --add-host host.docker.internal:host-gateway \ + -e TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal \ + --network host \ + pytest-container \ + $(ARGS) + + + +