Skip to content

Commit 56cf1a7

Browse files
committed
Add Dockerfile and .dockerignore for containerization setup
1 parent d966bb8 commit 56cf1a7

3 files changed

Lines changed: 45 additions & 0 deletions

File tree

.dockerignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.git
2+
.github
3+
__pycache__
4+
*.pyc
5+
*.pyo
6+
*.pyd
7+
Python
8+
venv
9+
.env
10+
.env.*
11+
*.log
12+
*.tmp
13+
*.swp
14+
.DS_Store
15+
Thumbs.db
16+
.idea
17+
.vscode
18+
coverage
19+
build
20+
dist
21+
*.egg-info

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM python:3.11-slim
2+
3+
ENV PYTHONDONTWRITEBYTECODE=1
4+
ENV PYTHONUNBUFFERED=1
5+
6+
WORKDIR /app
7+
8+
RUN addgroup --system app && adduser --system --ingroup app app
9+
10+
COPY requirements.txt .
11+
12+
RUN pip install --no-cache-dir -r requirements.txt
13+
14+
COPY . .
15+
16+
RUN chown -R app:app /app
17+
18+
USER app
19+
20+
EXPOSE 8000
21+
22+
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health')"
23+
24+
CMD ["fastapi", "run", "main.py", "--host", "0.0.0.0", "--port", "8000"]

requirements.txt

1.58 KB
Binary file not shown.

0 commit comments

Comments
 (0)