-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 17f684f
Showing
5 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM alpine:latest | ||
MAINTAINER Ian Blenke <[email protected]> | ||
|
||
ENV COTURN_VERSION 4.5.0.3 | ||
|
||
RUN apk add --no-cache --update bash curl git make build-base automake autoconf readline readline-dev gettext libcrypto1.0 openssl openssl-dev libevent libevent-dev linux-headers sqlite sqlite-libs sqlite-dev mariadb-libs mysql-dev postgresql postgresql-dev sqlite hiredis hiredis-dev jq && \ | ||
###################################################################### | ||
## Adding mongodb from alpine edge adds 130M to the 44M image size. ## | ||
## Uncomment the apk line below if you really need this. ## | ||
###################################################################### | ||
# apk add --no-cache --update --repository http://dl-4.alpinelinux.org/alpine/edge/testing mongodb && \ | ||
git clone --branch ${COTURN_VERSION} https://github.com/coturn/coturn /build && \ | ||
cd /build && \ | ||
./configure --prefix=/app && \ | ||
make install && \ | ||
rm -fr /build && \ | ||
apk del hiredis-dev postgresql-dev mysql-dev sqlite-dev linux-headers libevent-dev openssl-dev readline-dev automake autoconf build-base make git && \ | ||
rm -rf /var/cache/apk/* | ||
|
||
WORKDIR /app | ||
|
||
ADD coturn.sh /coturn.sh | ||
RUN chmod u+rx /coturn.sh | ||
|
||
CMD /coturn.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build: | ||
docker build -t ianblenke/coturn . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# ianblenke/coturn:latest | ||
|
||
This is an autobuild docker image repo for an Alpine based 44M image build of coturn. | ||
|
||
This builds from the origin source tree: | ||
|
||
https://github.com/coturn/coturn | ||
|
||
The startup script will auto-discover a public and private IP address, which can be | ||
environmentally overridden. | ||
|
||
The startup script will also accept a `JSON_CONFIG` environment variable containing a | ||
JSON formatted string with a `config` key array of lines to add to the generated | ||
coturn configuration file. | ||
|
||
There is presently support compiled in for sqlite3, redis, mysql, and postgresql. | ||
Note: Mongo support is commented out, as it adds 130M to the image size. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
|
||
# Discover public and private IP for this instance | ||
PUBLIC_IPV4="$(curl -qs http://169.254.169.254/2014-11-05/meta-data/public-ipv4)" | ||
[ -n "$PUBLIC_IPV4" ] || PUBLIC_IPV4="$(curl -qs ipinfo.io/ip)" | ||
PRIVATE_IPV4="$(curl -qs http://169.254.169.254/2014-11-05/meta-data/local-ipv4)" | ||
[ -n "$PRIVATE_IPV4" ] || PRIVATE_IPV4="$(ip addr show eth0 | grep 'inet ' | awk '{print $2}' | cut -d/ -f1)" | ||
|
||
# Yes, this does work. See: https://github.com/ianblenke/aws-6to4-docker-ipv6 | ||
#IPV6="$(ip -6 addr show eth0 scope global | grep inet6 | awk '{print $2}')" | ||
|
||
PORT=${PORT:-3478} | ||
ALT_PORT=${PORT:-3479} | ||
|
||
TLS_PORT=${TLS:-5349} | ||
TLS_ALT_PORT=${PORT:-5350} | ||
|
||
MIN_PORT=${MIN_PORT:-49152} | ||
MAX_PORT=${MAX_PORT:-65535} | ||
|
||
TURNSERVER_CONFIG=/app/etc/turnserver.conf | ||
|
||
cat <<EOF > ${TURNSERVER_CONFIG}-template | ||
# https://github.com/coturn/coturn/blob/master/examples/etc/turnserver.conf | ||
listening-port=${PORT} | ||
min-port=${MIN_PORT} | ||
max-port=${MAX_PORT} | ||
EOF | ||
|
||
if [ "${PUBLIC_IPV4}" != "${PRIVATE_IPV4}" ]; then | ||
echo "external-ip=${PUBLIC_IPV4}/${PRIVATE_IPV4}" >> ${TURNSERVER_CONFIG}-template | ||
else | ||
echo "external-ip=${PUBLIC_IPV4}" >> ${TURNSERVER_CONFIG}-template | ||
fi | ||
|
||
if [ -n "${JSON_CONFIG}" ]; then | ||
echo "${JSON_CONFIG}" | jq -r '.config[]' >> ${TURNSERVER_CONFIG}-template | ||
fi | ||
|
||
if [ -n "$SSL_CERTIFICATE" ]; then | ||
echo "$SSL_CA_CHAIN" > /app/etc/turn_server_cert.pem | ||
echo "$SSL_CERTIFICATE" >> /app/etc/turn_server_cert.pem | ||
echo "$SSL_PRIVATE_KEY" > /app/etc/turn_server_pkey.pem | ||
|
||
cat <<EOT >> ${TURNSERVER_CONFIG}-template | ||
tls-listening-port=${TLS_PORT} | ||
alt-tls-listening-port=${TLS_ALT_PORT} | ||
cert=/app/etc/turn_server_cert.pem | ||
pkey=/app/etc/turn_server_pkey.pem | ||
EOT | ||
|
||
fi | ||
|
||
# Allow for ${VARIABLE} substitution using envsubst from gettext | ||
envsubst < ${TURNSERVER_CONFIG}-template > ${TURNSERVER_CONFIG} | ||
|
||
exec /app/bin/turnserver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
coturn: | ||
build: . | ||
container_name: coturn | ||
net: host | ||
ports: | ||
- "3478:3478/udp" # STUN/TURN UDP | ||
- "3478:3478/tcp" # STUN/TURN TCP | ||
- "3479:3479/udp" # STUN/TURN UDP Alt port (RFC5780 support) | ||
- "3479:3479/tcp" # STUN/TURN TCP Alt port (RFC5780 support) | ||
- "5349:5349/udp" # STUN/TURN DTLS | ||
- "5349:5349/tcp" # STUN/TURN TLS | ||
- "5350:5350/udp" # STUN/TURN DTLS Alt port (RFC5780 support) | ||
- "5350:5350/tcp" # STUN/TURN TLS Alt port (RFC5780 support) | ||
- "49152:65535/udp" # UDP media ports for TURN relay | ||
environment: | ||
PORT: 3478 | ||
ALT_PORT: 3479 | ||
TLS_PORT: 5349 | ||
TLS_ALT_PORT: 5350 | ||
MIN_PORT: 49152 | ||
MAX_PORT: 65535 | ||
JSON_CONFIG: '{"config":["no-auth"]}' | ||
|