Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
chore: switch from poetry to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
monosans committed Oct 2, 2024
1 parent a0b1ef8 commit d2f93fc
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 1,414 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**
!nitro_generator_checker/**/*.py
!poetry.lock
!pyproject.toml
!uv.lock
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ jobs:
attestations: write
steps:
- uses: actions/checkout@v4
- run: pipx install poetry
- uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: poetry
check-latest: true
- run: poetry install --only=main,nuitka --sync --no-root --extras=non-termux --no-interaction
- run: poetry run --no-interaction python -m nuitka --standalone --python-flag='-m' --assume-yes-for-downloads nitro_generator_checker
- run: uv run --extra non-termux --extra nuitka --no-dev --frozen --python 3.12 python -m nuitka --standalone --python-flag='-m' --assume-yes-for-downloads --lto=yes nitro_generator_checker
- run: mv config.toml nitro_generator_checker.dist/
- if: ${{ github.event_name != 'pull_request' }}
uses: actions/attest-build-provenance@v1
Expand Down
46 changes: 15 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# hadolint global ignore=DL3008,DL3013,DL4006
FROM docker.io/python:3.12-slim-bookworm AS python-base-stage

ENV \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_COLOR=1 \
PIP_NO_INPUT=1 \
PIP_PROGRESS_BAR=off \
PIP_ROOT_USER_ACTION=ignore \
PIP_UPGRADE=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1

Expand All @@ -16,50 +9,41 @@ WORKDIR /app

FROM python-base-stage AS python-build-stage

ENV \
POETRY_NO_ANSI=1 \
POETRY_NO_CACHE=1 \
POETRY_NO_INTERACTION=1

RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*

RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked \
pip install poetry poetry-plugin-export

COPY ./poetry.lock ./pyproject.toml ./
ENV \
UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy

RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked \
poetry export --without-hashes --only=main --extras=non-termux | \
pip wheel --wheel-dir /usr/src/app/wheels -r /dev/stdin
RUN --mount=from=ghcr.io/astral-sh/uv,source=/uv,target=/bin/uv \
--mount=type=cache,target=/root/.cache/uv,sharing=locked \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
--mount=type=bind,source=uv.lock,target=uv.lock \
uv sync --extra non-termux --no-dev --no-install-project --frozen


FROM python-base-stage AS python-run-stage

RUN apt-get update \
&& apt-get install -y --no-install-recommends tini \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/* \
&& groupadd --gid 1000 app \
&& useradd --gid 1000 --no-log-init --uid 1000 app

COPY --from=python-build-stage /usr/src/app/wheels /wheels/
COPY --chown=app:app --from=python-build-stage /app/.venv /app/.venv

RUN pip install --no-index --find-links /wheels/ /wheels/* \
&& rm -rf /wheels/

ARG GID UID

# hadolint ignore=SC3028
RUN groupadd --gid "${GID}" --system app \
&& useradd --gid app --no-log-init --system --uid "${UID}" app
ENV PATH="/app/.venv/bin:$PATH"

ENV IS_DOCKER=1

COPY . .

USER app

COPY --chown=app:app . .

ENTRYPOINT ["tini", "--"]

CMD ["python", "-m", "nitro_generator_checker"]
6 changes: 1 addition & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
services:
app:
image: nitro_generator_checker
build:
context: .
args:
- GID=${GID:-1000}
- UID=${UID:-1000}
build: .
tty: true
volumes:
- ./config.toml:/app/config.toml
Expand Down
Loading

0 comments on commit d2f93fc

Please sign in to comment.