Skip to content

Commit b453e3c

Browse files
committed
migrate uv
1 parent 9dcb883 commit b453e3c

File tree

6 files changed

+1438
-2027
lines changed

6 files changed

+1438
-2027
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ repos:
7171
hooks:
7272
- id: biome-check
7373

74-
- repo: https://github.com/hadolint/hadolint
75-
rev: v2.12.0
76-
hooks:
77-
- id: hadolint-docker
78-
7974
- repo: https://github.com/markdownlint/markdownlint
8075
rev: v0.13.0
8176
hooks:

Dockerfile

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,33 +33,32 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
3333
curl \
3434
&& rm -rf /var/lib/apt/lists/*
3535

36-
ENV PYTHONDONTWRITEBYTECODE=1 \
37-
PIP_DISABLE_PIP_VERSION_CHECK=1 \
36+
ARG PIP_DISABLE_PIP_VERSION_CHECK=1 \
37+
PIP_NO_CACHE_DIR=0 \
3838
PIP_NO_COMPILE=0 \
3939
PIP_NO_INPUT=1 \
40-
POETRY_NO_INTERACTION=1
40+
PYTHONDONTWRITEBYTECODE=1 \
41+
UV_NO_CACHE=1
4142

4243
# set up python
43-
RUN --mount=type=cache,target=/root/.cache/pip \
44-
pip install poetry && \
45-
python -m venv --upgrade-deps ${VIRTUAL_ENV} && \
44+
COPY --from=ghcr.io/astral-sh/uv:0.5.29 /uv /uvx /bin/
45+
COPY --chown=${USER}:${USER} pyproject.toml uv.lock ./
46+
RUN --mount=type=cache,target=/root/.cache/uv \
47+
uv venv --seed ${VIRTUAL_ENV} && \
48+
uv sync --frozen --no-default-groups --no-install-project && \
4649
chown -R ${USER}:${USER} ${VIRTUAL_ENV} && \
47-
chown -R ${USER}:${USER} ${APP_HOME}
48-
COPY --chown=${USER}:${USER} pyproject.toml poetry.lock ./
49-
RUN --mount=type=cache,target=/root/.cache/pypoetry \
50-
poetry install --only main --no-root && \
51-
python --version && \
52-
pip list
50+
chown -R ${USER}:${USER} ${APP_HOME} && \
51+
uv pip list
5352

5453
# set up project
55-
USER ${USER}
5654
COPY --chown=${USER}:${USER} src src
57-
RUN --mount=type=cache,target=/root/.cache/pypoetry \
58-
poetry install --only-root
55+
RUN --mount=type=cache,target=/root/.cache/uv \
56+
uv sync --frozen --no-default-groups
5957

6058
EXPOSE 8000
6159
ARG ENVIRONMENT=dev
6260
ENV ENVIRONMENT=${ENVIRONMENT}
61+
USER ${USER}
6362
CMD ["gunicorn", "-c", "python:example_app.gunicorn_conf", "--reload"]
6463

6564
##
@@ -68,9 +67,10 @@ CMD ["gunicorn", "-c", "python:example_app.gunicorn_conf", "--reload"]
6867
FROM dev AS ci
6968

7069
USER root
71-
RUN --mount=type=cache,target=/root/.cache/pypoetry \
72-
poetry install && \
73-
pip list
70+
RUN --mount=type=cache,target=/root/.cache/uv \
71+
uv sync --frozen && \
72+
chown -R ${USER}:${USER} ${VIRTUAL_ENV} && \
73+
uv pip list
7474

7575
USER ${USER}
7676
COPY --chown=${USER}:${USER} tests tests

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# python-example-app
2+
23
Python example app incorporating best practices

0 commit comments

Comments
 (0)