Skip to content

Commit 0b3b1ea

Browse files
committed
add non-root support, upgrade os, update readme
1 parent 47da935 commit 0b3b1ea

4 files changed

Lines changed: 94 additions & 32 deletions

File tree

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
FROM sinusbot/docker:1.0.0-beta.6-f290553-discord
22

3-
LABEL maintainer="Max Schmitt <max@schmitt.mx>"
43
LABEL description="SinusBot - TeamSpeak 3 and Discord music bot."
54
LABEL version="1.0.0-beta.6-f290553"
65

README.md

Lines changed: 65 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,73 @@
1212
- Integrated Text-to-Speech engine
1313
- Compatible with macOS
1414

15-
## Installation
15+
## Disclaimer
16+
17+
By using this image you accept the [Privacy statement of the TeamSpeak Systems GmbH](https://www.teamspeak.com/en/privacy-and-terms), the [SinusBot Privacy Policy](https://forum.sinusbot.com/help/privacy-policy/) and SinusBot license agreement.
18+
19+
> © 2013-2019 Michael Friese. All rights reserved. (https://www.sinusbot.com)
20+
>
21+
> This software is free for personal use only. If you want to use it commercially, please contact the author.
22+
>
23+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24+
>
25+
> You may NOT redistribute this software or use this software commercially without prior written permission from the author.
26+
27+
*TeamSpeak 3 is © TeamSpeak Systems GmbH. This product and the author is in no way affiliated with TeamSpeak Systems GmbH.*
28+
29+
*Discord is © Hammer & Chisel Inc. This product and the author is in no way affiliated with Hammer & Chisel Inc.*
1630

17-
By using this image you accept the [Privacy statement of the TeamSpeak Systems GmbH](https://www.teamspeak.com/en/privacy-and-terms), the [SinusBot Privacy Policy](https://forum.sinusbot.com/help/privacy-policy/) and the license agreement.
31+
## Installation
1832

1933
### docker-compose
2034

2135
Download the [docker-compose file](https://github.com/SinusBot/docker/blob/master/docker-compose.yml) in it's own directory and start it with `docker-compose up`.
2236

2337
### docker
2438

39+
#### root (not recommended)
40+
2541
```bash
2642
docker run -d -p 8087:8087 \
2743
-v scripts:/opt/sinusbot/scripts \
2844
-v data:/opt/sinusbot/data \
29-
--name sinusbot sinusbot/docker
45+
--name sinusbot \
46+
sinusbot/docker
3047
```
3148

49+
#### unprivileged user
50+
3251
It is recommended that you run the SinusBot as a non-root user, even though the docker container is mostly isolated from the host.
3352
This can be done as described in the following:
3453

35-
- add a new user: `adduser --disabled-login sinusbot`
36-
- create the required folders if they don't exist: `mkdir -p /opt/sinusbot/data /opt/sinusbot/scripts`
37-
- give the user permissions to the folders: `chown -R sinusbot:sinusbot /opt/sinusbot`
38-
- add `-u sinusbot` to the docker run command shown above when you start it
54+
- add a new user:
55+
56+
`useradd --no-create-home -s /sbin/nologin -U sinusbot`
57+
- create the required folders if they don't exist:
58+
59+
`mkdir -p /opt/sinusbot/data /opt/sinusbot/scripts`
60+
- give the user permissions to the folders:
3961

40-
Additional information on [setting the user](https://docs.docker.com/engine/reference/run/#user) or [remapping the user](https://docs.docker.com/engine/security/userns-remap/) can be found in the docker documentation.
62+
`chown -R sinusbot:sinusbot /opt/sinusbot`
63+
- Run the docker image with the `UID` and `GID` environment variables set to the correct user- and group-ID as shown below:
64+
65+
```bash
66+
docker run -d -p 8087:8087 \
67+
-v scripts:/opt/sinusbot/scripts \
68+
-v data:/opt/sinusbot/data \
69+
-e UID=$(id -u sinusbot)
70+
-e GID=$(id -g sinusbot) \
71+
--name sinusbot \
72+
sinusbot/docker
73+
```
74+
75+
#### Tags
76+
77+
- `latest` is the default tag
78+
- `discord` is a discord-only version of `latest` and does not contain the TeamSpeak client with additonal dependencies
79+
- every release is tagged with it's version (for example: `1.0.0-beta.6-f290553`) and a discord-only tag (for example: `1.0.0-beta.6-f290553-discord`)
80+
81+
You view the [full list of tags](https://hub.docker.com/r/sinusbot/docker/tags) for specific versions.
4182

4283
## Get Password
4384

@@ -56,7 +97,7 @@ PLEASE MAKE SURE TO CHANGE THE PASSWORD DIRECTLY AFTER YOUR FIRST LOGIN!!!
5697

5798
## Override Password
5899

59-
By setting the `OVERRIDE_PASSWORD` environment variable you can override the password of the SinusBot. Usage:
100+
By setting the `OVERRIDE_PASSWORD` environment variable you can override the password of the SinusBot. Example:
60101

61102
```bash
62103
docker run -d -p 8087:8087 \
@@ -72,18 +113,6 @@ To use your [license](https://sinusbot.github.io/docs/licenses/), which you've g
72113

73114
After restarting the container (`docker restart sinusbot`) your licensed instances should appear automatically.
74115

75-
## Discord only image
76-
77-
There is an image for discord only usage, this won't contain the TeamSpeak client with the additonal dependencies.
78-
To use it you just have to use the `discord` tag instead of `latest` (default) tag:
79-
80-
```bash
81-
docker run -d -p 8087:8087 \
82-
-v scripts:/opt/sinusbot/scripts \
83-
-v data:/opt/sinusbot/data \
84-
--name sinusbot sinusbot/docker:discord
85-
```
86-
87116
## Updating
88117

89118
Docker containers themselves should not store application data, instead the data is stored in volumes (in this case `scripts` and `data`).
@@ -92,8 +121,7 @@ To upgrade a container you need to remove and re-run it as shown below.
92121
1. Stop and remove the old container.
93122

94123
```bash
95-
docker stop sinusbot
96-
docker rm sinusbot
124+
docker stop sinusbot && docker rm sinusbot
97125
```
98126

99127
2. Pull the latest image:
@@ -120,6 +148,20 @@ The Chromium Text-to-Speech engine is pre-installed but disabled by default due
120148
To enable it you simply need to set the `TTS.Enabled` property to `true` in the `config.ini` stored in the `data` volume (`/opt/sinusbot/data`) and restart your container (`docker restart sinusbot`).
121149
Once it's enabled it can be used by setting the locale to `en-US` or `de-DE` in the instance settings.
122150
151+
## Discord only image
152+
153+
[![Image Info](https://images.microbadger.com/badges/image/sinusbot/docker:discord.svg)](https://microbadger.com/images/sinusbot/docker:discord)
154+
155+
There is an image for discord only usage, this won't contain the TeamSpeak client with the additonal dependencies.
156+
To use it you just have to use the `discord` tag instead of `latest` (default) tag:
157+
158+
```bash
159+
docker run -d -p 8087:8087 \
160+
-v scripts:/opt/sinusbot/scripts \
161+
-v data:/opt/sinusbot/data \
162+
--name sinusbot sinusbot/docker:discord
163+
```
164+
123165
## Other Docker registries
124166

125167
### QUAY

discord/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
FROM debian:stretch-slim
1+
FROM debian:buster-slim
22

3-
LABEL maintainer="Max Schmitt <max@schmitt.mx>"
43
LABEL description="SinusBot - Discord only image"
54
LABEL version="1.0.0-beta.6-f290553"
65

discord/entrypoint.sh

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/bash
22

3-
PID=0
4-
53
if [ -d "default_scripts" ]; then
64
mv default_scripts/* scripts
75
rm -r default_scripts
@@ -16,7 +14,8 @@ ln -fs data/config.ini config.ini
1614

1715
echo "Updating youtube-dl..."
1816
youtube-dl --restrict-filename -U
19-
echo "youtube-dl was updated"
17+
18+
PID=0
2019

2120
# graceful shutdown
2221
kill_handler() {
@@ -25,18 +24,41 @@ kill_handler() {
2524
while [ -e /proc/$PID ]; do
2625
sleep .5
2726
done
28-
exit 0;
27+
exit 0
2928
}
3029

3130
trap 'kill ${!}; kill_handler' SIGTERM # docker stop
3231
trap 'kill ${!}; kill_handler' SIGINT # CTRL + C
3332

33+
SINUSBOT="./sinusbot"
34+
35+
if [[ -v UID ]] || [[ -v GID ]]; then
36+
SETPRIV="setpriv --clear-groups --inh-caps=-all"
37+
38+
# set user id
39+
if [[ -v UID ]]; then
40+
echo "User ID: $UID"
41+
SETPRIV="$SETPRIV --reuid=$UID"
42+
echo "Change file owner..."
43+
chown -R "$UID" "$PWD"
44+
fi
45+
# set group id
46+
if [[ -v GID ]]; then
47+
echo "Group ID: $GID"
48+
SETPRIV="$SETPRIV --regid=$GID"
49+
echo "Change file group..."
50+
chown -R ":$GID" "$PWD"
51+
fi
52+
echo "Drop privileges..."
53+
SINUSBOT="$SETPRIV $SINUSBOT"
54+
fi
55+
3456
echo "Starting SinusBot..."
3557
if [[ -v OVERRIDE_PASSWORD ]]; then
3658
echo "Overriding password..."
37-
./sinusbot --override-password="${OVERRIDE_PASSWORD}" &
59+
$SINUSBOT --override-password="${OVERRIDE_PASSWORD}" &
3860
else
39-
./sinusbot &
61+
$SINUSBOT &
4062
fi
4163

4264
PID=$!

0 commit comments

Comments
 (0)