Skip to content

Commit 280a6cd

Browse files
committed
Replace poetry with uv
- Update README for uv - Update CI with uv
1 parent b0572d6 commit 280a6cd

File tree

9 files changed

+3253
-4728
lines changed

9 files changed

+3253
-4728
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ deploy/
55
go-logs/
66
media/
77
go.log
8+
.venv

.github/workflows/ci.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ jobs:
2727

2828
steps:
2929
- uses: actions/checkout@main
30-
- name: Install poetry
31-
run: pipx install poetry
32-
- uses: actions/setup-python@main
30+
- uses: astral-sh/setup-uv@v5
3331
with:
34-
cache: 'poetry'
35-
- run: poetry install --no-root
32+
enable-cache: true
33+
- name: Sync
34+
run: uv sync --all-extras
3635
- uses: pre-commit/action@main
3736

3837
test:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ project-imports/
4949
htmlcov
5050
country-key-documents/
5151
celerybeat-schedule
52+
.venv

Dockerfile

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
FROM python:3.11-bullseye
2+
COPY --from=ghcr.io/astral-sh/uv:0.6.2 /uv /uvx /bin/
23

4+
LABEL maintainer="GO Dev <[email protected]>"
35
LABEL org.opencontainers.image.source="https://github.com/IFRCGo/go-api"
46

57
ENV PYTHONUNBUFFERED=1
8+
9+
ENV UV_COMPILE_BYTECODE=1
10+
ENV UV_LINK_MODE=copy
11+
ENV UV_PROJECT_ENVIRONMENT="/usr/local/"
12+
ENV UV_CACHE_DIR="/root/.cache/uv"
13+
614
EXPOSE 80
715
EXPOSE 443
816

9-
RUN apt-get update && \
17+
RUN apt-get update -y && \
1018
apt-get install -y --no-install-recommends \
1119
# FIXME: Make sure all packages are used/required
1220
nginx mdbtools vim tidy less gettext \
@@ -19,17 +27,11 @@ RUN apt-get update && \
1927
ENV HOME=/home/ifrc
2028
WORKDIR $HOME
2129

22-
COPY pyproject.toml poetry.lock $HOME/
23-
2430
# Upgrade pip and install python packages for code
25-
RUN pip install --upgrade --no-cache-dir pip "poetry>=2.1,<2.2" \
26-
&& poetry --version \
27-
# Configure to use system instead of virtualenvs
28-
&& poetry config virtualenvs.create false \
29-
&& poetry install --no-root \
30-
&& poetry add playwright \
31-
# Clean-up
32-
&& pip uninstall -y poetry virtualenv-clone virtualenv
31+
RUN --mount=type=cache,target=$UV_CACHE_DIR \
32+
--mount=type=bind,source=uv.lock,target=uv.lock \
33+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
34+
uv sync --frozen --no-install-project --all-groups
3335

3436
RUN playwright install \
3537
&& playwright install-deps

README.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,15 @@ Access the site at http://localhost:8000
5858

5959
$ docker-compose build
6060

61-
### Using [poetry](https://python-poetry.org/docs/) (python package manager)
62-
- Install used python version using pyenv
61+
### Using [uv](https://docs.astral.sh/uv/) (python package manager)
62+
- Install uv using this documentation https://docs.astral.sh/uv/getting-started/installation/
63+
- Sync packages using uv
6364
```bash
64-
pyenv install $(cat .python-version)
65+
uv sync
6566
```
66-
- Install poetry packages in host
67+
- Add new package in pyproject.toml and generate lock
6768
```bash
68-
poetry install
69-
```
70-
- Add new package
71-
```bash
72-
poetry add <package-name>
73-
```
74-
- Update lock file
75-
```bash
76-
poetry update --lock
69+
uv lock
7770
```
7871

7972
## Adding/Updating translations (Django static)

docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
# NOTE: Used Only for local development
2+
13
x-server: &base_server_setup
2-
image: ifrcgo/go-api:latest
4+
image: ifrcgo/go-api:uv-latest
35
build: .
46
# To attach to container with stdin `docker attach <container_name>`
57
# Used for python debugging.

0 commit comments

Comments
 (0)