Skip to content

Commit d378790

Browse files
author
Slyke
committed
Expanded upon custom services and settings
1 parent 395ebf3 commit d378790

File tree

1 file changed

+106
-4
lines changed

1 file changed

+106
-4
lines changed

docs/Custom.md

Lines changed: 106 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
# Custom containers and settings for docker-compose
1+
# Custom services and overriding default settings for IOTstack
22
You can specify modifcations to the `docker-compose.yml` file, including your own networks and custom containers/services.
33

44
Create a file called `compose-override.yml` in the main directory, and place your modifications into it. These changes will be merged into the `docker-compose.yml` file next time you run the build script.
55

66
## How it works
77
1. After the build process has been completed, a temporary docker compose file is created in the `tmp` directory.
88
2. The script then checks if `compose-override.yml` exists:
9-
1. If it exists, then continue to step `3`
10-
2. If it does not exist, copy the temporary docker compose file to the main directory and rename to `docker-compose.yml`.
9+
* If it exists, then continue to step `3`
10+
* If it does not exist, copy the temporary docker compose file to the main directory and rename it to `docker-compose.yml`.
1111
3. Using the `yaml_merge.py` script, merge both the `compose-override.yml` and the temporary docker compose file together; Using the temporary file as the default values and interating through each level of the yaml structure, check to see if the `compose-override.yml` has a value set.
1212
4. Output the final file to the main directory, calling it `docker-compose.yml`.
1313

14-
## Example
14+
## Examples
15+
16+
### Overriding default settings
1517
For example, lets assume you put the following into the `compose-override.yml` file:
1618
```
1719
services:
@@ -89,3 +91,103 @@ services:
8991
- ./services/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf
9092
- ./services/mosquitto/filter.acl:/mosquitto/config/filter.acl
9193
```
94+
95+
### Adding custom services
96+
97+
Custom services can be added in a similar way to overriding default settings for standard services. Lets add a Minecraft and rcon server to IOTstack.
98+
Firstly, put the following into `compose-override.yml`:
99+
```
100+
services:
101+
minecraft:
102+
image: itzg/minecraft-server
103+
ports:
104+
- "25565:25565"
105+
volumes:
106+
- "./services/minecraft:/data"
107+
environment:
108+
EULA: "TRUE"
109+
TYPE: "PAPER"
110+
ENABLE_RCON: "true"
111+
RCON_PASSWORD: "PASSWORD"
112+
RCON_PORT: 28016
113+
VERSION: "1.15.2"
114+
REPLACE_ENV_VARIABLES: "TRUE"
115+
ENV_VARIABLE_PREFIX: "CFG_"
116+
CFG_DB_HOST: "http://localhost:3306"
117+
CFG_DB_NAME: "IOTstack Minecraft"
118+
CFG_DB_PASSWORD_FILE: "/run/secrets/db_password"
119+
restart: unless-stopped
120+
rcon:
121+
image: itzg/rcon
122+
ports:
123+
- "4326:4326"
124+
- "4327:4327"
125+
volumes:
126+
- "./rcon_data:/opt/rcon-web-admin/db"
127+
128+
secrets:
129+
db_password:
130+
file: ./db_password
131+
```
132+
133+
Then create the service directory that the new instance will use to store persistant data:
134+
135+
`mkdir -p ./volumes/minecraft`
136+
137+
and
138+
139+
`mkdir -p ./volumes/rcon_data`
140+
141+
Obviously you will need to give correct folder names depending on the `volumes` you specify for your custom services. If your new service doesn't require persistant storage, then you can skip this step.
142+
143+
Then simply run the `./menu.sh` command, and rebuild the stack with what ever services you had before.
144+
145+
Using the Mosquitto example above, the final `docker-compose.yml` file will look like:
146+
147+
```
148+
version: '3.6'
149+
services:
150+
mosquitto:
151+
container_name: mosquitto
152+
image: eclipse-mosquitto
153+
restart: unless-stopped
154+
user: "1883"
155+
ports:
156+
- 1883:1883
157+
- 9001:9001
158+
volumes:
159+
- ./volumes/mosquitto/data:/mosquitto/data
160+
- ./volumes/mosquitto/log:/mosquitto/log
161+
- ./volumes/mosquitto/pwfile:/mosquitto/pwfile
162+
- ./services/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf
163+
- ./services/mosquitto/filter.acl:/mosquitto/config/filter.acl
164+
minecraft:
165+
image: itzg/minecraft-server
166+
ports:
167+
- "25565:25565"
168+
volumes:
169+
- "./volumes/minecraft:/data"
170+
environment:
171+
EULA: "TRUE"
172+
TYPE: "PAPER"
173+
ENABLE_RCON: "true"
174+
RCON_PASSWORD: "PASSWORD"
175+
RCON_PORT: 28016
176+
VERSION: "1.15.2"
177+
REPLACE_ENV_VARIABLES: "TRUE"
178+
ENV_VARIABLE_PREFIX: "CFG_"
179+
CFG_DB_HOST: "http://localhost:3306"
180+
CFG_DB_NAME: "IOTstack Minecraft"
181+
CFG_DB_PASSWORD_FILE: "/run/secrets/db_password"
182+
restart: unless-stopped
183+
rcon:
184+
image: itzg/rcon
185+
ports:
186+
- "4326:4326"
187+
- "4327:4327"
188+
volumes:
189+
- "./volumes/rcon_data:/opt/rcon-web-admin/db"
190+
secrets:
191+
db_password:
192+
file: ./db_password
193+
```

0 commit comments

Comments
 (0)