Add Dockerfile

Signed-off-by: Sebastian Hasler <sebastian.hasler@stuvus.uni-stuttgart.de>
master
Sebastian Hasler 2021-03-15 23:11:54 +01:00
parent cfae6178c7
commit 98b00a396b
3 changed files with 76 additions and 0 deletions

38
docker/Dockerfile Normal file
View File

@ -0,0 +1,38 @@
FROM rust:1.48-alpine AS build
ARG REV=master
RUN apk add --no-cache \
clang-libs \
curl \
libc-dev \
libnice-dev \
openssl-dev \
;
WORKDIR /src
RUN curl https://codeload.github.com/Johni0702/mumble-web-proxy/tar.gz/$REV \
| tar -xzf - --strip-components 1
RUN echo -e '\n[dependencies."async-trait"]\ndefault-features = false' >> Cargo.toml
RUN RUSTFLAGS="-C target-feature=-crt-static" cargo install --path .
FROM alpine
RUN apk add --no-cache \
bash \
libgcc \
libnice \
;
COPY --from=build /usr/local/cargo/bin/mumble-web-proxy /mumble-web-proxy
COPY entrypoint.sh /entrypoint.sh
ENV MWP_LISTEN_WS=64737
ENV MWP_SERVER=mumble-server:64738
ENV MWP_ACCEPT_INVALID_CERTIFICATE=
ENV MWP_ICE_PORT_MIN=
ENV MWP_ICE_PORT_MAX=
ENV MWP_ICE_IPV4=
ENV MWP_ICE_IPV6=
CMD ["/entrypoint.sh"]
USER 1000
EXPOSE 64737

13
docker/README.md Normal file
View File

@ -0,0 +1,13 @@
# mumble-web-proxy OCI image
This directory provides files to build a mumble-web-proxy OCI image.
The image is based on Alpine Linux and is less than 30 MiB in size.
One can use [Docker](https://www.docker.com/) in order to build the image,
as follows.
```
docker build --build-arg REV=master -t mumble-web-proxy .
```
`master` can be replaced by any revision (i.e. branch, tag or commit hash) of
this repository.

25
docker/entrypoint.sh Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
cmd=("/mumble-web-proxy" "--listen-ws=$MWP_LISTEN_WS" "--server=$MWP_SERVER")
if [ "$MWP_ACCEPT_INVALID_CERTIFICATE" = true ]; then
cmd+=("--accept-invalid-certificate")
fi
if [ -n "$MWP_ICE_PORT_MIN" ]; then
cmd+=("--ice-port-min=$MWP_ICE_PORT_MIN")
fi
if [ -n "$MWP_ICE_PORT_MAX" ]; then
cmd+=("--ice-port-max=$MWP_ICE_PORT_MAX")
fi
if [ -n "$MWP_ICE_IPV4" ]; then
cmd+=("--ice-ipv4=$MWP_ICE_IPV4")
fi
if [ -n "$MWP_ICE_IPV6" ]; then
cmd+=("--ice-ipv6=$MWP_ICE_IPV6")
fi
exec "${cmd[@]}"