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 event: push
branch: master 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 kind: pipeline
type: docker type: docker

View File

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

View File

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

View File

@ -29,6 +29,16 @@ services:
- SOCKET_PORT=2333 - SOCKET_PORT=2333
- SOCKET_PASSWORD=_judger_socket_password_ - 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: uoj-web:
image: git.m.ac/baoshuo/s2oj-web image: git.m.ac/baoshuo/s2oj-web
container_name: uoj-web container_name: uoj-web

View File

@ -1,2 +1,2 @@
USE `app_uoj233`; 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 WORKDIR /opt/s2oj_remote_judger
COPY package*.json ./ COPY package*.json ./

View File

@ -1,2 +1,2 @@
USE `app_uoj233`; 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 评测机的虚拟评测机。');