Skip to content

Commit

Permalink
Update Docker build.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Oct 14, 2018
1 parent 3671907 commit d5ceffc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
charts/
build.sh
Dockerfile
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Note the following environment variables affect the server:

## Bonus: Docker and Kubernetes

For extra credit, you can run the server under Docker. You will need host networking to allow the Docker instance to access all the TCP and UDP ports it needs (see above RTC_ANNOUNCED_IPV4). Docker doesn't allow exposing port ranges.
For extra credit, you can run the server under Docker (the repository is michaelfig/mediasoup-broadcast-example). You will need host networking to allow the Docker instance to access all the TCP and UDP ports it needs (see above RTC_ANNOUNCED_IPV4). Docker doesn't allow exposing port ranges.

If you like Kubernetes, there is a Helm chart in charts/mediasoup-broadcast-example. See the values.yaml in that directory for instructions on using hostNetworkIP. In short, you will need to schedule the mediasoup-broadcast-example pod (single replica only) to run on a node that has an external IP that meets the requirements of RTC_ANNOUNCED_IPV4. To accomplish this, you will use "hostNetworkIP: <MY-IP>" in your Helm yaml settings, and then label the node that receives traffic for that public IP with:

Expand Down
18 changes: 10 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#! /bin/sh
set -e
thisdir=`dirname "$0"`
NAME=mediasoup-broadcast-example
VERSION=`sed -ne '/^ *"version":/{ s/^.* "version": *"\([^"]*\)".*/\1/; p; q; }' "$thisdir"/package.json`

# If KUBE_CONTEXT=example, use --kube-context=example and -fcharts/example.yaml
KUBE_CONTEXT=${KUBE_CONTEXT-example}
thisdir=`dirname "$0"`
export KUBE_CONTEXT
case "$1" in
build)
push)
cd "$thisdir"
# Find the name of the Docker registry from charts/$KUBE_CONTEXT.yaml's repository: line.
REGISTRY=`sed -ne '/^ *repository:/{ s/^.* \([^/]*\).*$/\1/; p; q; }' charts/"$KUBE_CONTEXT".yaml`
docker build -t $REGISTRY/mediasoup-broadcast-example .
docker push $REGISTRY/mediasoup-broadcast-example
docker build -t $REGISTRY/mediasoup-broadcast-example:$VERSION -t $REGISTRY/mediasoup-broadcast-example:latest .
docker push $REGISTRY/mediasoup-broadcast-example:$VERSION
docker push $REGISTRY/mediasoup-broadcast-example:latest
;;
upgrade|install)
cd "$thisdir"
Expand All @@ -23,12 +26,11 @@ upgrade|install)
RECREATE=--recreate-pods
fi
helm --kube-context="$KUBE_CONTEXT" upgrade \
$RECREATE --install $NAME -f charts/"$KUBE_CONTEXT".yaml \
$RECREATE --install $NAME -f charts/"$KUBE_CONTEXT".yaml --set=image.tag=$VERSION \
charts/$NAME ${1+"$@"}
;;
"")
$SHELL $0 build
$SHELL $0 upgrade
"" | help)
echo "Run: \`$0 upgrade' to helm upgrade using KUBE_CONTEXT=$KUBE_CONTEXT"
;;
*)
cmd="$1"
Expand Down
6 changes: 1 addition & 5 deletions charts/example.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
image:
repository: registry.example.com/mediasoup-broadcast-example
tag: latest
pullPolicy: Always
service:
# Needs:
# kubectl label node <MY-NODE> hostNetworkIP=1.2.3.4
Expand All @@ -11,7 +7,7 @@ ingress:
ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/proxy-read-timeout: "1800"
nginx.ingress.kubernetes.io/proxy-send-timeout: "1800"
certmanager.k8s.io/cluster-issuer: ca-issuer
certmanager.k8s.io/cluster-issuer: letsencrypt-prod
enabled: true
hosts:
- msbe.example.com
Expand Down
2 changes: 1 addition & 1 deletion charts/mediasoup-broadcast-example/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
replicaCount: 1

image:
repository: mediasoup-broadcast-example
repository: michaelfig/mediasoup-broadcast-example
tag: stable
pullPolicy: IfNotPresent

Expand Down

0 comments on commit d5ceffc

Please sign in to comment.