Skip to content

Commit 6a3df41

Browse files
committed
Revert changes incompatible with legacy EC2
This reverts a number of commits, namely: - Python 3.12: 41ac2bc. - Poetry to uv:10a28c27b35c6d8ab1c4644cfebee2d274512c0f. Relevant dependency changes worth heeding: - django-crispy-forms: 01252dd - allauth: e395816
1 parent 627c298 commit 6a3df41

File tree

16 files changed

+2457
-1426
lines changed

16 files changed

+2457
-1426
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ jobs:
88
fail-fast: false
99
matrix:
1010
command:
11-
- "uv run ruff check ."
12-
- "uv run ruff format --check ws"
13-
- "uv run mypy ws"
14-
- "uv run pylint --jobs=0 ws"
15-
- "uv run pytest"
11+
- "ruff check ."
12+
- "ruff format --check ws"
13+
- "mypy ws"
14+
- "pylint --jobs=0 ws"
15+
- "pytest"
1616
runs-on: ubuntu-22.04
1717
services:
1818
# TODO: Only the `test` step in the matrix needs this service up and running.
@@ -36,7 +36,7 @@ jobs:
3636

3737
- name: "Install buildx"
3838
id: buildx
39-
uses: docker/setup-buildx-action@v3
39+
uses: docker/setup-buildx-action@v1
4040

4141
- name: "Restore Docker cache"
4242
uses: actions/cache@v4

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/.poetry_prod_up_to_date
2+
/.poetry_dev_up_to_date
13
/.node_packages_up_to_date
24
/.coverage
35
/.mypy_cache

.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

.tool-versions

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
python 3.10.17
2+
poetry 1.8.3
13
nodejs 16.20.2
2-
uv 0.9.5

Dockerfile

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,51 @@
11
# TODO:
2-
# - Consider python:3.12-slim
2+
# - Consider python:3.10-slim
33
# - Once dropping legacy AngularJS, build FE bundles separately
44

55
# Things needed to use this in production:
66
# - Direct logs to files outside the container
77
# - Ensure that Celery works as well
88
# - Run WSGI with an ENTRYPOINT
99

10-
FROM ubuntu:24.04 AS build
10+
FROM ubuntu:22.04 AS build
1111

1212
WORKDIR /app/
1313

1414
ENV DEBIAN_FRONTEND="noninteractive"
1515

1616
RUN apt-get update && apt-get install --no-install-recommends -y \
17-
build-essential \
18-
gcc \
17+
build-essential gcc \
18+
# Only for installing node \
19+
curl \
20+
# Only needed to install legacy node dependencies from git \
21+
git \
1922
locales \
2023
# Postgres client (for accessing RDS in production) \
2124
postgresql-client postgresql-contrib libpq-dev \
25+
python3.10 python3-dev python3-pip \
2226
&& apt-get clean \
2327
&& rm -rf /var/lib/apt/lists/*
2428

2529
RUN locale-gen en_US.UTF-8
2630
RUN update-locale en_US.UTF-8
2731

32+
# `click` will error out without locales explicitly set
2833
ENV LANGUAGE=en_US.UTF-8
2934
ENV LANG=en_US.UTF-8
3035
ENV LC_ALL=en_US.UTF-8
3136

32-
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/
37+
RUN pip3 install --upgrade pip==24.1
38+
39+
COPY .tool-versions .
40+
RUN pip install poetry==$(awk '/poetry/{printf $2}' .tool-versions)
41+
COPY poetry.lock .
42+
43+
# Instruct poetry to create a venv in `.venv`, then auto-add it to path
44+
RUN poetry config virtualenvs.in-project true
45+
ENV PATH="/app/.venv/bin:$PATH"
46+
3347
COPY pyproject.toml .
34-
RUN uv sync --all-groups
48+
RUN poetry install --no-root --with=test,lint,mypy
3549

3650
# TODO: We should install & build the legacy frontend here.
3751
# But I'm likely going to just rebuild everything. See the Git log for more.
@@ -42,14 +56,14 @@ COPY ws ./ws
4256
# NOTE: For the legacy AngularJS build, setting `WS_DJANGO_TEST` bypasses compressors
4357
# (yuglify, specifically). Not a problem for tests, but does break production.
4458
# Hopefully we've dropped the legacy setup & can just use webpack.
45-
RUN WS_DJANGO_TEST=1 uv run manage.py collectstatic
59+
RUN WS_DJANGO_TEST=1 ./manage.py collectstatic
4660

4761
# ------------------------------------------------------------------------
4862

4963
FROM build AS installer
5064

5165
# Remove dev dependencies (smaller venv, no dev deps in prod)
52-
RUN uv sync --no-dev
66+
RUN poetry install --no-root --sync --only=prod
5367

5468
FROM ubuntu:22.04
5569

Makefile

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
.DEFAULT_GOAL := all
22

3+
poetry_dev_bootstrap_file = .poetry_dev_up_to_date
4+
poetry_prod_bootstrap_file = .poetry_prod_up_to_date
35
npm_bootstrap_file = .node_packages_up_to_date
46

7+
58
# Default `make` will give everything's that helpful for local development.
69
.PHONY: all
710
all: install-python-dev install-js
@@ -11,13 +14,23 @@ all: install-python-dev install-js
1114
build: install-python-prod build-frontend
1215

1316
.PHONY: install-python-dev
14-
install-python-dev:
15-
uv sync --all-groups
16-
17-
# Note this will actually *remove* any dev dependencies, if present.
17+
install-python-dev: $(poetry_dev_bootstrap_file)
18+
$(poetry_dev_bootstrap_file): poetry.lock
19+
touch $(poetry_dev_bootstrap_file).notyet
20+
poetry install --no-root --with=test,lint,mypy
21+
mv $(poetry_dev_bootstrap_file).notyet $(poetry_dev_bootstrap_file)
22+
@# Remove the prod bootstrap file, since we now have dev deps present.
23+
rm -f $(poetry_prod_bootstrap_file)
24+
25+
# Note this will actually *remove* any dev dependencies, if present
1826
.PHONY: install-python-prod
19-
install-python-prod:
20-
uv sync --no-dev
27+
install-python-prod: $(poetry_prod_bootstrap_file)
28+
$(poetry_prod_bootstrap_file): poetry.lock
29+
touch $(poetry_prod_bootstrap_file).notyet
30+
poetry install --no-root --sync --only=prod
31+
mv $(poetry_prod_bootstrap_file).notyet $(poetry_prod_bootstrap_file)
32+
@# Remove the dev bootstrap file, since the `--no-dev` removed any present dev deps
33+
rm -f $(poetry_dev_bootstrap_file)
2134

2235
.PHONY: install-js
2336
install-js: $(npm_bootstrap_file)
@@ -35,18 +48,29 @@ build-frontend: install-js
3548
.PHONY: check
3649
check: lint test
3750

51+
# Run automatic code formatters/linters that don't require human input
52+
# (might fix a broken `make check`)
53+
.PHONY: fix
54+
fix: install-python-dev
55+
poetry run ruff format .
56+
poetry run ruff check --fix .
57+
3858
.PHONY: lint
3959
lint: lint-python typecheck-python lint-js
4060

4161
.PHONY: lint-python
4262
lint-python: install-python-dev
43-
uv run ruff format --check .
44-
uv run ruff check .
45-
uv run pylint --jobs 0 ws # '0' tells pylint to auto-detect available processors
63+
poetry run ruff format --check .
64+
poetry run ruff check .
65+
poetry run pylint --jobs 0 ws # '0' tells pylint to auto-detect available processors
4666

4767
.PHONY: typecheck-python
48-
typecheck-python:
49-
uv run mypy --config-file pyproject.toml ws
68+
typecheck-python: install-python-dev
69+
@# Annoying workaround for `Cannot find component WithAnnotations`
70+
if ! poetry run mypy --config-file pyproject.toml ws; then \
71+
rm -r .mypy_cache; \
72+
exit 1; \
73+
fi
5074

5175
.PHONY: lint-js
5276
lint-js: install-js
@@ -57,7 +81,7 @@ test: test-python test-js
5781

5882
.PHONY: test-python
5983
test-python: install-python-dev
60-
WS_DJANGO_TEST=1 uv run coverage run -m pytest
84+
WS_DJANGO_TEST=1 poetry run coverage run -m pytest
6185

6286
.PHONY: test-js
6387
test-js: install-js
@@ -66,14 +90,16 @@ test-js: install-js
6690
# Production webservers won't run this way, so install dev dependencies
6791
.PHONY: run
6892
run: install-python-dev
69-
uv run python -Wd manage.py runserver
93+
poetry run python -Wd manage.py runserver
7094

7195
.PHONY: run-js
7296
run-js: install-js
7397
NODE_ENV=development npm --prefix=frontend/ run serve
7498

7599
.PHONY: clean
76100
clean:
101+
rm -f $(poetry_dev_bootstrap_file)
102+
rm -f $(poetry_prod_bootstrap_file)
77103
rm -f $(npm_bootstrap_file)
78104
rm -rf .mypy_cache
79105
find . -name '*.pyc' -delete

0 commit comments

Comments
 (0)