-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dockerized tests to host postgres server
- Loading branch information
1 parent
35656a6
commit e8d0c5f
Showing
2 changed files
with
42 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,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"] |
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,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"] |