1 Star 2 Fork 0

EXP/ark-server-docker

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

ARK-server-docker

docker 一键部署 ARK(方舟-生存进化)


0x00 介绍

此为 steam 版 ARK 的 docker 服务端,可用于搭建私人联机服务器。

搭建过程只用到官方原生的 SteamCMD dockerARK Server configuration 配置。

此工程没有引入网上其他比较热门的 ARK 部署工具,所以它们的配置项均不适用

0x10 运行环境

0x10 硬件要求

硬件 最低配置 推荐配置 流畅配置
CPU 2C 4C 8C
内存 6G 8G 16G
虚拟内存 4G 4G 4G
硬盘 50G 100G 100G

ARK 当前版本的服务端大小为 18812537984 bytes,约 18G,因为要从 steam 服务器下载,所以国内非常慢甚至连接不上。建议使用香港或韩国的云主机,从海外下载速度较快且不会被 GFW 拦截、国内也有不错的访问速度

0x30 部署步骤

0x31 预操作

  1. 使用 root 用户安装 python3、 docker、 docker-compose、 git
  2. 使用 root 用户设置虚拟内存(推荐 4G)
  3. 添加 id=1000 的用户到 docker 组: usermod -aG docker $(grep 1000 /etc/passwd | awk -F: '{print $1}')
  4. 切换到 id=1000 的用户: su - $(grep 1000 /etc/passwd | awk -F: '{print $1}')
  5. 之后所有步骤使用 id=1000 的用户执行

之所以要使用 id=1000 的用户,是因为下面构建的 SteamCMD docker 镜像内也强制使用了 id=1000 的用户(steam)。

由于 docker 需要从宿主机挂载服务端的游戏目录,如果宿主机使用 root 用户挂载,会导致 docker 内的用户没有权限而无法读写。所以宿主机需要使用 id=1000 的用户启动 docker。

在 Linux 中, root 的 id=0, 而 1-999 是保留给系统用户的,普通用户的 id 从 1000 开始,docker 内一般只有一个普通用户,故默认 id=1000。

0x31 部署镜像

  1. 下载此仓库: git clone --depth 1 --branch master https://github.com/lyy289065406/ark-server-docker.git
  2. 进入根目录: cd ark-server-docker
  3. 构建镜像: bin/build.[sh|ps1](镜像中不含游戏本体,只有用于下载游戏的 SteamCMD
  4. 运行镜像: bin/run_docker.[sh|ps1]

如果不想自己构建镜像,可以使用现成的镜像: expm02/ark-server-docker:latest

0x32 部署 ARK 服务端(SteamCMD 通道)

安装游戏: bin/install_game.[sh|ps1],此为命令执行后会打开 SteamCMD 交互终端,依次输入:

  1. 创建 ARK 游戏目录: force_install_dir /home/steam/games/ark
  2. 匿名登录 steam : login anonymous
  3. 下载 ARK 服务端: app_update 376030(游戏约 18G,超级慢而且可能失败)

app_update 376030 可能会因为网络原因多次失败,重新执行即可,会断点下载

关于 steam app id 376030 ...

在 steam 中每个游戏都有一个唯一且固定的 APP ID,可以在商店页面地址中查看(跟在 /app/ 后的数字):

APP ID 游戏名称 描述
346110 ARK: Survival Evolved ARK 游戏客户端
376030 ARK: Survival Evolved Dedicated Server ARK 专用服务端

0x32 部署 ARK 服务端(Github 通道)

SteamCMD 通道无法安装成功时,可使用此方法(否则应该跳过):

展开
  1. 创建 Github 账号(若已有则跳过)
  2. 配置 Github SSH
  3. Frok 此仓库(目的是使用 SSH 下载): https://github.com/lyy289065406/ark.git
  4. 创建并切换工作目录: volumes/steam/games
  5. 使用 SSH 下载到该目录: git clone --depth 1 --branch master git@github.com:${你的用户名}/ark.git
  6. 切换工作目录: cd ark
  7. 解压大文件: bin/unpack_7zip.[sh|ps1](需要预装 7-zip 命令行)

更多细节详见 ARKREADME.md 说明

0x40 暴露服务

协议 端口 是否必要 用途
UDP 7777 服务端对玩家开放的端口,已硬编码不可修改
UDP 7778 同上
UDP 27015 被 steam 服务器列表搜索服务端所用的端口,已硬编码不可修改
TCP 32330 RCON 服务器在线管理工具的端口

以上端口均需要:

  • docker 映射到宿主机(已配置到 docker-compose.yml
  • 主机防火墙准入(Linux 若没有安装 iptables 则不需要)
  • 云主机配置安全组策略

0x50 运行 ARK 服务端

  1. 启动 ARK 服务端: bin/run_ark.[sh|ps1] -p ${服务器密码}(默认密码已经公开,建议重新指定)
  • ARK 启动约需 10 ~ 15 分钟,如果想验证是否启动成功,可以进入 docker 终端: bin/terminal.[sh|ps1]
  • 输入命令 netstat -nua 查看当前监听的 UDP 端口,只要把 7777 和 7778 端口刷出来则表示已成功启动

  1. steam 添加服务器:
  • 查看 -> 服务器 -> 收藏夹
  • 添加服务器 -> 填写 ${云主机公网 IP}:27015 -> 在此地址上寻找游戏 ...
  • 当在列表中看到自己的服务器名字后,点击 将选定游戏服务器添加至收藏夹

  1. steam 开始游戏:
  • 加入线上方舟
  • 筛选服务器 -> 收藏
  • 加入 -> 输入 服务器密码
  • 和小伙伴愉快游戏吧 ~

0x60 关于定制 ARK 启动配置

通过 bin/run_ark.[sh/ps1] 实际上是调用了 ARK 的核心启动脚本 bin/ark.sh,它默认配置了一些常用配置项:

分类 配置项 默认值 用途
可控 SessionName EXP_ARK_Server 在 steam 服务器列表上看到的名称
可控 MaxPlayers 10 能进入服务器的最大玩家数量
可控 ServerPassword EXP123456 玩家进入服务器时需要提供的密码
可控 ServerAdminPassword ADMIN654321 管理员激活 RCON 控制台的密码。
游戏内按 Tab打开控制台输入命令,游戏外可以安装 RCON Web Admin 输入命令。
ARK 的 RCON 命令详见这里,物品 ID 详见这里
可控 ServerMap TheIsland 服务器地图
可控 GameModIds 服务器已安装支持的 MOD ID 列表
可控 ActiveMods 服务器当前激活的 MOD ID 列表
可控 DifficultyOffset 0.2 游戏难度。难度越高、怪物等級越高
可控 HarvestAmountMultiplier 1.0 资源获得倍率,最大值 3 。
影响行为包括:砍伐树木、采摘浆果、分解尸体、开采岩石等
可控 TamingSpeedMultiplier 1.0 驯服恐龙倍率,最大值未知。此项越大、驯服速度越快
可控 ResourcesRespawnPeriodMultiplier 1.0 资源重生倍率。此项越小、重生速率越快。资源包括:树木、岩石、灌木等
可控 CropGrowthSpeedMultiplier 1.0 作物生长倍率。此项越大、作物成长越快
可控 XPMultiplier 1.0 指定玩家、部落和恐龙在各种行动中获得的经验获得倍率。此项越大、获得经验越多
硬编码 serverPVE True PVE 模式
硬编码 RCONEnabled True 是否启用 RCON 协议管理游戏
硬编码 RCONPort 32330 RCON 的服务端口
硬编码 servergamelog 记录 Admin 在 RCON 的操作日志
硬编码 ShowFloatingDamageText True 类似 RPG 游戏浮现伤害文字
硬编码 AllowFlyerCarryPvE True 在 PvE 模式中,允许玩家在骑乘翼龙时、捡起其他恐龙和玩家
硬编码 bAllowPlatformSaddleMultiFloors True 允许建筑多个平台楼层
硬编码 ServerAutoForceRespawnWildDinosInterval 服务器重启时强制刷新野生恐龙
硬编码 AutoDestroyStructures 随着时间推移,自动销毁附近废弃的部落建筑
硬编码 NoBattlEye 不启动 BattleEye 反作弊工具
硬编码 crossplay 允许跨平台(Epic 和 Steam 互通)
硬编码 usecache 加快 70% 的加载速度
硬编码 server 作为服务器启动(可有可无)
硬编码 log 在游戏内记录部落日志(默认按 L 查看)

启动过一次服务端后,会在 ShooterGame/Saved/Config/LinuxServer/ 目录下自动创建 GameUserSettings.iniGame.ini 配置文件,可以参考 ARK Server configuration 的参数说明修改这些配置文件。

除了上表的可控配置项,均可在配置文件中修改。否则需要修改脚本 bin/ark.sh

  1. 修改完成后,需要停止镜像: bin/stop.[sh|ps1]
  2. 如果修改过 bin/ark.sh,还需要重新构建镜像: bin/build.[sh|ps1]
  3. 再次运行镜像: bin/run_docker.[sh|ps1]
  4. 然后运行 ARK 服务端: bin/run_ark.[sh|ps1]

0x70 重启服务

只有第一次需要执行上述的步骤,配置好之后,只需要简单 3 条命令即可:

  1. 停止镜像: bin/stop.[sh|ps1]
  2. 运行镜像: bin/run_docker.[sh|ps1](参数见脚本内)
  3. 运行 ARK: bin/run_ark.[sh|ps1](参数见脚本内)

0x80 迁移服务

服务启动后会自动生成以下 3 个目录:

  • 配置目录: ./volumes/steam/games/ark/ShooterGame/Saved/Config/*
  • 存档目录: ./volumes/steam/games/ark/ShooterGame/Saved/SavedArks/*
  • 日志目录: ./volumes/steam/games/ark/ShooterGame/Saved/Logs/*

迁移前可以执行脚本 bin/backup.[sh|ps1] 将其备份到 backup 目录。

建议设置 crontab -e 定时任务自动备份 :

# 每小时备份一次存档
# 其中把 ${ARK_DIR} 换成实际 ark-server-docker 工程的绝对路径
# 例如: /home/steam/workspace/github/ark-server-docker
0 */1 * * * cd ${ARK_DIR} && bin/backup.sh > /tmp/backup.log

bin/backup.[sh|ps1] 脚本会自动删除 3 天前的存档记录,避免服务器硬盘溢出

0x90 安装 MOD

ark-mods 仓库中列出了推荐的 MOD。

把期望要安装的 MOD 复制到 ./volumes/steam/games/ark/ShooterGame/Content/Mods 目录后,在使用 bin/run_ark.[sh|ps1] 脚本启动服务器时,通过 -i ${MOD_IDS} 按需指定即可。

详见 《在 ARK 安装 MOD 指引

0xA0 定制个性化脚本

虽然用 bin/run_ark.[sh|ps1] 脚本可以一键启动,但是定制个性化服务时的启动参数还是太多,不方便记忆。

所以可以自行再添加一些封装脚本在 sbin 目录(此目录不会把文件同步到 Git 仓库),可以参考样例 sbin/onekey_demo.sh

#!/bin/bash
# sbin/onekey_demo.sh
#------------------------------------------------
# 示例:sbin/onekey_demo.sh 
#           [-s ${ServerName}]                  # 服务器名称(在 steam 服务器上看到的)
#           [-m ${MapName}]                     # 地图名
#           [-c ${PlayerAmount}]                # 最大玩家数
#           [-p ${ServerPassword}]              # 服务器密码
#           [-a ${AminPassword}]                # 管理员密码
#           [-d ${Difficulty}]                  # 游戏难度
#           [-h ${HarvestAmount}]               # 资源获得倍率
#           [-t ${TamingSpeed}]                 # 驯服恐龙倍率
#           [-r ${ResourcesRespawnPeriod}]      # 资源重生倍率
#           [-g ${CropGrowthSpeed}]             # 作物生长倍率
#           [-x ${XPMultiplier}]                # 经验获得倍率
#           [-i ${ModIds}]                      # 地图 MOD ID 列表,用英文逗号分隔
#------------------------------------------------

# 启动容器
bin/run_docker.sh
sleep 5

# 启动 ARK 服务端
bin/run_ark.sh  -s "EXP_ARK_Server" -p "EXP123456" -a "ADMIN654321" \
                -h "3" -t "5" -r "0.5" -g "2" -x "10" -c "10" \
                -m "Ragnarok" -i "1404697612,928102085,2885013943,751991809,731604991,889745138,902616446,1211297684,893904615,895711211,1232362083,618916953,722649005"

0xB0 升级服务端

因为 steam 的客户端会自动升级,当版本不匹配时,客户端无法找到服务端,此时需要使用 steam 通道在线升级:

  1. 重新构建镜像(因为新版本需要更新 SteamCMD 才能下载): bin/build.[sh|ps1] -c OFF
  2. 启动容器: bin/run_docker.[sh|ps1]
  3. 打开 steam 交互终端: bin/install_game.[sh|ps1]
  4. 匿名登录 steam : login anonymous
  5. 更新 ARK 服务端: app_update 376030 validate(游戏约 18G,超级慢而且可能失败)

0xC0 更多脚本说明

  • 构建 ARK 环境镜像: bin/build.[sh|ps1]
  • 发布 ARK 环境镜像: bin/deploy.[sh|ps1]
  • 运行 ARK 环境容器: bin/run_docker.[sh|ps1](参数见脚本内)
  • 安装 ARK 服务端: bin/install_game.[sh|ps1]
  • 运行 ARK 服务端: bin/run_ark.[sh|ps1](参数见脚本内)
  • 进入 ARK 环境容器终端: bin/terminal.[sh|ps1](参数见脚本内)
  • 停止 ARK 服务端与环境容器: bin/stop.[sh|ps1]
  • 备份 ARK 服务端存档: bin/backup.[sh|ps1]
  • 恢复 ARK 服务端存档: bin/recover.[sh|ps1]
  • 清除 ARK 服务端存档、配置和日志文件: bin/clean.[sh|ps1]

0xFF 参考文档

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

docker 一键部署 ARK 私服(方舟-生存进化) 展开 收起
README
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/exppoc/ark-server-docker.git
git@gitee.com:exppoc/ark-server-docker.git
exppoc
ark-server-docker
ark-server-docker
master

搜索帮助