# Docker Zerojudge ## Install & Run > https://github.com/jiangsir/ZeroJudge/tree/3.4.2 ### Choices of Image - leejoneshane/zerojudge - ~~johnny12150/zerojudge~~ 目前有bug暫不建議使用 ### Fetch/ pull image *注意*需先有mysql server, 如果沒請跑 `docker run --name mysql -e MYSQL_ROOT_PASSWORD=206207209 -d mysql:5.7` `docker run --name zero -e DB_HOST=172.17.0.2 -e DB_PASSWORD=206207209 -p 80:80 -d johnny12150/zerojudge` --- ### 網頁連結 - zerojudge default url: `http://localhost/` - zerojudge console url(可能要在進zerojudge設定): `http://localhost/ZeroJudge_Server/` 設定方法 > You can link the ZeroJudge System by http://localhost and http://localhost/ZeroJudge_Server/ > Please login with ==user:zero password:!@#$zerojudge== to manage your local ZeroJudge server. ### 新增題目 > https://github.com/jiangsir/ZeroJudge#%E5%8C%AF%E5%85%A5%E9%A1%8C%E5%BA%AB **注意** 這版的zjson內不可以包含key: `specialjudge_language` ### 客製化網頁 #### Homepage/ index - v3.3: /var/lib/tomcat8/webapps/ROOT **pdf資料夾也放此** #### Volume > https://ithelp.ithome.com.tw/articles/10192703 ![](https://i.imgur.com/qbHzEjC.png) For 放新檔案, mapping `ROOT` to `Local Drive` **Windows槽請用小寫** 把一開始的run換成(windows only) `docker run --name zero -e DB_HOST=172.17.0.2 -e DB_PASSWORD=206207209 -p 80:80 -v c:\Users\Wade\Downloads\ROOT:/usr/local/tomcat/webapps/ROOT/PDF -d leejoneshane/zerojudge` **-v如果遇到錯誤,可能是docker desktop下drive的權限沒設定** ![](https://i.imgur.com/96uHebt.png) <!-- ![](https://i.imgur.com/Igwc6zN.png) --> <!-- ![](https://i.imgur.com/Lbyfd6Q.png) --> ==create volume可以避免local的資料夾一開始是空的會覆蓋掉container內的== - `docker volume create --driver local --opt type=none --opt device=c:\Users\John\Downloads\ROOT --opt o=bind zerojudge` - `docker run --name zero -e DB_HOST=172.17.0.2 -e DB_PASSWORD=206207209 -p 80:80 -v zerojudge:/usr/local/tomcat/webapps/ROOT -d leejoneshane/zerojudge` ## Build your own image > https://ithelp.ithome.com.tw/articles/10191016?sc=hot `docker build -t zerojudge . --no-cache` ### Push it `docker tag zerojudge johnny12150/zerojudge` `docker push johnny12150/zerojudge` ## 常用指令 查mysql ip, `docker inspect mysql` ### Backup DB `docker exec mysql /usr/bin/mysqldump -u root — password=206207209 zerojudge > backup.sql` ### Restore `cat backup.sql | docker exec -i <CONTAINER> /usr/bin/mysql -u root --password=root <DATABASE>` ### Advanced way #### cron > https://github.com/fradelg/docker-mysql-cron-backup ``` docker container run -d \ --env MYSQL_USER=root \ --env MYSQL_PASS=206207209 \ --env MYSQL_DB=zerojudge\ --env CRON_TIME=0 3 * * *\ --link mysql --volume c:\Users\John\Downloads\sql_backup:/backup fradelg/mysql-cron-backup ``` For windows `docker container run -d --env MYSQL_USER=root --env MYSQL_PASS=206207209 --env MYSQL_DB=zerojudge --env CRON_TIME=0 3 * * * --link mysql --volume c:\Users\John\Downloads\sql_backup:/backup fradelg/mysql-cron-backup` #### ktor (by jetbrains) > https://medium.com/@math21/how-to-backup-your-database-from-a-mysql-docker-container-3fdd5769bad1 > https://medium.com/swlh/how-to-deploy-a-ktor-server-using-docker-dd01f4883c30