源碼地址為:https://github.com/QingdaoU/OnlineJudge
可參考的文檔為:https://github.com/QingdaoU/OnlineJudgeDeploy/tree/2.0
一、安裝所依賴的環境
sudo apt-get update && sudo apt-get install -y vim python-pip curl git
sudo apt-get install docker-compose
二、使用Git克隆項目並完成部署
git clone -b 2.0 https://github.com/QingdaoU/OnlineJudgeDeploy.git && cd OnlineJudgeDeploy
docker-compose up -d(root用戶使用該命令)或sudo -E docker-compose up -d(非root用戶使用該命令)
用戶名和密碼分別是:root和rootroot
瀏覽器默認打開為:http://IP地址/
例如http://192.168.126.128,顯示界面如下:
三、常見問題
常見問題一
錯誤信息:ERROR: Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a version of "2" (or "2.0") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/
解決辦法:修改docker-compose.yml中的version由3改為2
常見問題二:
錯誤信息:ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?
解決辦法:
docker-compose up -d(root用戶使用)
非root執行會出現這個異常
非root應該執行這條命令
sudo -E docker-compose up -d
四、小結
這個OJ平台是國內開源的相對環境很好搭建的,其實參考官方文檔也能搭建,本人之所以寫,一來為自己,二為分享給其他朋友,讓他們盡可能少吃點虧。