Skip to content

Commit 17b6638

Browse files
committed
Move example to separate folder
1 parent d4549ac commit 17b6638

5 files changed

Lines changed: 194 additions & 184 deletions

File tree

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,8 @@ Logs/
258258
.idea/
259259

260260
# Test data
261-
**/Data/*.txt
261+
**/Data/*.txt
262+
263+
# Examples
264+
!examples/*/appsecrets.*
265+
examples/docker-compose/bf2

README.md

Lines changed: 11 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Modifying settings in `serversettings.con`, `modnanager.con` or `maplist.con` is
3030
## Prerequisites
3131

3232
* A host running Linux or Windows. The Docker setup is tested on Linux containers
33-
* A Battlefield 2 server with ModManager and the [mm_webadmin.py](https://github.com/nihlen/bf2-docker#bf2hub-pb-mm-webadmin) module
33+
* A Battlefield 2 server with ModManager and the [mm_webadmin.py](https://github.com/nihlen/bf2-docker/tree/master/images/bf2hub-pb-mm-webadmin) module
3434

3535
## Usage
3636

@@ -41,16 +41,21 @@ Build a Battlefield 2 server image with the required ModManager module:
4141
docker build -t bf2:bf2hub-pb-mm-webadmin https://github.com/nihlen/bf2-docker.git#master:images/bf2hub-pb-mm-webadmin
4242
```
4343

44+
Or build the container image locally with the .NET SDK:
45+
```sh
46+
dotnet publish "src/BF2WebAdmin.Server/BF2WebAdmin.Server.csproj" -c Release -t:PublishContainer -p:RuntimeIdentifier=linux-x64
47+
```
48+
4449
Then start up webadmin and the Battlefield 2 servers by running this command in the same directory as the `docker-compose.yml` and `appsecrets.json` files.
4550
```sh
46-
docker-compose up -d --remove-orphans
51+
docker compose up -d --remove-orphans
4752
```
4853

4954
If you need to update the game server image you can rerun the build command, and if you need to update the webadmin image you can run
5055
```sh
51-
docker-compose pull
56+
docker compose pull
5257
```
53-
and then rerun the docker-compose up-command.
58+
and then rerun the docker compose up-command.
5459

5560
### Windows build
5661

@@ -62,183 +67,6 @@ dotnet publish .\src\BF2WebAdmin.Server\BF2WebAdmin.Server.csproj -c Release -o
6267

6368
Create `Configuration/appsecrets.json` using the template further down, then run `BF2WebAdmin.Server.exe` and navigate to http://localhost:5000.
6469

65-
### Docker Compose Example
66-
67-
This is an example of webadmin and two Battlefield 2 servers running on the same host.
68-
69-
If you want to display the country of the players when joining then you need a free GeoIP database file from MaxMind and place `GeoLite2-Country.mmdb` in the same directory as `appsecrets.json`. Then bind mount it the same way in the volume section of the bf2-webadmin service `- "./GeoLite2-Country.mmdb:/app/GeoLite2-Country.mmdb"`.
70-
71-
docker-compose.yml
72-
```yaml
73-
version: "3.3"
74-
services:
75-
bf2-webadmin:
76-
container_name: bf2-webadmin
77-
image: "nihlen/bf2-webadmin:latest"
78-
restart: on-failure
79-
environment:
80-
- ASPNETCORE_ENVIRONMENT=Production
81-
- ASPNETCORE_URLS=http://+:80
82-
ports:
83-
- "80:80"
84-
- "4300:4300"
85-
volumes:
86-
- "./bf2/webadmin/Data:/app/Data"
87-
- "./bf2/webadmin/Logs:/app/Logs"
88-
- "./bf2/webadmin/ServerLogs:/app/ServerLogs"
89-
- "./appsecrets.json:/app/Configuration/appsecrets.json"
90-
91-
bf2-server-1:
92-
container_name: bf2-server-1
93-
image: "bf2:bf2hub-pb-mm-webadmin"
94-
restart: on-failure
95-
environment:
96-
- ENV_SERVER_NAME=Testserver 1
97-
- ENV_MAX_PLAYERS=16
98-
- ENV_SERVER_PORT=16567
99-
- ENV_GAMESPY_PORT=29900
100-
- ENV_DEMOS_URL=http://www.example.com/
101-
- ENV_RCON_PASSWORD=rconpw123
102-
- ENV_BF2WEBADMIN_HOST=bf2-webadmin
103-
- ENV_BF2WEBADMIN_PORT=4300
104-
- ENV_BF2WEBADMIN_TIMER_INTERVAL=300
105-
- ENV_API_KEY=apikey123
106-
volumes:
107-
- "./bf2/server-1/server:/home/bf2/srv"
108-
- "./bf2/server-1/volume:/volume"
109-
ports:
110-
- "8000:80/tcp"
111-
- "4711:4711/tcp"
112-
- "4712:4712/tcp"
113-
- "16567:16567/udp"
114-
- "27901:27901/udp"
115-
- "29900:29900/udp"
116-
117-
bf2-server-2:
118-
container_name: bf2-server-2
119-
image: "bf2:bf2hub-pb-mm-webadmin"
120-
restart: on-failure
121-
environment:
122-
- ENV_SERVER_NAME=Testserver 2
123-
- ENV_MAX_PLAYERS=16
124-
- ENV_SERVER_PORT=16569
125-
- ENV_GAMESPY_PORT=29901
126-
- ENV_DEMOS_URL=http://www.example.com/
127-
- ENV_RCON_PASSWORD=rconpw123
128-
- ENV_BF2WEBADMIN_HOST=bf2-webadmin
129-
- ENV_BF2WEBADMIN_PORT=4300
130-
- ENV_BF2WEBADMIN_TIMER_INTERVAL=300
131-
- ENV_API_KEY=apikey123
132-
volumes:
133-
- "./bf2/server-2/server:/home/bf2/srv"
134-
- "./bf2/server-2/volume:/volume"
135-
ports:
136-
- "8001:80/tcp"
137-
- "4721:4711/tcp"
138-
- "4722:4712/tcp"
139-
- "16569:16569/udp"
140-
- "27911:27901/udp"
141-
- "29901:29901/udp"
142-
143-
```
70+
## Examples
14471

145-
### Appsecrets Example
146-
147-
`ServerSettings:IpAddress` public IP of the host
148-
149-
Note: The ports, aliases and RCON passwords need to match between the game server (docker-compose file) and the appsettings.
150-
151-
appsecrets.json
152-
```json
153-
{
154-
"ConnectionStrings": {
155-
"BF2DB": "Data Source=./Data/BF2WebAdmin.sqlite;Cache=Shared"
156-
},
157-
"ServerSettings": {
158-
"IpAddress": "YOUR_PUBLIC_IP_ADDRESS",
159-
"Port": 4300,
160-
"StartFakeGameServer": false,
161-
"ServerLogDirectory": "ServerLogs",
162-
"PrintSendLog": false,
163-
"PrintRecvLog": false,
164-
"ForceHttps": false,
165-
"GameServers": [
166-
{
167-
"IpAddress": "bf2-server-1",
168-
"GamePort": 16567,
169-
"QueryPort": 29900,
170-
"RconPort": 4711,
171-
"RconPassword": "rconpw123",
172-
"DiscordBot": {
173-
"Token": "",
174-
"AdminChannel": "",
175-
"NotificationChannel": "",
176-
"MatchResultChannel": ""
177-
}
178-
},
179-
{
180-
"IpAddress": "bf2-server-2",
181-
"GamePort": 16569,
182-
"QueryPort": 29901,
183-
"RconPort": 4711,
184-
"RconPassword": "rconpw123",
185-
"DiscordBot": {
186-
"Token": "",
187-
"AdminChannel": "",
188-
"NotificationChannel": "",
189-
"MatchResultChannel": ""
190-
}
191-
}
192-
]
193-
},
194-
"Discord": {
195-
"Webhooks": [
196-
{
197-
"WebhookId": "",
198-
"WebhookToken": "",
199-
"ServerGroupFilter": "",
200-
"MessageTypeFilter": "player"
201-
}
202-
]
203-
},
204-
"Seq": {
205-
"ServerUrl": "",
206-
"ApiKey": ""
207-
},
208-
"Authentication": {
209-
"Admins": [
210-
{
211-
"Username": "admin",
212-
"Password": "test"
213-
}
214-
]
215-
},
216-
"RabbitMQ": {
217-
"Host": "",
218-
"Port": 5673,
219-
"VirtualHost": "",
220-
"UserName": "",
221-
"Password": ""
222-
},
223-
"Twitter": {
224-
"ConsumerKey": "",
225-
"ConsumerSecret": "",
226-
"AccessToken": "",
227-
"AccessTokenSecret": ""
228-
},
229-
"Mashape": {
230-
"Key": ""
231-
},
232-
"Geoip": {
233-
"DatabasePath": "GeoLite2-Country.mmdb"
234-
},
235-
"Logging": {
236-
"IncludeScopes": false,
237-
"LogLevel": {
238-
"Default": "Information",
239-
"System": "Information",
240-
"Microsoft": "Information"
241-
}
242-
}
243-
}
244-
```
72+
See the [docker compose example](examples/docker-compose/README.md)

examples/docker-compose/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Docker Compose Example
2+
3+
This is an example of webadmin and two Battlefield 2 servers running on the same host.
4+
5+
If you want to display the country of the players when joining then you need a free GeoIP database file from MaxMind and place `GeoLite2-Country.mmdb` in the same directory as `appsecrets.json`. Then bind mount it the same way in the volume section of the bf2-webadmin service `- "./GeoLite2-Country.mmdb:/app/GeoLite2-Country.mmdb"`.
6+
7+
`ServerSettings:IpAddress` public IP of the host
8+
9+
Note: The ports, aliases and RCON passwords need to match between the game server (docker-compose file) and the appsettings/appsecrets.
10+
11+
## Build container images
12+
13+
Build a BF2 game server image and a BF2 webadmin image needed for the example. Run it in the root folder of this repo.
14+
```sh
15+
docker build -t bf2:bf2hub-pb-mm-webadmin https://github.com/nihlen/bf2-docker.git#master:images/bf2hub-pb-mm-webadmin
16+
dotnet publish "src/BF2WebAdmin.Server/BF2WebAdmin.Server.csproj" -c Release -t:PublishContainer -p:RuntimeIdentifier=linux-x64
17+
```
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
"ConnectionStrings": {
3+
"BF2DB": "Data Source=./Data/BF2WebAdmin.sqlite;Cache=Shared"
4+
},
5+
"ServerSettings": {
6+
"IpAddress": "bf2-webadmin",
7+
"Port": 4300,
8+
"StartFakeGameServer": false,
9+
"ServerLogDirectory": "ServerLogs",
10+
"PrintSendLog": false,
11+
"PrintRecvLog": false,
12+
"ForceHttps": false,
13+
"GameServers": [
14+
{
15+
"IpAddress": "bf2-server-1",
16+
"GamePort": 16567,
17+
"QueryPort": 29900,
18+
"RconPort": 4711,
19+
"RconPassword": "rconpw123",
20+
"DiscordBot": {
21+
"Token": "",
22+
"AdminChannel": "",
23+
"NotificationChannel": "",
24+
"MatchResultChannel": ""
25+
}
26+
},
27+
{
28+
"IpAddress": "bf2-server-2",
29+
"GamePort": 16569,
30+
"QueryPort": 29901,
31+
"RconPort": 4711,
32+
"RconPassword": "rconpw123",
33+
"DiscordBot": {
34+
"Token": "",
35+
"AdminChannel": "",
36+
"NotificationChannel": "",
37+
"MatchResultChannel": ""
38+
}
39+
}
40+
]
41+
},
42+
"Discord": {
43+
"Webhooks": [
44+
{
45+
"WebhookId": "",
46+
"WebhookToken": "",
47+
"ServerGroupFilter": "",
48+
"MessageTypeFilter": "player"
49+
}
50+
]
51+
},
52+
"Seq": {
53+
"ServerUrl": "",
54+
"ApiKey": ""
55+
},
56+
"Authentication": {
57+
"Admins": [
58+
{
59+
"Username": "admin",
60+
"Password": "test"
61+
}
62+
]
63+
},
64+
"RabbitMQ": {
65+
"Host": "",
66+
"Port": 5673,
67+
"VirtualHost": "",
68+
"UserName": "",
69+
"Password": ""
70+
},
71+
"Twitter": {
72+
"ConsumerKey": "",
73+
"ConsumerSecret": "",
74+
"AccessToken": "",
75+
"AccessTokenSecret": ""
76+
},
77+
"Mashape": {
78+
"Key": ""
79+
},
80+
"Geoip": {
81+
"DatabasePath": "GeoLite2-Country.mmdb"
82+
},
83+
"Logging": {
84+
"IncludeScopes": false,
85+
"LogLevel": {
86+
"Default": "Information",
87+
"System": "Information",
88+
"Microsoft": "Information"
89+
}
90+
}
91+
}

0 commit comments

Comments
 (0)