|
| 1 | +# Spreed WebRTC server in minimal Docker (for production) |
| 2 | +# |
| 3 | +# This Dockerfile creates a container which builds Spreed WebRTC as piped in |
| 4 | +# on stdin using another Docker container defined in `Dockerfile.build`. |
| 5 | +# |
| 6 | +# First create the builder image: |
| 7 | +# |
| 8 | +# ``` |
| 9 | +# docker build -t spreed-webrtc-builder -f Dockerfile.build . |
| 10 | +# ``` |
| 11 | +# |
| 12 | +# Next run the builder container, piping its output into the creation of the |
| 13 | +# runner container: |
| 14 | +# |
| 15 | +# ``` |
| 16 | +# docker run --rm spreed-webrtc-builder | docker build -t spreed-webrtc -f Dockerfile.run - |
| 17 | +# ``` |
| 18 | +# |
| 19 | +# image. Afterwards run the container like this: |
| 20 | +# |
| 21 | +# ``` |
| 22 | +# docker run --rm --name my-spreed-webrtc -p 8080:8080 -p 8443:8443 \ |
| 23 | +# -v `pwd`:/srv/extra -i -t spreed-webrtc |
| 24 | +# ``` |
| 25 | +# |
| 26 | +# Now you can either use a frontend proxy like Nginx to provide TLS to Spreed |
| 27 | +# WebRTC and even run it in production like that from the Docker container, or |
| 28 | +# for easy development testing, the container also provides a TLS listener with |
| 29 | +# a self-signed certificate on port 8443. |
| 30 | +# |
| 31 | +# To use custom configuration, use the `server.conf.in` file as template and |
| 32 | +# remove the listeners from [http] and [https] sections. Then provide that file |
| 33 | +# when running the docker container as with `-c` parameter like this: |
| 34 | +# |
| 35 | +# ``` |
| 36 | +# docker run --rm --name my-spreed-webrtc -p 8080:8080 -p 8443:8443 \ |
| 37 | +# -v `pwd`:/srv/extra -i -t spreed-webrtc \ |
| 38 | +# -c /srv/extra/server.conf |
| 39 | +# ``` |
| 40 | +# |
| 41 | +# And last, this container checks environment variables NEWCERT and NEWSECRETS, |
| 42 | +# on startup. Set those to `1` to regenerate the corresponding values on start. |
| 43 | +# The current certificate and secrets are printed before startup so you can use |
| 44 | +# them easily for other services. Of course, if you want to have persistent cert |
| 45 | +# and secrets, the container needs to be persistent in the first place, so no |
| 46 | +# `--rm` parameter in the example from above in that case. |
| 47 | +# |
| 48 | + |
| 49 | +FROM frolvlad/alpine-glibc:alpine-3.3_glibc-2.23 |
| 50 | +MAINTAINER Simon Eisenmann <simon@struktur.de> |
| 51 | + |
| 52 | +ENV LANG=C.UTF-8 |
| 53 | + |
| 54 | +# Add dependencies. |
| 55 | +RUN apk add --no-cache \ |
| 56 | + openssl |
| 57 | + |
| 58 | +# Add Spreed WebRTC as provided by Dockerfile.run. |
| 59 | +COPY srv/ /srv |
| 60 | + |
| 61 | +# Move around stuff from tarball to their expected locations. |
| 62 | +RUN mv /srv/spreed-webrtc/dist/loader/* /srv/spreed-webrtc && \ |
| 63 | + mv /srv/spreed-webrtc/dist/www/html /srv/spreed-webrtc && \ |
| 64 | + mv /srv/spreed-webrtc/dist/www/static /srv/spreed-webrtc |
| 65 | + |
| 66 | +# Add entrypoint. |
| 67 | +COPY docker_entrypoint.sh /srv/entrypoint.sh |
| 68 | + |
| 69 | +# Create default config. |
| 70 | +RUN cp -v /srv/spreed-webrtc/server.conf.in /srv/spreed-webrtc/default.conf && \ |
| 71 | + sed -i 's|listen = 127.0.0.1:8080|listen = 0.0.0.0:8080|' /srv/spreed-webrtc/default.conf && \ |
| 72 | + sed -i 's|;root = .*|root = /srv/spreed-webrtc|' /srv/spreed-webrtc/default.conf && \ |
| 73 | + sed -i 's|;listen = 127.0.0.1:8443|listen = 0.0.0.0:8443|' /srv/spreed-webrtc/default.conf && \ |
| 74 | + sed -i 's|;certificate = .*|certificate = /srv/cert.pem|' /srv/spreed-webrtc/default.conf && \ |
| 75 | + sed -i 's|;key = .*|key = /srv/privkey.pem|' /srv/spreed-webrtc/default.conf && \ |
| 76 | + touch /etc/spreed-webrtc-server.conf |
| 77 | + |
| 78 | +# Cleanup. |
| 79 | +RUN rm -rf /tmp/* /var/cache/apk/* |
| 80 | + |
| 81 | +# Add mount point for extra things. |
| 82 | +RUN mkdir /srv/extra |
| 83 | +VOLUME /srv/extra |
| 84 | + |
| 85 | +# Tell about our service. |
| 86 | +EXPOSE 8080 |
| 87 | +EXPOSE 8443 |
| 88 | + |
| 89 | +# Define entry point with default command. |
| 90 | +ENTRYPOINT ["/bin/sh", "/srv/entrypoint.sh", "-dc", "/srv/spreed-webrtc/default.conf"] |
| 91 | +CMD ["-c", "/etc/spreed-webrtc-server.conf"] |
0 commit comments