codecombat.jpg

流程记录

前期准备

新建并运行容器
$ docker run -it --name $CONTAINER_NAME -p 3000:3000 -w /root debian:stretch /bin/bash
容器运行起来以后,之后操作就是在容器里。
开始切换源(使用国内源进行下载加速)
$ echo "deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib" > /etc/apt/sources.list
$ echo "deb http://mirrors.aliyun.com/debian-security stretch/updates main" >> /etc/apt/sources.list
$ echo "deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib" >> /etc/apt/sources.list
$ echo "deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib" >> /etc/apt/sources.list
安装后如果提示还缺什么,需要自行安装。(如果提示已安装就跳过)
配置你的Git信息
$ git config --global user.name "$YOUR_NAME"
$ git config --global user.email "$YOUR_EMAIL_ADDRESS"
安装 node.js 6(只能是这个版本)
$ curl -L https://deb.nodesource.com/setup_6.x | bash -
$ apt-get install -y nodejs
$ npm config set registry https://registry.npm.taobao.org
$ npm config set python python2.7
安装MongoDB-2.6(推荐MongoDB-3以下的版本)
$ echo "deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen" | tee /etc/apt/sources.list.d/mongodb.list
$ apt-get update
$ apt-get install -y --allow-unauthenticated mongodb-org
将 MongoDB 先运行起来,后续操作需要导入游戏基础数据库,数据库从官法提供的网址下载,解压后导入到本地数据库中。
$ service mongod start
$ curl -L http://analytics.codecombat.com:8080/dump.tar.gz | tar xzvf -
$ mongorestore --drop dump


以上的步骤不能保证未来的任何时候都能正确执行,如果不能执行了,我已将所需文件分享到百度云,请自行下载后解压,再继续执行后面的命令。

开启服务

获取 CodeCombat 源代码,并切换到最后保留了服务器源代码的分支。
$ mkdir coco
$ cd coco
$ git init
$ git remote add origin https://github.com/codecombat/codecombat.git
$ git fetch origin production
$ git checkout 2642fd2a97d86bc8c324b2193bf2d4bcb1cf4ee7
安装依赖文件,准备运行环境。
$ npm install node-sass
$ npm install --ignore-scripts
$ npm run bower -- install --allow-root
$ npm install
编译前端页面,开启服务器。
$ npm run webpack
$ npm run nodemon
之后再次启动需要执行以下命令。
$ docker start $CONTAINER_NAME
$ docker exec -it -w /root/coco $CONTAINER_NAME sh -c "service mongod start && npm run nodemon"

如果觉得太麻烦,也可以用 Docker 直接导入容器开始游戏,容器已经分享到百度云。

导入准备好的容器镜像文件,创建容器。
$ docker import coco.tar $IMAGE_NAME
$ docker create -it --name $CONTAINER_NAME -p 3000:3000 -w /root/coco $IMAGE_NAME sh -c "service mongod start && npm run nodemon"
启动(停止)容器只需要以下命令。
$ docker start $CONTAINER_NAME
$ docker stop $CONTAINER_NAME

打开你的浏览器输入地址:localhost:3000,开始免费畅玩!
网盘里包含一个虚拟机镜像,下载打开即可。
另外两个是游戏本体与数据库,也可以使用docker导入。
文献参考:https://gon.gyeq.in/2018/2CYQHTC/
网盘地址:https://pan.baidu.com/xxx/

文章声明

注:本文章仅用于个人学习Codecombat代码结构,切勿进行非法传播。现已按 Codecombat官方要求关闭下载链接,个人学习可联系邮箱分享学习心得:Yunqian866@gmail.com

Last modification:December 2nd, 2021 at 01:12 pm
如果觉得我的文章对你有用,请随意赞赏