Skip to content

Commit 490cd97

Browse files
authored
Merge pull request #7 from tuke307/app/dev
App/dev
2 parents a051e98 + ddd3920 commit 490cd97

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+4502
-1148
lines changed

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"recommendations": [
3-
"ms-python.black-formatter"
3+
"ms-python.black-formatter",
4+
"ameenahsanma.poetry-monorepo"
45
]
56
}

tree-disk-api/.dockerignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.git
2+
.github
3+
.dockerignore
4+
.gitignore
5+
6+
.idea
7+
.vscode
8+
9+
__pycache__/
10+
*.py[cod]
11+
*$py.class
12+
*.so
13+
htmlcov/
14+
.coverage
15+
.coverage.*
16+
.pytest_cache/
17+
.venv
18+
venv
19+
20+
.DS_Store
21+
.AppleDouble
22+
.LSOverride
23+
._*
24+
25+
.vscode
26+
.idea
27+
28+
Dockerfile
29+
README.md
30+
docker.compose.yml
31+
.env*
32+
33+
output/
34+
input/
35+
tests/

tree-disk-api/.env.sample

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GUNICORN_TIMEOUT=
2+
DEBUG=
3+
SAVE_RESULTS=

tree-disk-api/Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Stage 1: Build stage
2+
FROM python:3.12-slim as builder
3+
4+
ENV POETRY_VERSION=2.0.0
5+
ENV POETRY_VENV=/opt/poetry-venv
6+
ENV POETRY_CACHE_DIR=/opt/.cache
7+
ENV POETRY_VIRTUALENVS_IN_PROJECT=1
8+
9+
# Install build dependencies if needed (uncomment below)
10+
# RUN apt-get update && apt-get install -y --no-install-recommends \
11+
# gcc \
12+
# python3-dev \
13+
# && rm -rf /var/lib/apt/lists/*
14+
15+
# Install Poetry in isolated virtual environment
16+
RUN python -m venv $POETRY_VENV \
17+
&& $POETRY_VENV/bin/pip install --no-cache-dir poetry==$POETRY_VERSION
18+
19+
# Add Poetry to PATH
20+
ENV PATH="$POETRY_VENV/bin:$PATH"
21+
22+
WORKDIR /app
23+
24+
# Copy dependency specifications
25+
COPY pyproject.toml poetry.lock ./
26+
27+
# Install project dependencies (production only)
28+
RUN poetry install --no-root
29+
30+
# Stage 2: Runtime stage
31+
FROM python:3.12-slim
32+
33+
WORKDIR /app
34+
35+
# Copy virtual environment from builder
36+
COPY --from=builder /app/.venv .venv
37+
38+
# Copy application code
39+
COPY . .
40+
41+
# Activate virtual environment
42+
ENV PATH="/app/.venv/bin:$PATH"
43+
44+
EXPOSE 3100
45+
46+
CMD ["gunicorn", "main:app", "-c", "gunicorn.conf.py"]

tree-disk-api/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
## Installation
44
```bash
5+
poetry config virtualenvs.in-project true
56
poetry env use python
7+
```
8+
9+
```bash
610
poetry install
7-
poetry shell
11+
eval $(poetry env activate)
812
```
913

1014
## Usage Examples

tree-disk-api/gunicorn.conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import multiprocessing
2+
import os
23

34
pythonpath = "src"
45
bind = "0.0.0.0:3100"
56
workers = multiprocessing.cpu_count() # * 2 + 1
67
worker_class = "uvicorn.workers.UvicornWorker"
7-
timeout = 120
8+
timeout = os.environ.get("GUNICORN_TIMEOUT", 120)

0 commit comments

Comments
 (0)