|
| 1 | +# Screeps Server <!-- omit in toc --> |
| 2 | + |
| 3 | +- [Create the world](#create-the-world) |
| 4 | +- [Running the server](#running-the-server) |
| 5 | +- [Additional setup steps](#additional-setup-steps) |
| 6 | +- [Managing the server](#managing-the-server) |
| 7 | +- [Stopping and starting the server](#stopping-and-starting-the-server) |
| 8 | +- [Updating](#updating) |
| 9 | +- [Troubleshooting](#troubleshooting) |
| 10 | + |
| 11 | +There are two different ways to start a screeps server. |
| 12 | +* [without a world](#create-the-world) |
| 13 | +* [with a world already created](#running-the-server) |
| 14 | + |
| 15 | +## Create the world |
| 16 | +If you do not have an existing server directory, just start the Docker container with the command line argument `init`, and everything gets done for you. The `LOCAL_UID` environment variable ensures that the files that are created in the mounted volume have the correct owner set. You can enter any valid (host) uid here. When omitted the default uid is `9001`. |
| 17 | + |
| 18 | +```bash |
| 19 | +docker run --rm -it -v ${PWD}/screeps:/screeps -e LOCAL_UID=$(id -u) -e STEAM_KEY=YOUR_STEAM_KEY_HERE qnimbus/docker-screeps init |
| 20 | +``` |
| 21 | +Now it's all set to run the Screeps server. |
| 22 | + |
| 23 | +## Running the server |
| 24 | +Make sure you have a server directory (from aprevious installations or by running the 'init' command above). |
| 25 | + |
| 26 | +You can use 'docker-compose' to start the screeps server, create the screeps_net bridged network and start the redis and mongodb instances. |
| 27 | + |
| 28 | +```bash |
| 29 | +docker-compose -f docker-compose.yml up -d |
| 30 | +``` |
| 31 | + |
| 32 | +If you want to start each container manually follow the steps below. |
| 33 | + |
| 34 | +1. Make sure you are in the server directory |
| 35 | +2. [Create the custom bridged network](#creating-network) |
| 36 | +3. [Start mongo & redis containers](#mongo-redis) |
| 37 | +4. Run the server |
| 38 | +```bash |
| 39 | +docker run --rm -it --name screeps --network screeps_net -v ${PWD}/screeps:/screeps -p 21025:21025 -p 21026:21026 -d -e LOCAL_UID=$(id -u) qnimbus/docker-screeps |
| 40 | +``` |
| 41 | + |
| 42 | +## Additional setup steps |
| 43 | + |
| 44 | +### Build your own container |
| 45 | + |
| 46 | +To build your own (customized) container locally, run the following command: |
| 47 | + |
| 48 | +```bash |
| 49 | +docker build . -t qnimbus/docker-screeps |
| 50 | +``` |
| 51 | + |
| 52 | +### Getting Steam API key |
| 53 | + |
| 54 | +Navigate to [https://steamcommunity.com/dev/apikey](https://steamcommunity.com/dev/apikey) and generate or copy your Steam API key. |
| 55 | + |
| 56 | +### <a name="creating-network"></a>Creating a bridged network for MongoDB and Redis |
| 57 | + |
| 58 | +You need to add the screeps, mongo and redis containers to a custom bridged network so the container names are resolvable via DNS on the individual containers. If you do not have a separate custom bridged network you can create one as follows: |
| 59 | + |
| 60 | +```bash |
| 61 | +docker network create --attachable -d "bridge" --subnet 172.28.0.0/16 screeps_net |
| 62 | +``` |
| 63 | + |
| 64 | +*Note: The subnet can be changed to your individual needs as well as the network name ('screeps_net')* |
| 65 | + |
| 66 | +### Starting and running MongoDB and Redis |
| 67 | + |
| 68 | +```bash |
| 69 | +docker run --rm --name redis --network screeps_net -d -v redis-volume:/data redis |
| 70 | +``` |
| 71 | + |
| 72 | +```bash |
| 73 | +docker run --rm --name mongo --network screeps_net -d -v mongo-volume:/data/db mongo |
| 74 | +``` |
| 75 | + |
| 76 | +### Creating a password |
| 77 | + |
| 78 | +In order to push your code to your private server you need a password (using `screepsmod-auth`) for your user. You can configure a password by pointing your browser at |
| 79 | +[http://127.0.0.1:21025/authmod/password/](http://127.0.0.1:21025/authmod/password/) or by typing `setPassword('your_password')` into the screeps console when logged in on the screeps client. |
| 80 | + |
| 81 | +## Managing the server |
| 82 | + |
| 83 | +### Mods |
| 84 | + |
| 85 | +Mods can be installed by running: |
| 86 | +```bash |
| 87 | +docker run --rm -v ${PWD}:/screeps -e LOCAL_UID=$(id -u) qnimbus/docker-screeps yarn add screepsmod-auth |
| 88 | +``` |
| 89 | +### CLI |
| 90 | + |
| 91 | +The CLI can be accessed by running: |
| 92 | + |
| 93 | +```bash |
| 94 | +docker exec -it screeps npx screeps cli |
| 95 | +``` |
| 96 | + |
| 97 | +### Useful CLI commands |
| 98 | + |
| 99 | +To reset server state & data: |
| 100 | + |
| 101 | +```bash |
| 102 | +system.resetAllData() |
| 103 | +``` |
| 104 | + |
| 105 | +You can create autonomous NPC bot players on your private server. They work as regular players, but you can specify their AI scripts in bots option at your mods.json file. Initially there is one AI loaded into your server, called simplebot, but you can always add more, and share with other players. |
| 106 | + |
| 107 | +To view all bot related command and list current active bots, type: |
| 108 | + |
| 109 | +```bash |
| 110 | +> help(bots); |
| 111 | +``` |
| 112 | + |
| 113 | +```bash |
| 114 | +> bots.removeUser('JackBot'); // Take note: this is the actual bot instance name, not 'bot-tooangel' for example. |
| 115 | +``` |
| 116 | + |
| 117 | +## Stopping and starting the server |
| 118 | +Stop: |
| 119 | +```docker stop screeps``` |
| 120 | +Start: |
| 121 | +```docker start screeps``` |
| 122 | + |
| 123 | +## Updating |
| 124 | + |
| 125 | +1. Stop the server: |
| 126 | + ```docker stop screeps``` |
| 127 | +2. Remove the server: |
| 128 | + ```docker rm screeps``` |
| 129 | +3. Remove current image |
| 130 | + ```docker rmi qnimbus/docker-screeps``` |
| 131 | +4. Follow [Running the server](#running-the-server) |
| 132 | + |
| 133 | +## Troubleshooting |
| 134 | + |
| 135 | +When running the docker commands from a Windows Git Bash shell (MSYS) you may need to prepend the `MSYS_NO_PATHCONV=1` environment variable to the commands, like so: |
| 136 | + |
| 137 | +```bash |
| 138 | + MSYS_NO_PATHCONV=1 docker run --rm -it -v ${PWD}:/screeps -e LOCAL_UID=$(id -u) -e STEAM_KEY=YOUR_STEAM_KEY_HERE qnimbus/docker-screeps init |
| 139 | +``` |
0 commit comments