Skip to content

Commit

Permalink
dockerized tests to host postgres server
Browse files Browse the repository at this point in the history
  • Loading branch information
AronBuzogany committed Feb 23, 2024
1 parent 35656a6 commit e8d0c5f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
21 changes: 21 additions & 0 deletions backend/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -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"]
21 changes: 21 additions & 0 deletions backend/tests.yaml
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit e8d0c5f

Please sign in to comment.