Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from QingdaoU:master #68

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release build

on:
push:
tags:
- v**
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
environment: release
permissions:
contents: read
packages: write
steps:
- name: Docker metadata
id: metadata
uses: docker/metadata-action@v5
with:
images: |
registry.cn-hongkong.aliyuncs.com/oj-image/backend
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Aliyun Container Registry
uses: docker/login-action@v3
with:
registry: registry.cn-hongkong.aliyuncs.com
username: ${{ secrets.ALIYUN_ACR_USERNAME }}
password: ${{ secrets.ALIYUN_ACR_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.metadata.outputs.tags }}
annotations: ${{ steps.metadata.outputs.annotations }}
44 changes: 32 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
FROM python:3.8-alpine3.14
FROM alpine:3.19 AS downloader

ENV OJ_ENV production

ADD . /app
WORKDIR /app

HEALTHCHECK --interval=5s --retries=3 CMD python3 /app/deploy/health_check.py
RUN <<EOS
set -ex
apk add unzip
wget https://github.com/QingdaoU/OnlineJudgeFE/releases/download/oj_2.7.5/dist.zip
unzip dist.zip
rm -f dist.zip
EOS

FROM python:3.12-alpine
ARG TARGETARCH
ARG TARGETVARIANT

ENV OJ_ENV production
WORKDIR /app

RUN apk add --update --no-cache build-base nginx openssl curl unzip supervisor jpeg-dev zlib-dev postgresql-dev freetype-dev && \
pip install --no-cache-dir -r /app/deploy/requirements.txt && \
apk del build-base --purge
COPY ./deploy/requirements.txt /app/deploy/
# psycopg2: libpg-dev
# pillow: libjpeg-turbo-dev zlib-dev freetype-dev
RUN --mount=type=cache,target=/etc/apk/cache,id=apk-cahce-$TARGETARCH$TARGETVARIANT-final \
--mount=type=cache,target=/root/.cache/pip,id=pip-cahce-$TARGETARCH$TARGETVARIANT-final \
<<EOS
set -ex
apk add gcc libc-dev python3-dev libpq libpq-dev libjpeg-turbo libjpeg-turbo-dev zlib zlib-dev freetype freetype-dev supervisor openssl nginx curl unzip
pip install -r /app/deploy/requirements.txt
apk del gcc libc-dev python3-dev libpq-dev libjpeg-turbo-dev zlib-dev freetype-dev
EOS

RUN curl -L $(curl -s https://api.github.com/repos/QingdaoU/OnlineJudgeFE/releases/latest | grep /dist.zip | cut -d '"' -f 4) -o dist.zip && \
unzip dist.zip && \
rm dist.zip
COPY ./ /app/
COPY --from=downloader --link /app/dist/ /app/dist/
RUN chmod -R u=rwX,go=rX ./ && chmod +x ./deploy/entrypoint.sh

ENTRYPOINT /app/deploy/entrypoint.sh
HEALTHCHECK --interval=5s CMD [ "/usr/local/bin/python3", "/app/deploy/health_check.py" ]
EXPOSE 8000
ENTRYPOINT [ "/app/deploy/entrypoint.sh" ]
4 changes: 2 additions & 2 deletions deploy/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ do
sleep 8
done

addgroup -g 12003 spj
adduser -u 12000 -S -G spj server
addgroup -g 903 spj
adduser -u 900 -S -G spj server

chown -R server:spj $DATA $APP/dist
find $DATA/test_case -type d -exec chmod 710 {} \;
Expand Down
43 changes: 16 additions & 27 deletions deploy/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
certifi==2019.3.9
chardet==3.0.4
coverage==6.1.2
Django==3.2.9
django-redis==5.0.0
djangorestframework==3.12.4
entrypoints==0.3
coverage==6.5.0
django-cas-ng==5.0.1
django-dbconn-retry==0.1.7
django-dramatiq==0.11.6
django-redis==5.4.0
Django==3.2.25
djangorestframework==3.14.0
dramatiq==1.16.0
entrypoints==0.4
Envelopes==0.4
flake8==4.0.1
flake8-coding==1.3.2
flake8-quotes==3.3.1
gunicorn==20.1.0
idna==3.3
flake8-quotes==3.3.2
flake8==7.0.0
gunicorn==21.2.0
jsonfield==3.1.0
mccabe==0.6.1
otpauth==1.0.1
Pillow==8.4.0
psycopg2==2.9.2
pycodestyle==2.8.0
pyflakes==2.4.0
pillow==10.2.0
psycopg2==2.9.9
python-dateutil==2.8.2
pytz==2021.3
qrcode==7.3.1
qrcode==7.4.2
raven==6.10.0
redis==3.5.3
requests==2.26.0
six==1.16.0
urllib3==1.26.7
XlsxWriter==3.0.2
django-dramatiq==0.10.0
dramatiq==1.12.0
django-dbconn-retry==0.1.5
django-cas-ng==4.2.1
XlsxWriter==3.1.9
3 changes: 0 additions & 3 deletions docs/README.md

This file was deleted.

16 changes: 16 additions & 0 deletions docs/data.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
{
"update": [
{
"version": "2024-02-04",
"level": "Important",
"title": "OnlineJudge 1.16.0 更新",
"details": [
"更新基底映像档,从 `python:3.8-alpine3.14` 改为 `python:3.12-alpine`。",
"更新评测的程序语言版本:",
"C/C++: GCC 13",
"Java: Temurin 21",
"Python 2: 移除",
"Python 3: CPython 3.12",
"Golang: Golang 1.22",
"Node.js: Node.js 20",
"PHP: 暫時移除"
]
},
{
"version": "2021-11-20",
"level": "Important",
Expand Down
Loading