Skip to content

Commit

Permalink
Merge pull request #233 from Dahlgren/feature/docker
Browse files Browse the repository at this point in the history
Docker image
  • Loading branch information
Dahlgren authored Dec 28, 2022
2 parents b1b043c + 09743cf commit b851139
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.git
config.js
Dockerfile
docker-compose.yml
node_modules
package-lock.json
servers.json
24 changes: 24 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Docker

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
name: Build
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Docker build
run: docker build . --tag arma-server-web-admin

- name: Docker run tests
run: docker run --env GAME_TYPE=arma3 --env GAME_PATH=/arma3 arma-server-web-admin npm test
1 change: 1 addition & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
strategy:
matrix:
node-version:
- 16.x
- 14.x
- 12.x
- 10.x
Expand Down
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM node:16-slim

# Install arma dependencies
RUN dpkg --add-architecture i386 && apt-get update && apt-get install -y git lib32stdc++6 zlib1g:i386 && apt-get clean && rm -rf /var/lib/apt/lists/*

# Install node dependencies for the application
RUN mkdir /app
COPY package.json /app/package.json
WORKDIR /app
RUN npm install

# Install Docker config
COPY config.docker.js /app/config.js

# Create empty servers config
RUN echo '[]' > /app/servers.json

# Copy rest of application to image
COPY . /app/

# Start application
CMD npm start

# Declare application port
EXPOSE 3000
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,62 @@ Make sure to disable Wine GUI Crash Dialog or server control will be stuck on a
This is easiest solved using `winetricks` by running `winetricks nocrashdialog`.
It can also be disabled manually.
[Read more at Wine FAQ](http://wiki.winehq.org/FAQ#head-c857c433cf9fc1dcd90b8369ef75c325483c91d6).

## Docker

### Example

To host an Arma 3 x64 server with an existing Arma 3 Server install in subfolder `arma3` with persisted profiles in `profiles` and shared network with host,

```sh
mkdir -p arma3 profiles
touch servers.json
docker run \
--network=host \
--env GAME_TYPE=arma3_x64 \
--env GAME_PATH=/arma3 \
--volume $PWD/arma3:/arma3 \
--volume $PWD/servers.json:/app/servers.json \
--volume $PWD/profiles:"/root/.local/share/Arma 3 - Other Profiles" \
dahlgren/arma-server-web-admin
```

### Required setup

Mount a preinstalled Arma server folder to the container, currently only the linux server is supported.
Set GAME_TYPE to your desired arma server, for example `--env GAME_TYPE=arma3` or `--env GAME_TYPE=arma3_x64`.
Set GAME_PATH to your mounted volume, for example `--env GAME_PATH=/arma3` and `--volume $PWD/arma3:/arma3`.

### Networking
Host preferably needs to share network with the container or all game ports used will need to be forwarded to the container.
Use `--network=host` to use same network as the host machine.

Web Admin UI is available at port 3000.
If you use `--network=host` you can reach the web ui at `http://localhost:3000` by default.

### Persistence

#### Servers

Mount a file at `/app/servers.json` to persist the servers config.
For example `--volume $PWD/servers.json:/app/servers.json` to use a file named `servers.json` in current folder as persistent servers config file.

#### Profiles

If you need to persist the server profiles such as vars file make sure to mount a volume.
For Arma 3 the default profiles directory will be located at `/root/.local/share/Arma 3 - Other Profiles`

### Environment Variables

Key | Description
--- | ---
GAME_PATH | Required. Absolute folder path to game server in docker container
GAME_TYPE | Required. Type of game server, see above
AUTH_USERNAME | Username used for HTTP Basic Auth
AUTH_PASSWORD | Password used for HTTP Basic Auth
SERVER_ADMINS | Steam IDs that should be set as admins
SERVER_ADDITIONAL_CONFIG | Additional content to add into server.cfg
SERVER_MODS | Mods to be loaded as server side only mods
SERVER_PARAMETERS | Additional parameters to pass on server launch
SERVER_PREFIX | Prefix on all server names
SERVER_SUFFIX | Suffix on all server names
25 changes: 25 additions & 0 deletions config.docker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
for (var environmentVariable of ['GAME_TYPE', 'GAME_PATH']) {
if (!process.env[environmentVariable]) {
console.log('Missing required environment variable "' + environmentVariable + '"')
process.exit(1)
}
}

module.exports = {
game: process.env.GAME_TYPE,
path: process.env.GAME_PATH,
port: process.env.PORT || 3000,
host: process.env.HOST || '0.0.0.0',
type: 'linux',
additionalConfigurationOptions: process.env.SERVER_ADDITIONAL_CONFIG,
parameters: (process.env.SERVER_PARAMETERS || '').split(','),
serverMods: (process.env.SERVER_MODS || '').split(','),
admins: (process.env.SERVER_ADMINS || '').split(','),
auth: {
username: process.env.AUTH_USERNAME,
password: process.env.AUTH_PROCESS
},
prefix: process.env.SERVER_PREFIX,
suffix: process.env.SERVER_SUFFIX,
logFormat: process.env.LOG_FORMAT || 'dev'
}

0 comments on commit b851139

Please sign in to comment.