diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..46856fa --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +/docker/janus +/docker/coturn +/Dockerfile +/docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e2be782 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM golang:1.13 AS builder + +RUN apt-get update && apt-get install -y python3 +WORKDIR /workdir + +COPY . . +RUN make build + +FROM alpine:3.11 + +ENV CONFIG=/config/server.conf +RUN adduser -D spreedbackend && \ + apk add --no-cache --no-cache ca-certificates libc6-compat libstdc++ +USER spreedbackend +COPY --from=builder /workdir/bin/signaling /usr/local/signaling +COPY ./server.conf.in /config/server.conf + +CMD ["/bin/sh", "-c", "/usr/local/signaling --config=$CONFIG"] diff --git a/README.md b/README.md index e16ee07..ca277a7 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,21 @@ systemctl enable signaling.service systemctl start signaling.service ``` +### Running with Docker + +#### Docker Compose + +You will likely have to adjust the Janus command line options depending on the exact network configuration on your server. Refer to [Setup of Janus](#setup-of-janus) and the Janus documentation for how to configure your Janus server. + +Copy `server.conf.in` to `server.conf` and adjust it to your liking. + +If you're using the [docker-compose.yml](docker-compose.yml) configuration as is, the MCU Url must be set to `ws://localhost:8188`, the NATS Url must be set to `nats://localhost:4222`, and TURN Servers must be set to `turn:localhost:3478?transport=udp,turn:localhost:3478?transport=tcp`. + +```bash +docker-compose build +docker-compose up -d +``` + ## Setup of NATS server There is a detailed description on how to install and run the NATS server diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..23d2b78 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,32 @@ +version: '3' + +services: + spreedbackend: + build: . + volumes: + - ./server.conf:/config/server.conf + network_mode: host + restart: unless-stopped + depends_on: + - nats + - janus + - coturn + nats: + image: nats:2.1 + volumes: + - ./gnatsd.conf:/config/gnatsd.conf + command: ["-c", "/config/gnatsd.conf"] + network_mode: host + restart: unless-stopped + janus: + build: docker/janus + command: ["janus"] + network_mode: host + restart: unless-stopped + coturn: + build: docker/coturn + network_mode: host + environment: + REALM: nextcloud.domain.invalid + STATIC_SECRET: static_secret_same_in_server_conf + restart: unless-stopped diff --git a/docker/coturn/Dockerfile b/docker/coturn/Dockerfile new file mode 100644 index 0000000..e178bce --- /dev/null +++ b/docker/coturn/Dockerfile @@ -0,0 +1,5 @@ +FROM alpine:3.11 + +RUN apk add --no-cache coturn + +CMD ["/bin/sh", "-c", "turnserver --prod --fingerprint --use-auth-secret --static-auth-secret=$STATIC_SECRET --realm=$REALM --no-multicast-peers --no-tls --no-dtls"] diff --git a/docker/janus/Dockerfile b/docker/janus/Dockerfile new file mode 100644 index 0000000..fb964b0 --- /dev/null +++ b/docker/janus/Dockerfile @@ -0,0 +1,34 @@ +# Modified from https://gitlab.com/powerpaul17/nc_talk_backend/-/blob/dcbb918d8716dad1eb72a889d1e6aa1e3a543641/docker/janus/Dockerfile +FROM alpine:3.11 + +RUN apk add --no-cache curl autoconf automake libtool pkgconf build-base \ + glib-dev libconfig-dev libnice-dev jansson-dev openssl-dev zlib libsrtp-dev \ + gengetopt libwebsockets-dev git + +# usrsctp +ARG USRSCTP_VERSION=4069ba5b9587bd7c99d964756b527d6259f0d3da + +RUN cd /tmp && \ + git clone https://github.com/sctplab/usrsctp && \ + cd usrsctp && \ + git checkout $USRSCTP_VERSION && \ + ./bootstrap && \ + ./configure --prefix=/usr && \ + make && make install + +# JANUS + +ARG JANUS_VERSION=0.9.2 +RUN mkdir -p /usr/src/janus && \ + cd /usr/src/janus && \ + curl -L https://github.com/meetecho/janus-gateway/archive/v$JANUS_VERSION.tar.gz | tar -xz && \ + cd /usr/src/janus/janus-gateway-$JANUS_VERSION && \ + ./autogen.sh && \ + ./configure --disable-rabbitmq --disable-mqtt --disable-boringssl && \ + make && \ + make install && \ + make configs + +WORKDIR /usr/src/janus/janus-gateway-$JANUS_VERSION + +CMD [ "janus" ]