Skip to content

Commit a23526f

Browse files
committed
Docker support
- Use Python 3.13 - Update Dockerfile to use uv - Update docker targets in Makefile
1 parent 156d14b commit a23526f

File tree

4 files changed

+22
-38
lines changed

4 files changed

+22
-38
lines changed

.gitignore

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ coverage.xml
5050
*.py,cover
5151
.hypothesis/
5252
.pytest_cache/
53+
.ruff_cache/
5354

5455
# Translations
5556
*.mo
@@ -65,39 +66,16 @@ db.sqlite3-journal
6566
instance/
6667
.webassets-cache
6768

68-
# Scrapy stuff:
69-
.scrapy
70-
7169
# Sphinx documentation
7270
docs/_build/
7371

74-
# PyBuilder
75-
target/
76-
7772
# Jupyter Notebook
7873
.ipynb_checkpoints
7974

8075
# IPython
8176
profile_default/
8277
ipython_config.py
8378

84-
# pyenv
85-
.python-version
86-
87-
# pipenv
88-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91-
# install all needed dependencies.
92-
#Pipfile.lock
93-
94-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95-
__pypackages__/
96-
97-
# Celery stuff
98-
celerybeat-schedule
99-
celerybeat.pid
100-
10179
# SageMath parsed files
10280
*.sage.py
10381

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

Dockerfile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
FROM python:3.11-slim-buster
1+
FROM python:3.13-slim-trixie
22

33
LABEL MAINTAINER="Pradeep Bashyal"
44

5-
WORKDIR /app
6-
7-
COPY requirements.txt /app
8-
RUN pip install --no-cache-dir --upgrade pip && \
9-
pip install --no-cache-dir -r requirements.txt
5+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
106

11-
COPY requirements-deploy.txt /app
12-
RUN pip install --no-cache-dir -r requirements-deploy.txt
7+
WORKDIR /app
138

149
COPY app.py /app/
1510
COPY api.py /app/
1611
COPY api-spec.yaml /app/
1712
COPY my_project_template /app/my_project_template
1813

19-
CMD ["gunicorn" , "--bind", "0.0.0.0:8080", "--worker-tmp-dir", "/dev/shm", "app:app"]
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
18+
19+
CMD [".venv/bin/gunicorn" , "--bind", "0.0.0.0:8080", "--worker-tmp-dir", "/dev/shm", "app:app"]

Makefile

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
PROJECT_NAME := $(shell basename `pwd`)
22
PACKAGE_NAME := my_project_template
3+
VERSION := 0.0.1
34

45
.PHONY: clean clean-test clean-pyc clean-build docs help test test-all
56
.DEFAULT_GOAL := help
@@ -53,7 +54,7 @@ clean-test: ## remove test and coverage artifacts
5354
rm -fr .pytest_cache
5455
rm -fr allure_report
5556

56-
lint: ## check style with flake8
57+
lint: ## check style with ruff
5758
uv tool run ruff check
5859

5960
behave: clean-test ## run the behave tests, generate and serve report
@@ -68,7 +69,7 @@ test: clean-test ## run all(BDD and unit) tests
6869
uv run behave
6970

7071
coverage: ## check code coverage quickly with the default Python
71-
coverage run --source my_project_template -m pytest
72+
coverage run --source $(PACKAGE_NAME) -m pytest
7273
coverage report -m
7374
coverage html
7475
$(BROWSER) htmlcov/index.html
@@ -78,19 +79,23 @@ dist: clean ## builds source and wheel package
7879
ls -l dist
7980

8081
docker-build: ## build a docker image for the service
81-
docker build -t my-project-template-service:0.0.1 .
82+
docker build -t $(PACKAGE_NAME):$(VERSION) .
8283

8384
docker: docker-build ## build a docker image and run the service
84-
docker run --name my-project-template -p 8080:8080 my-project-template-service:0.0.1
85+
docker run --name $(PACKAGE_NAME) -p 8080:8080 $(PACKAGE_NAME):$(VERSION)
8586

86-
install: clean ## install the package to the active Python's site-packages
87+
sync: clean ## install the package to the active Python's site-packages
8788
uv sync --all-groups
8889
pre-commit install
8990

91+
install: sync ## Sync pyproject.toml to .venv as well as install tools
92+
pre-commit install
93+
uv tool install bump-my-version
94+
9095
venv: ## creates a Python3 virtualenv environment in venv
9196
uv venv --prompt $(PROJECT_NAME)-venv
9297

9398
activate: ## activate a virtual environment. Run `make venv` before activating.
9499
@echo "====================================================================="
95100
@echo "To activate the new virtual environment, execute the following from your shell"
96-
@echo "source venv/bin/activate"
101+
@echo "source .venv/bin/activate"

0 commit comments

Comments
 (0)