Skip to content

Commit 12712bf

Browse files
committed
chore: use poetry + ruff
1 parent c2e3c5b commit 12712bf

7 files changed

Lines changed: 925 additions & 40 deletions

File tree

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.idea
33
.git
44
.DS_Store
5+
.ruff_cache

.flake8

Lines changed: 0 additions & 10 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,6 @@ tmp/
6060
custom_settings.py
6161
*.zip
6262

63+
data/
6364
.venv/
65+
.ruff_cache/

Dockerfile

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
1-
FROM python:3.12-alpine
1+
FROM python:3.12-alpine AS builder
22
ARG TARGETARCH
33
ARG TARGETVARIANT
4-
ENV OJ_ENV production
4+
ENV POETRY_VIRTUALENVS_IN_PROJECT=true
55
WORKDIR /app
66

7-
COPY requirements.txt /app/
7+
COPY pyproject.toml poetry.lock /app/
88
# psycopg2: libpg-dev
99
# pillow: libjpeg-turbo-dev zlib-dev freetype-dev
10-
RUN --mount=type=cache,target=/etc/apk/cache,id=apk-cahce-$TARGETARCH$TARGETVARIANT-final \
11-
--mount=type=cache,target=/root/.cache/pip,id=pip-cahce-$TARGETARCH$TARGETVARIANT-final \
10+
RUN --mount=type=cache,target=/etc/apk/cache,id=apk-cahce-$TARGETARCH$TARGETVARIANT-builder \
11+
--mount=type=cache,target=/root/.cache/pypoetry,id=poetry-cahce-$TARGETARCH$TARGETVARIANT-builder \
1212
<<EOS
1313
set -ex
14-
apk add gcc libc-dev python3-dev libpq libpq-dev libjpeg-turbo libjpeg-turbo-dev zlib zlib-dev freetype freetype-dev
15-
pip install -r /app/requirements.txt
16-
apk del gcc libc-dev python3-dev libpq-dev libjpeg-turbo-dev zlib-dev freetype-dev
14+
apk add poetry gcc libc-dev python3-dev libpq-dev libjpeg-turbo-dev zlib-dev freetype-dev
15+
poetry env use /usr/local/bin/python3
16+
poetry install --no-interaction --without dev --no-root
1717
EOS
1818

19+
FROM python:3.12-alpine
20+
ARG TARGETARCH
21+
ARG TARGETVARIANT
22+
ENV OJ_ENV production
23+
ENV PATH="/app/.venv/bin:$PATH"
24+
WORKDIR /app
25+
26+
RUN --mount=type=cache,target=/etc/apk/cache,id=apk-cahce-$TARGETARCH$TARGETVARIANT-final \
27+
apk add libpq libjpeg-turbo lzlib freetype
28+
1929
COPY ./ /app/
2030
RUN chmod -R u=rwX,go=rX ./ && chmod +x /app/entrypoint.sh
31+
COPY --from=builder --link /app/.venv/ /app/.venv/
2132

2233
EXPOSE 8080
2334
CMD [ "/app/entrypoint.sh" ]

poetry.lock

Lines changed: 861 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[tool.poetry]
2+
name = "oj"
3+
version = "1.7.0"
4+
description = "Open source online judge based on Vue, Django and Docker"
5+
authors = ["virusdefender <virusdefender@outlook.com>"]
6+
license = "License :: OSI Approved :: MIT License"
7+
readme = "README.md"
8+
9+
[tool.poetry.dependencies]
10+
python = "^3.8"
11+
django = ">=3.2.24,<3.3.0"
12+
django-cas-ng = "^5.0.1"
13+
django-dbconn-retry = "^0.1.7"
14+
django-dramatiq = "^0.11.6"
15+
django-redis = "^5.4.0"
16+
djangorestframework = "^3.14.0"
17+
dramatiq = "^1.16.0"
18+
entrypoints = "^0.4"
19+
envelopes = "^0.4"
20+
gunicorn = "^21.2.0"
21+
jsonfield = "^3.1.0"
22+
otpauth = "^1.0.1"
23+
pillow = "^10.2.0"
24+
psycopg2 = "^2.9.9"
25+
python-dateutil = "^2.8.2"
26+
qrcode = "^7.4.2"
27+
raven = "^6.10.0"
28+
xlsxwriter = "^3.1.9"
29+
30+
[tool.poetry.group.dev.dependencies]
31+
coverage = "^7.4.1"
32+
ruff = "^0.2.1"
33+
34+
[tool.ruff]
35+
exclude = [".venv"]
36+
37+
[tool.ruff.format]
38+
quote-style = "single"
39+
40+
[build-system]
41+
requires = ["poetry-core"]
42+
build-backend = "poetry.core.masonry.api"

requirements.txt

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)