Skip to content

Commit 50673a8

Browse files
feat: add Dockerfile and docker-compose configuration for containerization
1 parent ab260b3 commit 50673a8

3 files changed

Lines changed: 63 additions & 0 deletions

File tree

‎.dockerignore‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.venv
2+
__pycache__
3+
*.pyc
4+
.git
5+
.gitignore
6+
.env
7+
.pytest_cache
8+
.DS_Store
9+
README.md
10+
.github
11+
tests
12+
alembic/versions/__pycache__

‎Dockerfile‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM python:3.12-slim
2+
3+
WORKDIR /app
4+
5+
RUN apt-get update && apt-get install -y --no-install-recommends \
6+
gcc \
7+
libpq-dev \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
COPY requirements.txt .
11+
RUN pip install --no-cache-dir -r requirements.txt
12+
13+
COPY app/ ./app/
14+
COPY alembic/ ./alembic/
15+
COPY alembic.ini .
16+
17+
EXPOSE 8000
18+
19+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

‎docker-compose.yml‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
services:
2+
db:
3+
image: postgres:16
4+
environment:
5+
POSTGRES_USER: gatekeeper_app
6+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
7+
POSTGRES_DB: gatekeeper
8+
volumes:
9+
- postgres_data:/var/lib/postgresql/data
10+
ports:
11+
- "5432:5432"
12+
healthcheck:
13+
test: ["CMD-SHELL", "pg_isready -U gatekeeper_app -d gatekeeper"]
14+
interval: 5s
15+
timeout: 5s
16+
retries: 5
17+
18+
app:
19+
build: .
20+
depends_on:
21+
db:
22+
condition: service_healthy
23+
environment:
24+
DATABASE_URL: postgresql://gatekeeper_app:${POSTGRES_PASSWORD}@db:5432/gatekeeper
25+
TEST_DATABASE_URL: postgresql://gatekeeper_app:${POSTGRES_PASSWORD}@db:5432/gatekeeper_test
26+
ports:
27+
- "8000:8000"
28+
command: >
29+
sh -c "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8000"
30+
31+
volumes:
32+
postgres_data:

0 commit comments

Comments
 (0)