Git Product home page Git Product logo

syzoj-ng-demo's Introduction

SYZOJ NG Demo

Here is a simple dockerized SYZOJ NG. Everything is done with the simple and stupid way.

This is only for demo. Do NOT use it on production. I'll publish a dockerized production version when appropriate.

docker run --name=demo \
           # You can mount data directories to access outside
           # But you need a copy of mysql's initial data directory of this image
           # --rm \
           # -v /root/data/minio:/root/minio-data \
           # -v /root/data/mysql:/var/lib/mysql \
           # -v /root/data/redis:/var/lib/redis \
           -e ENV=production \
           # (Optional) by default "SYZOJ"
           -e SITE_NAME="<your site name here>" \
           # (Optional) by default SYZOJ logo
           -e APP_LOGO="https://your.logo.url/logo.png_or.svg" \
           # The frontend URL you'll access it
           # It should be the same in Nginx
           -e FRONTEND=https://demo.syzoj.org \
           # It should be accessable by user and proxy_pass-ed to http://container_ip:2003
           # with http "Host" header set to 127.0.0.1:2003.
           -e MINIO_ENDPOINT_USER=https://demo.syzoj.org/minio \
           # It should be accessable by judge clients and proxy_pass-ed to http://container_ip:2003
           # with http "Host" header set to 127.0.0.1:2003.
           -e MINIO_ENDPOINT_JUDGE=https://demo.syzoj.org/minio \
           # If you are caring about the demo site's security, use secure keys
           -e MINIO_ACCESS_KEY=minioadmin \
           -e MINIO_SECRET_KEY=this_is_secret \
           # Your login user to the demo website
           -e ADMIN_USERNAME=yourusername \
           -e [email protected] \
           -e ADMIN_PASSWORD=yourpassword \
           # The email address for mailing (for registering verification and resetting password)
           -e [email protected] \
           -e MAIL_TRANSPORT=smtps://user:[email protected] \
           # The prebuilt image (or the image you built yourself)
           menci/syzoj-ng-demo

For more environment variables see the make config part in start.sh.

map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
}

server {
        server_name demo.syzoj.org;
        listen 80;

        # listen 443 ssl;
        # SSL configuration here

        # For MinIO
        ignore_invalid_headers off;
        client_max_body_size 0;
        proxy_buffering off;

        # Frontend
        location / {
                proxy_read_timeout 300s;
                proxy_send_timeout 300s;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection $connection_upgrade;
                proxy_set_header Accept-Encoding "";

                # There're some configuable items for frontend. See syzoj-ng-app's docs.
                # For, example:
                # sub_filter '__default_title__'    '"<your site name here>"';
                # sub_filter_once on;

                add_header Access-Control-Allow-Origin "https://demo.syzoj.org";

                # 172.20.0.2 is your docker container's IP. Same for below.
                proxy_pass http://172.20.0.2:2001;
        }

        # Backend
        location ~ (api|docs|docs-json) {
                proxy_read_timeout 300s;
                proxy_send_timeout 300s;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection $connection_upgrade;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

                proxy_pass http://172.20.0.2:2002;
        }

        # MinIO
        location /minio/ {
                proxy_set_header Host "127.0.0.1:2003"; # This is important
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_connect_timeout 300;
                proxy_http_version 1.1;
                proxy_set_header Connection "";
                chunked_transfer_encoding off;

                proxy_pass http://172.20.0.2:2003/;
        }
}

For adavnced usages please see syzoj-ng and syzoj-ng-app's docs.

Now you can login into your demo site with your admin account. Click the server icon on the footer of the page to go to "Judge Machine" management page. Add a judge machine and get its key with clicking the key icon. Then deploy syzoj-ng-judge with the key.

syzoj-ng-demo's People

Contributors

menci avatar

Stargazers

Asakura Mizu avatar

Watchers

James Cloos avatar  avatar  avatar

syzoj-ng-demo's Issues

How to deploy with Docker?

I have compiled the Dockerfile using:

sudo docker build -t syzojdemo.

After the image was built, I did:

sudo docker run -p 8080:80 436fe070f4e3

Then it outputs what looks like an error message:

HEAD is now at e689027 Update config
Please tell your frontend host (or IP:PORT) with -e FRONTEND. e.g. http://demo.syzoj.org
This host should be proxy_pass-ed to container:2001.

After this, whenever I try sudo docker start 58143fba4fa3, it starts and then promptly exits.

Is there something I did wrong?

Thank you very much!

Admin user breaks the UI

On the ranking page, when I click on the admin user, the UI breaks because of some missing data.

It seems, that the following information has to be added to the database:

insert into user_information (userId,organization,location,url,telegram,qq,github) values (1,'','','','','','');
insert into user_preference (userId,preference) values (1,'{}');

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.