Skip to content

Commit 6959cbc

Browse files
committed
chore: replace poetry with uv
- upgrade python to 3.13 - upgrade other packages
1 parent 23cfcc4 commit 6959cbc

7 files changed

Lines changed: 1263 additions & 2534 deletions

File tree

.github/workflows/linting.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,26 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@main
17-
- name: Install poetry
18-
run: pipx install poetry
19-
- uses: actions/setup-python@main
17+
18+
- uses: actions/setup-python@v5
19+
with:
20+
python-version-file: '.python-version'
21+
22+
- uses: astral-sh/setup-uv@v5
23+
with:
24+
enable-cache: true
25+
26+
- uses: awalsh128/cache-apt-pkgs-action@latest
2027
with:
21-
cache: 'poetry'
22-
- run: poetry install
28+
packages: gdal-bin libgdal-dev
29+
30+
- name: Setup uv python environment
31+
run: uv venv
32+
33+
- name: uv lock check
34+
run: uv lock --locked --offline
35+
36+
- name: uv sync
37+
run: uv sync --all-extras
38+
2339
- uses: pre-commit/action@main

.python-version

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

Dockerfile

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,32 @@
1-
FROM python:3.8-slim-buster
1+
FROM python:3.13-slim-bookworm AS base
2+
COPY --from=ghcr.io/astral-sh/uv:0.7.4 /uv /uvx /bin/
23

34
LABEL maintainer="IFRC"
45
LABEL org.opencontainers.image.source="https://github.com/IFRCGo/go-risk-module-api"
56

67
ENV PYTHONUNBUFFERED=1
78

9+
ENV UV_COMPILE_BYTECODE=1
10+
ENV UV_LINK_MODE=copy
11+
ENV UV_PROJECT_ENVIRONMENT="/usr/local/"
12+
813
WORKDIR /code
914

10-
RUN apt-get -y update \
15+
RUN --mount=type=cache,target=/root/.cache/uv \
16+
--mount=type=bind,source=uv.lock,target=uv.lock \
17+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
18+
apt-get update -y \
1119
&& apt-get install -y --no-install-recommends \
12-
git \
13-
g++ \
14-
curl \
15-
wait-for-it \
16-
gdal-bin \
17-
libgdal-dev
18-
19-
20-
ARG CPLUS_INCLUDE_PATH=/usr/include/gdal
21-
ARG C_INCLUDE_PATH=/usr/include/gdal
22-
RUN pip install GDAL==2.4.0
23-
24-
COPY pyproject.toml poetry.lock /code/
25-
26-
# Upgrade pip and install python packages for code
27-
RUN pip install --upgrade --no-cache-dir pip poetry \
28-
&& poetry --version \
29-
# Configure to use system instead of virtualenvs
30-
&& poetry config virtualenvs.create false \
31-
&& poetry install --no-root \
32-
# Remove installer
33-
&& pip uninstall -y poetry virtualenv-clone virtualenv
20+
# Build required packages
21+
gdal-bin build-essential gcc g++ libc-dev libgdal-dev libproj-dev \
22+
# Helper packages
23+
git curl wait-for-it procps \
24+
&& uv lock --locked --offline \
25+
&& uv sync --frozen --no-install-project --all-groups \
26+
# Clean-up
27+
&& apt-get remove -y build-essential gcc g++ libc-dev libgdal-dev libproj-dev \
28+
&& apt-get autoremove -y \
29+
&& rm -rf /var/lib/apt/lists/*
3430

3531

3632
COPY . /code/

0 commit comments

Comments
 (0)