Skip to content

Commit 8d71753

Browse files
authored
Merge branch 'main' into insert_readme_first
2 parents 5cfe85f + fe02f66 commit 8d71753

File tree

3 files changed

+102
-5
lines changed

3 files changed

+102
-5
lines changed

.dockerignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Git
2+
.git
3+
.gitignore
4+
5+
# Python
6+
__pycache__
7+
*.pyc
8+
*.pyo
9+
*.pyd
10+
.Python
11+
env
12+
pip-log.txt
13+
pip-delete-this-directory.txt
14+
.tox
15+
.coverage
16+
.coverage.*
17+
.cache
18+
nosetests.xml
19+
coverage.xml
20+
*.cover
21+
*.log
22+
23+
# Virtual environment
24+
venv
25+
.env
26+
.venv
27+
ENV
28+
29+
# IDE
30+
.idea
31+
.vscode
32+
*.swp
33+
*.swo
34+
35+
# Project specific
36+
docs/
37+
tests/
38+
*.md
39+
LICENSE
40+
pytest.ini
41+
setup.py

.github/workflows/unitest.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.8", "3.9", "3.10", "3.11"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install pytest pytest-asyncio
28+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
29+
pip install -e .
30+
31+
- name: Run tests
32+
run: |
33+
pytest

Dockerfile

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
1-
FROM python:3.12
1+
# Build stage
2+
FROM python:3.12-slim AS builder
3+
4+
WORKDIR /build
5+
6+
# Copy requirements first to leverage Docker cache
7+
COPY requirements.txt .
8+
9+
# Install build dependencies and Python packages
10+
RUN apt-get update \
11+
&& apt-get install -y --no-install-recommends gcc python3-dev \
12+
&& pip install --no-cache-dir --upgrade pip \
13+
&& pip install --no-cache-dir --timeout 1000 -r requirements.txt \
14+
&& rm -rf /var/lib/apt/lists/*
15+
16+
# Runtime stage
17+
FROM python:3.12-slim
18+
19+
# Set Python environment variables
20+
ENV PYTHONUNBUFFERED=1
21+
ENV PYTHONDONTWRITEBYTECODE=1
22+
23+
# Install git
24+
RUN apt-get update \
25+
&& apt-get install -y --no-install-recommends git \
26+
&& rm -rf /var/lib/apt/lists/*
227

328
WORKDIR /app
429

530
# Create a non-root user
631
RUN useradd -m -u 1000 appuser
732

33+
COPY --from=builder /usr/local/lib/python3.12/site-packages/ /usr/local/lib/python3.12/site-packages/
834
COPY src/ ./
9-
COPY requirements.txt ./
10-
11-
RUN pip install -r requirements.txt
1235

1336
# Change ownership of the application files
1437
RUN chown -R appuser:appuser /app
@@ -18,4 +41,4 @@ USER appuser
1841

1942
EXPOSE 8000
2043

21-
CMD ["uvicorn", "main:app", "--reload", "--host", "0.0.0.0"]
44+
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

0 commit comments

Comments
 (0)