diff --git a/.github/workflows/docker-ghcr.yml b/.github/workflows/docker-ghcr.yml new file mode 100644 index 0000000000..1bdbb48bd8 --- /dev/null +++ b/.github/workflows/docker-ghcr.yml @@ -0,0 +1,70 @@ +name: Publish Docker images to GHCR + +on: + push: + branches: + - master + tags: + - 'v*' + workflow_dispatch: + +permissions: + contents: read + packages: write + +jobs: + publish: + name: Build and push ${{ matrix.name }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - name: backend + image: hydro-backend + context: ./install/docker/backend + - name: judge + image: hydro-judge + context: ./install/docker/judge + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Lowercase GitHub owner for GHCR + run: echo "OWNER_LC=${GITHUB_REPOSITORY_OWNER,,}" >> "$GITHUB_ENV" + + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ env.OWNER_LC }}/${{ matrix.image }} + tags: | + type=ref,event=branch + type=ref,event=tag + type=sha,prefix=sha- + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push ${{ matrix.name }} image + uses: docker/build-push-action@v6 + with: + context: ${{ matrix.context }} + file: ${{ matrix.context }}/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha,scope=${{ matrix.image }} + cache-to: type=gha,mode=max,scope=${{ matrix.image }} diff --git a/install/docker/docker-compose.yml b/install/docker/docker-compose.yml index b5b2b06c4d..0f3ba70cc9 100644 --- a/install/docker/docker-compose.yml +++ b/install/docker/docker-compose.yml @@ -13,10 +13,12 @@ services: timeout: 10s retries: 5 start_period: 30s + oj-backend: - build: ./backend + image: ghcr.io/hydro-dev/hydro-backend:latest container_name: oj-backend restart: always + pull_policy: always depends_on: oj-mongo: condition: service_healthy @@ -33,11 +35,16 @@ services: retries: 3 start_period: 30s start_interval: 5s + ulimits: + stack: + soft: -1 + hard: -1 oj-judge: - build: ./judge + image: ghcr.io/hydro-dev/hydro-judge:latest container_name: oj-judge restart: always + pull_policy: always privileged: true depends_on: oj-backend: @@ -46,3 +53,7 @@ services: volumes: - ./judge/judge.yaml:/root/.hydro/judge.yaml - ./judge/mount.yaml:/root/.hydro/mount.yaml + ulimits: + stack: + soft: -1 + hard: -1