├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── add.sh ├── build.sh ├── cli.sh ├── docker-compose.yaml ├── docker-entrypoint.sh ├── install.sh ├── start.sh ├── start_with_mongo.sh ├── stop.sh └── stop_with_mongo.sh /.gitignore: -------------------------------------------------------------------------------- 1 | screeps-server/**/* 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:10.16.3-stretch 2 | VOLUME /screeps 3 | WORKDIR /screeps 4 | 5 | COPY "docker-entrypoint.sh" / 6 | ENTRYPOINT ["/docker-entrypoint.sh"] 7 | 8 | CMD ["run"] 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Adam Shumann 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-screeps-toolbox 2 | 3 | docker screeps 服务器部署工具包,用于简化 screeps 游戏服务部署流程,并针对国内网络进行了优化。需要提前安装 docker 以及 docker-compose(*如果打算使用 mongo 的话*)。 4 | 5 | # 脚本 6 | 7 | 本工具包提供如下脚本,你可以在 [这里](https://www.jianshu.com/p/91ab3ccc537b) 找到具体的使用方法: 8 | 9 | **构建运行时镜像** 10 | 11 | ``` 12 | ./build.sh 13 | ``` 14 | 15 | **部署服务器** 16 | 17 | ``` 18 | ./install.sh 19 | ``` 20 | 21 | **运行服务器** 22 | 23 | ``` 24 | ./start.sh 25 | ``` 26 | 27 | **停止服务器** 28 | 29 | ``` 30 | ./stop.sh 31 | ``` 32 | 33 | **进入命令行** 34 | 35 | ``` 36 | ./cli.sh 37 | ``` 38 | 39 | **安装 mod** 40 | 41 | ``` 42 | ./add.sh [要安装的 mod 名称,不需要加中括号] 43 | ``` 44 | 45 | **运行添加了 mongo 的服务器** 46 | 47 | ``` 48 | ./start_with_mongo.sh 49 | ``` 50 | 51 | **关闭添加了 mongo 的服务器** 52 | 53 | ``` 54 | ./stop_with_mongo.sh 55 | ``` 56 | -------------------------------------------------------------------------------- /add.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | # 用于给游戏服务器添加 mod,需要先关闭游戏服务器 3 | 4 | IMAGE_NAME="hopgoldy-screeps-server" 5 | cd screeps-server 6 | 7 | if [ ! -n "$1" ] 8 | then 9 | echo "安装失败,请指定要安装的 mod" 10 | else 11 | echo "正在安装 $1" 12 | docker run -it --rm \ 13 | -v $PWD:/screeps \ 14 | ${IMAGE_NAME} \ 15 | sh -c " 16 | yarn config set registry https://registry.npm.taobao.org & \ 17 | yarn add $1 18 | " 19 | fi 20 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 用于构建游戏运行时镜像 3 | 4 | IMAGE_NAME="hopgoldy-screeps-server" 5 | 6 | docker build -t ${IMAGE_NAME} . 7 | -------------------------------------------------------------------------------- /cli.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | # 用于启动游戏服务器 cli 3 | 4 | CONTAINER_NAME="screeps-server" 5 | 6 | docker exec -it ${CONTAINER_NAME} npx screeps cli 7 | -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: "3.5" 2 | services: 3 | server: 4 | container_name: "screeps-server" 5 | image: "hopgoldy-screeps-server" 6 | depends_on: 7 | - redis 8 | - mongo 9 | volumes: 10 | - $PWD/screeps-server:/screeps 11 | networks: 12 | - screeps-net 13 | ports: 14 | - 21025:21025 15 | 16 | redis: 17 | image: "redis:3.0.6" 18 | networks: 19 | - screeps-net 20 | volumes: 21 | - screeps-redis-db:/data 22 | expose: 23 | - 6379 24 | 25 | mongo: 26 | image: "mongo:2.6.4" 27 | networks: 28 | - screeps-net 29 | volumes: 30 | - screeps-mongo-db:/data/db 31 | expose: 32 | - 27017 33 | 34 | networks: 35 | screeps-net: 36 | 37 | volumes: 38 | screeps-redis-db: 39 | screeps-mongo-db: 40 | -------------------------------------------------------------------------------- /docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | function init_srv(){ 5 | echo "===== SETTING UP SCREEPS =====" 6 | yarn init -y 7 | yarn config set registry https://registry.npm.taobao.org 8 | yarn add screeps 9 | npx screeps init 10 | } 11 | 12 | function run_srv(){ 13 | cd /screeps 14 | exec npx screeps start 15 | } 16 | 17 | case $1 in 18 | init) 19 | init_srv 20 | ;; 21 | run) 22 | run_srv 23 | ;; 24 | *) 25 | exec "$@" 26 | ;; 27 | esac 28 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | # 用于初始化 screeps 游戏服务器 3 | 4 | IMAGE_NAME="hopgoldy-screeps-server" 5 | 6 | mkdir screeps-server 7 | cd screeps-server 8 | 9 | docker run -it --rm -v $PWD:/screeps ${IMAGE_NAME} init 10 | -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | # 用于启动游戏服务器(未使用 mongo 时),需要先执行 install.sh 3 | 4 | IMAGE_NAME="hopgoldy-screeps-server" 5 | cd screeps-server 6 | 7 | docker run -d \ 8 | --name screeps-server \ 9 | -v $PWD:/screeps \ 10 | -p 21025:21025 \ 11 | ${IMAGE_NAME} 12 | -------------------------------------------------------------------------------- /start_with_mongo.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | # 用于启动游戏服务器(使用 mongo 时),需要先安装 screepsmod-mongo 3 | 4 | docker-compose -p screeps up -d 5 | -------------------------------------------------------------------------------- /stop.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | # 用于关闭基础游戏服务器(未使用 mongo) 3 | 4 | CONATINER_NAME="screeps-server" 5 | 6 | docker container stop ${CONATINER_NAME} && \ 7 | docker container rm ${CONATINER_NAME} 8 | -------------------------------------------------------------------------------- /stop_with_mongo.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | # 用于关闭使用 mongo 的游戏服务器 3 | 4 | docker-compose -p screeps down 5 | --------------------------------------------------------------------------------