Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add teamspeak #3919

Merged
merged 6 commits into from
Feb 2, 2018
Merged

Conversation

muenchow
Copy link
Contributor

@muenchow muenchow commented Jan 19, 2018

Summary

We wish to add to the official image our TeamSpeak server.
Documentation can be found here. The TeamSpeak server is closed source, so only the dockerfile can be found on github: https://github.com/TeamSpeak-Systems/teamspeak-linux-docker-images

Checklist for Review

NOTE: This checklist is intended for the use of the Official Images maintainers both to track the status of your PR and to help inform you and others of where we're at. As such, please leave the "checking" of items to the repository maintainers. If there is a point below for which you would like to provide additional information or note completion, please do so by commenting on the PR. Thanks! (and thanks for staying patient with us ❤️)

  • associated with or contacted upstream?
  • does it fit into one of the common categories? ("service", "language stack", "base distribution")
    • service!
  • is it reasonably popular, or does it solve a particular use case well?
  • does a documentation PR exist? (should be reviewed and merged at roughly the same time so that we don't have an empty image page on the Hub for very long)
  • dockerization review for best practices and cache gotchas/improvements (ala the official review guidelines)?
  • 2+ dockerization review?
  • existing official images have been considered as a base? (ie, if foobar needs Node.js, has FROM node:... instead of grabbing node via other means been considered?)
  • if FROM scratch, tarballs only exist in a single commit within the associated history?
  • passes current tests? any simple new tests that might be appropriate to add? (https://github.com/docker-library/official-images/tree/master/test)

@tianon
Copy link
Member

tianon commented Jan 26, 2018

Hello, welcome, and thanks for your patience! 🙏

I think my main initial thought for this Dockerization is that multi-stage builds currently aren't supported for official images (#3383).

Moving things around into something like the following appears to do the trick though (and results in a very small image; ~18.9MB):

FROM alpine:3.7

RUN apk add --no-cache ca-certificates libstdc++ su-exec
RUN set -eux; \
 addgroup ts3server; \
 adduser -Hh /var/ts3server -G ts3server -s /sbin/nologin -D ts3server; \
 mkdir -p /var/ts3server; \
 chown -R ts3server:ts3server /var/ts3server

ENV PATH "${PATH}:/opt/ts3server"

ARG TEAMSPEAK_CHECKSUM=23e0aec4991c6e8b051a192b0d40dfc2e2fac3e66b616ca33880712e99421f37
ARG TEAMSPEAK_URL=http://dl.4players.de/ts/releases/pre_releases/server/3.1.0-Beta-2/teamspeak3-server_linux_alpine-3.1.0.tar.bz2

RUN set -eux; \
 apk add --no-cache --virtual .fetch-deps tar; \
 wget "${TEAMSPEAK_URL}" -O server.tar.bz2; \
 echo "${TEAMSPEAK_CHECKSUM} *server.tar.bz2" | sha256sum -c -; \
 mkdir -p /opt/ts3server; \
 tar -xf server.tar.bz2 --strip-components=1 -C /opt/ts3server; \
 rm server.tar.bz2; \
 apk del .fetch-deps; \
 mv /opt/ts3server/*.so /opt/ts3server/redist/* /usr/local/lib; \
 ldconfig /usr/local/lib; \
 chown -R ts3server:ts3server /opt/ts3server

# setup directory where user data is stored
VOLUME /var/ts3server/
WORKDIR /var/ts3server/

#  9987 default voice
# 10011 server query
# 30033 file transport
EXPOSE 9987/udp 10011 30033 

COPY entrypoint.sh /opt/ts3server
ENTRYPOINT [ "entrypoint.sh" ]
CMD [ "ts3server" ]

It might also be worth considering assigning an explicit UID/GID to that ts3server user/group so that it doesn't unexpectedly change for users in the future (using the service port number is a common choice, just to make the choice obvious).

…input mode for sha256sum and moved generated config files to /var/run/ts3server/ to better support --user.
@muenchow
Copy link
Contributor Author

@tianon thank you very much for the review. I used the improved Dockerfile, you provided, and added a default uid and gid like you suggested.

Additionally i fixed a problem that appeared when --user has been set.

Copy link
Member

@yosifkit yosifkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment about Beta-1. Beta-2 Dockerization looks fine to me!

Not a blocker: did you want to keep the capitalization of Beta on the docker image tags? Most images we have in official images only use lowercase, but it is up to you.

GitCommit: 0aa60b817eec11e41f8a93b225bab48f82133b1b
Directory: 3.1.0

Tags: 3.1.0-Beta-1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version doesn't have the same improvements that the [3.1.0-Beta-2] Dockerfile has. Is this version necessary? The versions in this file control the "Supported Versions" list that gets generated into the docs that show up on the Docker Hub.

We usually only recommend keeping the versions that are "supported" by upstream; ie which versions will get a minor or patch bump simultaneously. Some projects only keep one version, like wordpress*, while others like pypy have 2 versions, and then images like python actively update 5 versions.

* one version of WordPress is maintained with multiple variations under different Linux distributions, versions of php, and server types (fpm/apache)

- #1729 (comment)

You are welcome to do a back-fill of an older version if that is important; it will just need to have the same fixes (TeamSpeak-Systems/teamspeak-linux-docker-images@0aa60b8).

@muenchow
Copy link
Contributor Author

muenchow commented Feb 2, 2018

@yosifkit you are right, there is no real reason to continuously support beta versions. I removed from.

@yosifkit
Copy link
Member

yosifkit commented Feb 2, 2018

Diff:
error: failed fetching repo "teamspeak"
unable to find a manifest named "teamspeak" (in "/tmp/tmp.dUVtirCLoY/oi/library" or as a remote URL)
error: failed fetching repo "teamspeak"
unable to find a manifest named "teamspeak" (in "/tmp/tmp.dUVtirCLoY/oi/library" or as a remote URL)
error: failed fetching repo "teamspeak"
unable to find a manifest named "teamspeak" (in "/tmp/tmp.dUVtirCLoY/oi/library" or as a remote URL)
error: failed fetching repo "teamspeak"
unable to find a manifest named "teamspeak" (in "/tmp/tmp.dUVtirCLoY/oi/library" or as a remote URL)
diff --git a/_bashbrew-arches b/_bashbrew-arches
index e69de29..7d666b6 100644
--- a/_bashbrew-arches
+++ b/_bashbrew-arches
@@ -0,0 +1 @@
+teamspeak:latest @ amd64
diff --git a/_bashbrew-list b/_bashbrew-list
index e69de29..75a37e6 100644
--- a/_bashbrew-list
+++ b/_bashbrew-list
@@ -0,0 +1,3 @@
+teamspeak:3.1
+teamspeak:3.1.0
+teamspeak:latest
diff --git a/teamspeak_latest/Dockerfile b/teamspeak_latest/Dockerfile
new file mode 100644
index 0000000..8871d6b
--- /dev/null
+++ b/teamspeak_latest/Dockerfile
@@ -0,0 +1,39 @@
+FROM alpine:3.7
+
+RUN apk add --no-cache ca-certificates libstdc++ su-exec
+RUN set -eux; \
+ addgroup -g 9987 ts3server; \
+ adduser -u 9987 -Hh /var/ts3server -G ts3server -s /sbin/nologin -D ts3server; \
+ mkdir -p /var/ts3server /var/run/ts3server; \
+ chown ts3server:ts3server /var/ts3server /var/run/ts3server; \
+ chmod 777 /var/ts3server /var/run/ts3server
+
+ENV PATH "${PATH}:/opt/ts3server"
+
+ARG TEAMSPEAK_CHECKSUM=23e0aec4991c6e8b051a192b0d40dfc2e2fac3e66b616ca33880712e99421f37
+ARG TEAMSPEAK_URL=http://dl.4players.de/ts/releases/pre_releases/server/3.1.0-Beta-2/teamspeak3-server_linux_alpine-3.1.0.tar.bz2
+
+RUN set -eux; \
+ apk add --no-cache --virtual .fetch-deps tar; \
+ wget "${TEAMSPEAK_URL}" -O server.tar.bz2; \
+ echo "${TEAMSPEAK_CHECKSUM} *server.tar.bz2" | sha256sum -c -; \
+ mkdir -p /opt/ts3server; \
+ tar -xf server.tar.bz2 --strip-components=1 -C /opt/ts3server; \
+ rm server.tar.bz2; \
+ apk del .fetch-deps; \
+ mv /opt/ts3server/*.so /opt/ts3server/redist/* /usr/local/lib; \
+ ldconfig /usr/local/lib; \
+ chown -R ts3server:ts3server /opt/ts3server
+
+# setup directory where user data is stored
+VOLUME /var/ts3server/
+WORKDIR /var/ts3server/
+
+#  9987 default voice
+# 10011 server query
+# 30033 file transport
+EXPOSE 9987/udp 10011 30033 
+
+COPY entrypoint.sh /opt/ts3server
+ENTRYPOINT [ "entrypoint.sh" ]
+CMD [ "ts3server" ]
diff --git a/teamspeak_latest/entrypoint.sh b/teamspeak_latest/entrypoint.sh
new file mode 100755
index 0000000..7945b3c
--- /dev/null
+++ b/teamspeak_latest/entrypoint.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+set -e
+
+# don't start ts3server with root permissions
+if [ "$1" = 'ts3server' -a "$(id -u)" = '0' ]; then
+    chown -R ts3server /var/ts3server
+    exec su-exec ts3server "$0" "$@"
+fi
+
+# have the default inifile as the last parameter
+if [ "$1" = 'ts3server' ]; then
+    set -- "$@" inifile=/var/run/ts3server/ts3server.ini
+fi
+
+# usage: file_env VAR [DEFAULT]
+#    ie: file_env 'XYZ_DB_PASSWORD' 'example'
+# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
+#  "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
+file_env() {
+	local var="$1"
+	local fileVar="${var}_FILE"
+	eval local varValue="\$${var}"
+	eval local fileVarValue="\$${var}_FILE"
+	local def="${2:-}"
+	if [ "${varValue:-}" ] && [ "${fileVarValue:-}" ]; then
+			echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
+			exit 1
+	fi
+	local val="$def"
+	if [ "${varValue:-}" ]; then
+			val="${varValue}"
+	elif [ "${fileVarValue:-}" ]; then
+			val="$(cat "${fileVarValue}")"
+	fi
+	export "$var"="$val"
+	unset "$fileVar"
+	unset "$fileVarValue"
+}
+
+if [ "$1" = 'ts3server' ]; then
+	file_env 'TS3SERVER_DB_HOST'
+	file_env 'TS3SERVER_DB_USER'
+	file_env 'TS3SERVER_DB_PASSWORD'
+	file_env 'TS3SERVER_DB_NAME'
+	
+	cat <<- EOF >/var/run/ts3server/ts3server.ini
+		licensepath=${TS3SERVER_LICENSEPATH}
+		query_ip_whitelist=${TS3SERVER_IP_WHITELIST:-query_ip_whitelist.txt}
+		query_ip_blacklist=${TS3SERVER_IP_BLACKLIST:-query_ip_blacklist.txt}
+		dbplugin=${TS3SERVER_DB_PLUGIN:-ts3db_sqlite3}
+		dbpluginparameter=${TS3SERVER_DB_PLUGINPARAMETER:-/var/run/ts3server/ts3db.ini}
+		dbsqlpath=${TS3SERVER_DB_SQLPATH:-/opt/ts3server/sql/}
+		dbsqlcreatepath=${TS3SERVER_DB_SQLCREATEPATH:-create_sqlite}
+		dbconnections=${TS3SERVER_DB_CONNECTIONS:-10}
+		dbclientkeepdays=${TS3SERVER_DB_CLIENTKEEPDAYS:-30}
+		logpath=${TS3SERVER_LOG_PATH:-/var/ts3server/logs}
+		logquerycommands=${TS3SERVER_LOG_QUERY_COMMANDS:-0}
+		logappend=${TS3SERVER_LOG_APPEND:-0}
+	EOF
+	cat <<- EOF >/var/run/ts3server/ts3db.ini
+		[config]
+		host='${TS3SERVER_DB_HOST}'
+		port='${TS3SERVER_DB_PORT:-3306}'
+		username='${TS3SERVER_DB_USER}'
+		password='${TS3SERVER_DB_PASSWORD}'
+		database='${TS3SERVER_DB_NAME}'
+		socket=
+		wait_until_ready='${TS3SERVER_DB_WAITUNTILREADY:-30}'
+	EOF
+fi
+
+exec "$@"

LGTM

Build test of #3919; 59139f1; amd64 (teamspeak):

$ bashbrew build teamspeak:3.1
Using bashbrew/cache:dc06b0688567258c36cf05206f5ee2178fdf395aa1662263a1cbf1d99332d3fe (teamspeak:3.1)
Tagging teamspeak:3.1
Tagging teamspeak:3.1.0
Tagging teamspeak:latest

$ test/run.sh teamspeak:3.1
testing teamspeak:3.1
	'utc' [1/4]...passed
	'cve-2014--shellshock' [2/4]...passed
	'no-hard-coded-passwords' [3/4]...passed
	'override-cmd' [4/4]...passed

@tianon tianon merged commit 35cbe35 into docker-library:master Feb 2, 2018
@muenchow muenchow deleted the add-teamspeak branch February 6, 2018 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants