Skip to content

Commit 0f8246d

Browse files
committed
Update docker image build and dependencies
Why these changes are being introduced: As we continue to slowly build out this uv driven version of the CLI template, finding little things to update along the way. How this addresses that need: * Updated Dockerfile to use uv in image build * Add convenience docker methods in Makefile, unassociated with AWS ECR (helpful for local testing) * Update dependencies Side effects of this change: * None Relevant ticket(s): * None
1 parent a02b2b7 commit 0f8246d

File tree

7 files changed

+343
-199
lines changed

7 files changed

+343
-199
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
default_language_version:
2-
python: python3.13
2+
python: python3.12
33
repos:
44
- repo: local
55
hooks:
@@ -24,6 +24,6 @@ repos:
2424
types: ["python"]
2525
- id: pip-audit
2626
name: pip-audit
27-
entry: uv run pip-audit
27+
entry: uv run pip-audit --ignore-vuln GHSA-4xh5-x5gv-qwph
2828
language: system
2929
pass_filenames: false

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.13
1+
3.12

Dockerfile

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
FROM python:3.12-slim as build
1+
FROM python:3.13-slim
2+
3+
RUN apt-get update && \
4+
apt-get install -y --no-install-recommends git ca-certificates && \
5+
rm -rf /var/lib/apt/lists/*
6+
7+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
8+
ENV UV_SYSTEM_PYTHON=1
9+
210
WORKDIR /app
3-
COPY . .
411

5-
RUN pip install --no-cache-dir --upgrade pip pipenv
12+
# Copy project metadata
13+
COPY pyproject.toml uv.lock* ./
614

7-
RUN apt-get update && apt-get upgrade -y && apt-get install -y git
15+
# Copy CLI application
16+
COPY my_app ./my_app
817

9-
COPY Pipfile* /
10-
RUN pipenv install
18+
# Install package into system python, includes "marimo-launcher" script
19+
RUN uv pip install --system .
1120

12-
ENTRYPOINT ["pipenv", "run", "my_app"]
21+
ENTRYPOINT ["my-app"]

Makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ruff: # Run 'ruff' linter and print a preview of errors
5656
uv run ruff check .
5757

5858
safety: # Check for security vulnerabilities
59-
uv run pip-audit
59+
uv run pip-audit --ignore-vuln GHSA-4xh5-x5gv-qwph
6060

6161
lint-apply: black-apply ruff-apply # Apply changes with 'black' and resolve 'fixable errors' with 'ruff'
6262

@@ -70,4 +70,17 @@ ruff-apply: # Resolve 'fixable errors' with 'ruff'
7070
# CLI convenience commands
7171
##############################
7272
my-app: # CLI without any arguments, utilizing uv script entrypoint
73-
uv run my-app
73+
uv run my-app
74+
75+
76+
####################################
77+
# Docker
78+
####################################
79+
docker-build: # Build local image for testing
80+
docker build -t python-cli-template:latest .
81+
82+
docker-shell: # Shell into local container for testing
83+
docker run -it --entrypoint='bash' python-cli-template:latest
84+
85+
docker-run: # Run main entrypoint + command without arguments
86+
docker run python-cli-template:latest

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A template repository for creating Python CLI applications.
44

55
## App Setup (delete this section and above after initial application setup)
66

7-
1. Rename "my_app" to the desired app name across the repo. (May be helpful to do a project-wide find-and-replace).
7+
1. Rename "my_app" and "python-cli-template" to the desired app name across the repo. (May be helpful to do a project-wide find-and-replace).
88
2. Update Python version if needed.
99
3. Install all dependencies with `make install` to create initial Pipfile.lock with latest dependency versions.
1010
4. Add initial app description to README and update initial required ENV variable documentation as needed.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[project]
66
name = "python-cli-template"
77
version = "2.0.0"
8-
requires-python = ">=3.13"
8+
requires-python = ">=3.12"
99

1010
dependencies = [
1111
"click>=8.2.1",
@@ -35,7 +35,7 @@ exclude = ["tests/"]
3535
log_level = "INFO"
3636

3737
[tool.ruff]
38-
target-version = "py313"
38+
target-version = "py312"
3939

4040
# set max line length
4141
line-length = 90

uv.lock

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

0 commit comments

Comments
 (0)