feat: build s2oj-remote-judger image

This commit is contained in:
Baoshuo Ren 2023-01-20 17:54:49 +08:00
parent 2556dd7819
commit 66acf9dba5
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
7 changed files with 70 additions and 88 deletions

View File

@ -58,6 +58,36 @@ steps:
event: push
branch: master
---
kind: pipeline
type: docker
name: Build Docker Image (s2oj-remote-judger)
trigger:
branch:
- master
steps:
- name: tags
image: alpine
commands:
- echo -n "latest, $DRONE_BRANCH, ${DRONE_COMMIT_SHA:0:8}" > .tags
- name: docker
image: plugins/docker
settings:
registry: git.m.ac
repo: git.m.ac/baoshuo/s2oj-remote-judger
context: remote_judger
dockerfile: remote_judger/Dockerfile
username: baoshuo
password:
from_secret: GITMAC_SECRET
cache_from: git.m.ac/baoshuo/s2oj-remote-judger:latest
when:
event: push
branch: master
---
kind: pipeline
type: docker

View File

@ -3,9 +3,10 @@ name: Build & Push Docker Images
on:
push:
branches:
- 'master'
tags:
- 'v*'
- master
pull_request:
branches:
- master
workflow_dispatch:
env:
@ -13,88 +14,31 @@ env:
IMAGE_BASENAME: ${{ github.repository }}
jobs:
build-db:
name: Build Database Image
build:
name: Build Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v2.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
strategy:
matrix:
include:
- image_name: db
context: db
dockerfile: Dockerfile
- image_name: judger
context: judger
dockerfile: Dockerfile
- image_name: remote-judger
context: remote_judger
dockerfile: Dockerfile
- image_name: web
context: .
dockerfile: web/Dockerfile
fail-fast: false
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4.0.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_BASENAME }}-db
tags: |
latest
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=
- name: Build and push Docker image
uses: docker/build-push-action@v3.1.1
with:
context: db
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-judger:
name: Build Judger Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v2.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4.0.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_BASENAME }}-judger
tags: |
latest
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=
- name: Build and push Docker image
uses: docker/build-push-action@v3.1.1
with:
context: judger
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-web:
name: Build Web Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
@ -114,7 +58,7 @@ jobs:
id: meta
uses: docker/metadata-action@v4.0.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_BASENAME }}-web
images: ${{ env.REGISTRY }}/${{ env.IMAGE_BASENAME }}-${{ matrix.image_name }}
tags: |
latest
type=ref,event=branch
@ -126,8 +70,8 @@ jobs:
- name: Build and push Docker image
uses: docker/build-push-action@v3.1.1
with:
context: .
file: web/Dockerfile
push: true
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@ -50,8 +50,6 @@ services:
- USE_MIRROR=1
container_name: uoj-remote-judger
restart: always
volumes:
- ./uoj_data/judger/log:/opt/uoj_judger/log
env_file:
- remote-judger.development.env
environment:

View File

@ -29,6 +29,16 @@ services:
- SOCKET_PORT=2333
- SOCKET_PASSWORD=_judger_socket_password_
uoj-remote-judger:
image: git.m.ac/baoshuo/s2oj-remote-judger
container_name: uoj-remote-judger
restart: always
environment:
- UOJ_PROTOCOL=http
- UOJ_HOST=uoj-web
- UOJ_JUDGER_NAME=remote_judger
- UOJ_JUDGER_PASSWORD=_judger_password_
uoj-web:
image: git.m.ac/baoshuo/s2oj-web
container_name: uoj-web

View File

@ -1,2 +1,2 @@
USE `app_uoj233`;
insert into judger_info (judger_name, password, ip) values ('compose_judger', '_judger_password_', 'uoj-judger');
insert into judger_info (judger_name, password, ip, display_name, description) values ('compose_judger', '_judger_password_', 'uoj-judger', '内置评测机', '用于评测本地题目的评测机。');

View File

@ -1,4 +1,4 @@
FROM node:18
FROM node:18.13.0
WORKDIR /opt/s2oj_remote_judger
COPY package*.json ./

View File

@ -1,2 +1,2 @@
USE `app_uoj233`;
insert into judger_info (judger_name, password, ip) values ('remote_judger', '_judger_password_', 'uoj-remote-judger');
insert into judger_info (judger_name, password, ip, display_name, description) values ('remote_judger', '_judger_password_', 'uoj-remote-judger', '远端评测机', '用于桥接远端 OJ 评测机的虚拟评测机。');