Skip to content

Commit 6fccefb

Browse files
committed
Update dockerfile and project
1 parent 3685b50 commit 6fccefb

File tree

6 files changed

+49
-15
lines changed

6 files changed

+49
-15
lines changed

.bumpversion.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ setup_hooks = []
2020
pre_commit_hooks = []
2121
post_commit_hooks = []
2222

23-
2423
[[tool.bumpversion.files]]
25-
filename = "my_project_template/__init__.py"
24+
filename = "src/my_project_template/__init__.py"
2625
search = "__version__ = \"{current_version}\""
2726
replace = "__version__ = \"{new_version}\""
2827

@@ -35,3 +34,8 @@ replace = "version = \"{new_version}\""
3534
filename = "api-spec.yaml"
3635
search = "version: {current_version}"
3736
replace = "version: {new_version}"
37+
38+
[[tool.bumpversion.files]]
39+
filename = "Makefile"
40+
search = "VERSION := {current_version}"
41+
replace = "VERSION := {new_version}"

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.git
12
.github
23
.eggs/
34
build
@@ -6,9 +7,9 @@ dist
67
*.egg-info
78
tests
89
venv
10+
.venv
911

1012
__pycache__
11-
*.pyc
1213
*.pyo
1314
*.pyd
1415
*.output

Dockerfile

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,44 @@
1-
FROM python:3.13-slim-trixie
2-
1+
FROM python:3.13-slim-trixie AS builder
32
LABEL MAINTAINER="Pradeep Bashyal"
43

54
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
65

6+
ENV UV_COMPILE_BYTECODE=1
7+
ENV UV_LINK_MODE=copy
8+
ENV UV_PYTHON_PREFERENCE=only-managed
9+
710
WORKDIR /app
11+
# Install everything except the package
12+
RUN --mount=type=cache,target=/root/.cache/uv \
13+
--mount=type=bind,source=uv.lock,target=uv.lock \
14+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
15+
uv sync --locked --no-install-project --group deploy
16+
17+
# Sync so that Python version is installed
18+
COPY . /app
19+
RUN --mount=type=cache,target=/root/.cache/uv \
20+
uv sync --locked --group deploy && uv build
21+
22+
23+
# Final Docker Image
24+
FROM python:3.13-slim-trixie
25+
26+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
27+
28+
WORKDIR /app
29+
30+
# Copy the Python packages
31+
COPY --from=builder /app/.venv /app/.venv
32+
33+
COPY --from=builder /app/dist/my_project_template-0.0.1-py3-none-any.whl /tmp/
34+
RUN python3 -m pip install /tmp/my_project_template-0.0.1-py3-none-any.whl
835

936
COPY app.py /app/
1037
COPY api.py /app/
1138
COPY api-spec.yaml /app/
12-
COPY my_project_template /app/my_project_template
39+
COPY run-app.sh /app/
1340

14-
# Sync the project into a new environment, asserting the lockfile is up to date
15-
COPY pyproject.toml /app/
16-
COPY uv.lock /app/
17-
RUN /bin/uv sync --locked --group deploy
41+
# Put the uv built Python packages in the PATH
42+
ENV PYTHONPATH="/app/.venv/lib/python3.13/site-packages/:"
1843

19-
CMD [".venv/bin/gunicorn" , "--bind", "0.0.0.0:8080", "--worker-tmp-dir", "/dev/shm", "app:app"]
44+
CMD ["/app/run-app.sh"]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ lint: ## check style with ruff
5858
uv tool run ruff check
5959

6060
behave: clean-test ## run the behave tests, generate and serve report
61-
- uv run behave -f allure_behave.formatter:AllureFormatter -o allure_report
61+
uv run behave -f allure_behave.formatter:AllureFormatter -o allure_report
6262
allure serve allure_report
6363

6464
pytest: clean-test ## run tests quickly with the default Python

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
[build-system]
2+
requires = ["uv_build>=0.8.15,<0.9.0"]
3+
build-backend = "uv_build"
4+
15
[project]
2-
name = "nmdp-python-project-template"
6+
name = "my_project_template"
37
version = "0.0.1"
48
description="Python Project Template. Standardized Python project structure for NMDP projects"
59
requires-python = ">=3.13"

uv.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)