diff --git a/backend/Dockerfile.test b/backend/Dockerfile.test new file mode 100644 index 00000000..46b7ac47 --- /dev/null +++ b/backend/Dockerfile.test @@ -0,0 +1,21 @@ +FROM python:3.9-slim + +# Set the working directory +WORKDIR /app + +# Copy the application code into the container +COPY . /app + +# Install dependencies +RUN apt-get update +RUN apt-get install -y --no-install-recommends python3-pip +RUN pip3 install --no-cache-dir -r requirements.txt -r dev-requirements.txt + +# Set environment variables +ENV POSTGRES_USER=test_user +ENV POSTGRES_PASSWORD=test_password +ENV POSTGRES_DB=test_database +ENV POSTGRES_HOST=postgres + +# Command to run the tests +CMD ["pytest"] \ No newline at end of file diff --git a/backend/tests.yaml b/backend/tests.yaml new file mode 100644 index 00000000..9a4bb115 --- /dev/null +++ b/backend/tests.yaml @@ -0,0 +1,21 @@ +version: '3.8' + +services: + postgres: + image: postgres:latest + environment: + POSTGRES_USER: test_user + POSTGRES_PASSWORD: test_password + POSTGRES_DB: test_database + + test-runner: + build: + context: . + dockerfile: Dockerfile.test + depends_on: + - postgres + environment: + POSTGRES_HOST: postgres # Use the service name defined in Docker Compose + volumes: + - .:/app + command: ["pytest"] \ No newline at end of file