Git Product home page Git Product logo

boca-docker's Introduction

🎈 boca-docker

Build and publish multi-platform_Docker images on ghcr.io workflow Delete GitHub Actions cache for repository workflow Delete_untagged_and/or_unsupported_Docker_images_on_ghcr.io_workflow Close_stale_issues_and_PRs_workflow

Ubuntu JAMMY Ubuntu FOCAL Multi-Architecture

Google_Groups

Table of Contents

What Is BOCA?

BOCA Online Contest Administrator (known simply as BOCA) is an administration system to held programming contests (e.g., ACM-ICPC, Maratona de Programação da SBC). According to the developers, its main features are portability, concurrency control, multi-site and distributed contests, and a simple web interface (for details refer to https://github.com/cassiopc/boca).

BOCA is implemented mainly in PHP and makes use of a PostgreSQL database in the backend (see architecture below). It is a good example of a monolithic system, in which the user interface and database access are all interwoven, rather than containing architecturally separate components. The problem is compound due to the low readability and complex code structuring, which is hard to adapt and to extend.

Why boca-docker?

The boca-docker project is a use case of how we can take advantage of microservices architecture and containerization technology (i.e., Docker) to deploy applications in a more convenient and faster way (see illustration below). After quite some reverse engineering, we provide a multi-platform/arch Docker version of BOCA's main components (web app, online automated judge and database) aiming at easing the customization, extensibility and automation of the operational effort required to deploy, run and scale BOCA.

Original architecture boca-docker architecture
Alt text Alt text

This work started as part of the undergraduate final year project carried out by João Vitor Alves Fazolo under supervision of Prof. Dr. Rodrigo Laiola Guimaraes at Universidade Federal do Espirito Santo (UFES).

Requirements

Quick Start

  • Open a Terminal window and make sure the Docker engine is up and running:

    # List docker images
    docker images -a
    # List containers
    docker container ls -a
  • Download the docker-compose.yml and docker-compose.prod.yml files, and place them in the current work directory. Then,

    docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
  • Voilà! The application should be running now. Open a web browser and visit the URL http://localhost:8000/boca. First, create and activate a BOCA contest (user: system | password: boca). Then, login as admin (user: admin | password: boca) to manage users, problems, languages etc;

    NOTE: consider changing these passwords later on. Find out more information on how to setup a contest here. For general questions about BOCA consider looking at this forum.

  • To stop the application (considering that the shell is in the same directory):

    docker compose -f docker-compose.yml -f docker-compose.prod.yml down

How To Deploy It To A Swarm

  • Create the stack (make sure Docker Engine is already running in swarm mode):

    docker stack deploy --compose-file docker-compose.yml -c docker-compose.prod.yml boca-stack
  • Then, check if the stack is running:

    docker stack services boca-stack
  • Open a web browser and follow the instructions described above;

  • To bring the stack down:

    docker stack rm boca-stack

How To Add Custom Configuration

There are many ways to customize the boca-docker application. Without trying to support every possible use case, here are just a few that we have found useful.

  • Environment Variables: shows the correct syntax for the various ways one can change predefined configuration values to keep the boca-docker application flexible and organized. See documentation here;

  • Docker Secrets: an alternative way to passing sensitive information via environment variables, causing the initialization scripts to load the values for those variables from files present in the containers. See documentation here;

  • Networking: shows how to add network isolation between services in the boca-docker application. See documentation here;

  • Volumes: demonstrates how to store data outside the database container, so that the state of the application persists even after the container stops. See documentation here;

  • Migrations: illustrates how to backup and restore BOCA's database to facilitate migration from one boca-docker instance to another. See documentation here;

  • Healthcheck: allows a check to be configured in order to determine whether or not the PostgreSQL container is "healthy." This is a particularly neat use case given that the other services depend on that to work. See documentation here;

  • Multiple Platforms: shows the syntax for selecting an image that matches a specific OS and architecture (alternatively, Docker does that automatically). See documentation here.

How To Run On Different Ubuntu Release Images

To run the boca-docker application built on top of different versions of Ubuntu images, please edit the docker-compose.prod.yml file with an alternative tag from the table below.

Tag name BOCA version Ubuntu version Code name Architecture
latest, 1.2, 1.2-jammy, 1.2.2, 1.2.2-jammy 1.5 22.04 LTS Jammy Jellyfish amd64, arm/v7, arm64/v8, ppc64le, s390x
1.2-focal, 1.2.2-focal 1.5 20.04 LTS Focal Fossa amd64, arm/v7, arm64/v8, ppc64le, s390x
nightly, nightly-jammy 1.5 22.04 LTS Jammy Jellyfish amd64, arm/v7, arm64/v8, ppc64le, s390x
nightly-focal 1.5 20.04 LTS Focal Fossa amd64, arm/v7, arm64/v8, ppc64le, s390x

For example, to use BOCA version 1.5 running on Ubuntu 20.04 LTS (Focal Fossa) on any supported architecture:

...
services:
  ...

  # web app
  boca-web:
      image: ghcr.io/joaofazolo/boca-docker/boca-web:1.2-focal
  ...

  ...
  # online judge
  boca-jail:
      image: ghcr.io/joaofazolo/boca-docker/boca-jail:1.2-focal
  ...

Deprecated Image Tags

The following image tags have been deprecated and are no longer receiving updates:

  • 1.2.1
  • 1.2.0
  • 1.1.0
  • 1.0.0

How To Build It (For Development)

  • Clone this repository and set it as your working directory:

    git clone https://github.com/joaofazolo/boca-docker.git
    cd boca-docker
  • Then, compose it up with the command below (this might take a while, sit back and relax):

    docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build

    NOTE: Keep in mind that these Docker images are created for and to run on the default platform (i.e. linux/amd64). This works for the majority of development machines and cloud providers versions. To build target-specific or multi-platform Docker images consult the documentation;

  • Follow the instructions above to set up the application;

  • To stop it:

    docker compose -f docker-compose.yml -f docker-compose.dev.yml down
  • Alternatively, it is possible to build images without launching the application.

    docker build -t boca-base . -f docker/dev/base/Dockerfile
    docker build -t boca-web . -f docker/dev/web/Dockerfile
    docker build -t boca-jail . -f docker/dev/jail/Dockerfile

How To Publish It

NOTE: These instructions take into account the Docker images generated in the previous section (no multi-platform support).

  • After building, set the user and image tags accordingly. The IMAGE_ID's will show up with the docker images -a;

    docker images -a
    # boca-base only necessary for development
    # docker tag IMAGE_ID_BOCA_BASE ghcr.io/joaofazolo/boca-docker/boca-base:1.2.2
    docker tag IMAGE_ID_BOCA_WEB ghcr.io/joaofazolo/boca-docker/boca-web:1.2.2
    docker tag IMAGE_ID_BOCA_JAIL ghcr.io/joaofazolo/boca-docker/boca-jail:1.2.2
  • Log in into GitHub's Container Registry using your username and personal access token (details here);

    docker login ghcr.io
  • Push the container images to repository.

    # boca-base only necessary for development
    # docker push ghcr.io/joaofazolo/boca-docker/boca-base:1.2.2
    docker push ghcr.io/joaofazolo/boca-docker/boca-web:1.2.2
    docker push ghcr.io/joaofazolo/boca-docker/boca-jail:1.2.2

How To Contribute

If you would like to help contribute to this project, please see CONTRIBUTING.

Before submitting a PR consider building and testing a Docker image locally and checking your code with Super-Linter:

docker run --rm \
           -e ACTIONS_RUNNER_DEBUG=true \
           -e RUN_LOCAL=true \
           --env-file ".github/super-linter.env" \
           -v "$PWD":/tmp/lint \
           ghcr.io/super-linter/super-linter:latest

Known Issues

  • Rosetta for x86_64/amd64 emulation must be disabled on Apple Silicon (ARM-based chips) for the online automated judge (boca-jail) to work (tested on Apple M1, Docker Desktop 4.28.0, Engine: 25.0.3, Compose: v2.24.6-desktop.1, Mar 2024);

License

Copyright Universidade Federal do Espirito Santo (Ufes)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

This program is released under license GNU GPL v3+ license.

Support

Please report any issues with boca-docker at https://github.com/joaofazolo/boca-docker/issues

boca-docker's People

Contributors

alejolp avatar arthurbdiniz avatar bcribas avatar cassiopc avatar cjoa avatar dependabot[bot] avatar joaofazolo avatar rlaiola avatar ronistone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

boca-docker's Issues

Erro Autojudge - Java

Olá pessoal,
Primeiramente, obrigado pelo suporte do autojudge no python (realizei a maratona nas turmas de programação com sucesso).
Porém, tenho outras turmas que utilizam agora a linguagem Java. Está ocorrendo o erro abaixo quando submeto a resolução de um problema. Para ajudar, vou colocar todas as informações que utilizei, ok? Se precisarem de mais informações, por favor, entrem em contato.

=> Hardware/software
Windows 11 home 23H2
Notebook x64
Docker Desktop 4.26.1
Docker Engine v24.0.7

=> Em anexo, o problema (A.zip) e a solução em Java (Roman.zip). Lembrando que, para executar em Java, precisamos retirar o "package" e colocar o nome do arquivo/classe com o mesmo nome que está em basename, na descrição do problema.
A.zip
Roman.zip

=> Erro gerado no stderr
Exception in thread "main" java.lang.InternalError: Error loading java.security file
at java.base/java.security.Security.initialize(Security.java:94)
at java.base/java.security.Security$1.run(Security.java:79)
at java.base/java.security.Security$1.run(Security.java:77)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.Security.(Security.java:77)
at java.base/sun.security.util.SecurityProperties.getOverridableProperty(SecurityProperties.java:53)
at java.base/sun.security.util.SecurityProperties.privilegedGetOverridable(SecurityProperties.java:44)
at java.base/sun.security.util.FilePermCompat.(FilePermCompat.java:45)
at java.base/java.security.AccessControlContext.(AccessControlContext.java:260)
at java.base/java.security.AccessController.createWrapper(AccessController.java:599)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:430)
at java.base/java.util.ResourceBundle$ResourceBundleProviderHelper.loadResourceBundle(ResourceBundle.java:3602)
at java.base/java.util.ResourceBundle.loadBundle(ResourceBundle.java:1844)
at java.base/java.util.ResourceBundle.findBundle(ResourceBundle.java:1774)
at java.base/java.util.ResourceBundle.findBundle(ResourceBundle.java:1728)
at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1662)
at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1582)
at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1556)
at java.base/java.util.ResourceBundle.getBundle(ResourceBundle.java:932)
at jdk.compiler/com.sun.tools.javac.util.JavacMessages.lambda$add$0(JavacMessages.java:121)
at jdk.compiler/com.sun.tools.javac.util.JavacMessages.getBundles(JavacMessages.java:140)
at jdk.compiler/com.sun.tools.javac.util.JavacMessages.setCurrentLocale(JavacMessages.java:80)
at jdk.compiler/com.sun.tools.javac.util.JavacMessages.(JavacMessages.java:112)
at jdk.compiler/com.sun.tools.javac.util.JavacMessages.(JavacMessages.java:89)
at jdk.compiler/com.sun.tools.javac.util.JavacMessages.instance(JavacMessages.java:58)
at jdk.compiler/com.sun.tools.javac.util.JCDiagnostic$Factory.(JCDiagnostic.java:71)
at jdk.compiler/com.sun.tools.javac.util.JCDiagnostic$Factory.instance(JCDiagnostic.java:61)
at jdk.compiler/com.sun.tools.javac.util.Log.(Log.java:352)
at jdk.compiler/com.sun.tools.javac.util.Log.(Log.java:255)
at jdk.compiler/com.sun.tools.javac.util.Log.instance(Log.java:235)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:197)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
Exception in thread "main" java.lang.InternalError: Error loading java.security file
at java.base/java.security.Security.initialize(Security.java:94)
at java.base/java.security.Security$1.run(Security.java:79)
at java.base/java.security.Security$1.run(Security.java:77)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.Security.(Security.java:77)
at java.base/sun.security.util.SecurityProperties.getOverridableProperty(SecurityProperties.java:53)
at java.base/sun.security.util.SecurityProperties.privilegedGetOverridable(SecurityProperties.java:44)
at java.base/sun.security.util.FilePermCompat.(FilePermCompat.java:45)
at java.base/java.security.AccessControlContext.(AccessControlContext.java:260)
at java.base/java.security.AccessController.createWrapper(AccessController.java:599)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:430)
at java.base/java.util.ResourceBundle$ResourceBundleProviderHelper.loadResourceBundle(ResourceBundle.java:3602)
at java.base/java.util.ResourceBundle.loadBundle(ResourceBundle.java:1844)
at java.base/java.util.ResourceBundle.findBundle(ResourceBundle.java:1774)
at java.base/java.util.ResourceBundle.findBundle(ResourceBundle.java:1728)
at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1662)
at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1582)
at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1556)
at java.base/java.util.ResourceBundle.getBundle(ResourceBundle.java:932)
at jdk.compiler/com.sun.tools.javac.util.JavacMessages.lambda$add$0(JavacMessages.java:121)
at jdk.compiler/com.sun.tools.javac.util.JavacMessages.getBundles(JavacMessages.java:140)
at jdk.compiler/com.sun.tools.javac.util.JavacMessages.setCurrentLocale(JavacMessages.java:80)
at jdk.compiler/com.sun.tools.javac.util.JavacMessages.(JavacMessages.java:112)
at jdk.compiler/com.sun.tools.javac.util.JavacMessages.(JavacMessages.java:89)
at jdk.compiler/com.sun.tools.javac.util.JavacMessages.instance(JavacMessages.java:58)
at jdk.compiler/com.sun.tools.javac.util.JCDiagnostic$Factory.(JCDiagnostic.java:71)
at jdk.compiler/com.sun.tools.javac.util.JCDiagnostic$Factory.instance(JCDiagnostic.java:61)
at jdk.compiler/com.sun.tools.javac.util.Log.(Log.java:352)
at jdk.compiler/com.sun.tools.javac.util.Log.(Log.java:255)
at jdk.compiler/com.sun.tools.javac.util.Log.instance(Log.java:235)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:197)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
Exception in thread "main" java.lang.InternalError: Error loading java.security file
at java.base/java.security.Security.initialize(Security.java:94)
at java.base/java.security.Security$1.run(Security.java:79)
at java.base/java.security.Security$1.run(Security.java:77)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.Security.(Security.java:77)
at java.base/sun.security.util.SecurityProperties.getOverridableProperty(SecurityProperties.java:53)
at java.base/sun.security.util.SecurityProperties.privilegedGetOverridable(SecurityProperties.java:44)
at java.base/sun.security.util.FilePermCompat.(FilePermCompat.java:45)
at java.base/java.security.AccessControlContext.(AccessControlContext.java:260)
at java.base/java.security.AccessController.createWrapper(AccessController.java:599)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:430)
at java.base/java.util.ResourceBundle$ResourceBundleProviderHelper.loadResourceBundle(ResourceBundle.java:3602)
at java.base/java.util.ResourceBundle.loadBundle(ResourceBundle.java:1844)
at java.base/java.util.ResourceBundle.findBundle(ResourceBundle.java:1774)
at java.base/java.util.ResourceBundle.findBundle(ResourceBundle.java:1728)
at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1662)
at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1582)
at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1556)
at java.base/java.util.ResourceBundle.getBundle(ResourceBundle.java:857)
at jdk.jartool/sun.tools.jar.Main.(Main.java:186)
Compilation Error: 1
Current directory is /home/bocajail/tmp/bocalFvAen.d
safeexec: starting the job. Parent controller has pid 133, child is 134...
safeexec: TOTAL TIME RUNNING ./compileit.sh: 2 sec (0.524778 sec)
safeexec: killing all recent processes from this user/group to avoid possible malicious code... use -K if you don't want this

Internal test script failed

Sorry to bother you again. I created users and uploaded an example problem (abacaxi.zip) successfully. However, when submitting a solution, the following error appears on the screen showing the run details: error: internal test script failed (/home/bocajail/tmp/bocaVuBz4N.d/problemdata/tests/c. It seems to be a problem compiling the script that tests whether autojudge is working. What could I be doing wrong?

admin not found

Firstly, congratulations on the initiative. Installing BOCA was much simpler with your docker. However, the website says that the admin user does not exist, while the system user enters with the password boca. Do you have any idea what could be happening?

Build problem tool not working

          Another problem (maybe related) is that the `.zip` is not being created using the `http://localhost:8000/boca/admin/buildproblem.php` tool. The error is that the `[...]/doc/problemexamples/[...]` folder is missing in the `boca-web` container. I fixed this problem by copying the `https://github.com/cassiopc/boca/tree/master/doc/problemexamples` folder to `var/www/boca/doc/problemexamples/[...]` in the `boca-web` container. Now, the `.zip` is being created without the `test` scripts (at least it is being created). Even when putting the test scripts manually, the error mentioned above occurs.

Originally posted by @laffernandes in #35 (comment)

Erro Autojudge

Olá,
Estou utilizando o boca-docker e, quando submeto a resolução de um problema, está ocorrendo o seguinte erro do autojudge:
Internal directory is /tmp/bocahqIZ4k.d
./compileit.sh: fork: retry: Resource temporarily unavailable
./compileit.sh: fork: retry: Resource temporarily unavailable
./compileit.sh: fork: retry: Resource temporarily unavailable
./compileit.sh: fork: retry: Resource temporarily unavailable
./compileit.sh: fork: Resource temporarily unavailable
Compilation Error: 8
Current directory is /home/bocajail/tmp/bocahqIZ4k.d
safeexec: starting the job. Parent controller has pid 358, child is 359...
safeexec: PROGRAM EXITED WITH NONZERO CODE ./compileit.sh: 254
safeexec: TOTAL TIME RUNNING ./compileit.sh: 15 sec (0.001614 sec)
safeexec: killing all recent processes from this user/group to avoid possible malicious code... use -K if you don't want this

A resolução está correta e o código submetido está em Py3.
Se puderes dar uma luz, agradeço.

Bug after creating or updating a problem package

This might be a bug in all builds. It can be reproduced by playing the role of a contest admin that creates or updates a problem package within the problems web page. If the Color field in the form is specified, the ballon for that problem will not be colored properly (it will not be created at all) and the form to add a new problem package will not be shown the next time the web page is reloaded.

Why it happens?
R: boca-web lacks the php-gd package

How to solve it?
R: Include the following command in boca-web build
apt-get install -y php-gd

Autojudge

Olá, subi os containers e fiz um contest, porém o serviço de autojudge não está rodando. Como faço para subir o serviço?

Boca not updating Scoreboard

Hello,
My first time using boca here.
I'm trying to create a contest to test the S4RiS.php admin tool, this is to allow neoSaris (a new scoreboard revealer) to work with boca. But as I'm simulating the contest I'm able to set the problems, set the site, etc. The contests seems to work with runs, autojudges, etc. But I cannot see the scoreboard, it says that the scoreboard is empty!
I'm not sure of why is is happening as the runs and being performed successfully. The score is on level 3 so it should be displayed.
The BOCA logs doesn't show anything special, that tells that something is going wrong with the scoreboard, but when using the misc/Transfer-Scoreboard options it says that the main site URL is invalid. I'm using the local IP (I've tried 127.0.0.1/boca, localhost/boca).
I think that is the expected answer as the main site (1) is itself, and that main site might not be itself when running multi-site contests. So, not sure about what's happening.

Looking at the docker logs, I can find 2023-02-04 19:23:16 [Sat Feb 04 22:23:16.416768 2023] [access_compat:error] [pid 37] [client 172.18.0.1:48364] AH01797: client denied by server configuration: /var/www/boca/favicon.ico, referer: http://localhost:8000/boca/admin/score.php

I've already checked some issues around this, but it seems to be right configured.

Sorry if I'm not providing all the required information about the issue, It's my first time setting BOCA so I'm not familiar with its setup, but I can provide more information that might be required :)

database access variables didn't work

Hi.
First, congratulations and thanks for the work.
I'm trying to configure the database access variables and it didn't work. Apparently, the system is trying to access BOCA_DB_NAME using BOCA_DB_SUPER_USER:

psql: error: FATAL: database "superuser" does not exist

docker-compose.yml:

version: '3.8'

services:

# web app
boca-web:
    environment:
        # database configuration
        # privileged user password

        - BOCA_DB_NAME=boca
        - BOCA_DB_SUPER_USER=superuser
        - BOCA_DB_SUPER_PASSWORD=superp@ss
    ports:
        - 8002:80

# online judge
# boca-jail:

# database
boca-db:
    image: postgres:14-alpine
    environment:
        # database configuration
        # privileged user password
        - POSTGRES_DB=boca
        - POSTGRES_USER=superuser
        - POSTGRES_PASSWORD=superp@ss

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.