Skip to content

Commit

Permalink
Add Linux Alpine Docker image (#1226)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc authored Nov 17, 2023
1 parent 93bbccf commit 3d2556f
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 21 deletions.
19 changes: 15 additions & 4 deletions doc/Building.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ Rewrites mediasoup-worker C++ files using [clang-format](https://clang.llvm.org/

Builds and runs the `mediasoup-worker-test` binary at `worker/out/Release/` (or at `worker/out/Debug/` if the "MEDIASOUP_BUILDTYPE" environment variable is set to "Debug"), which uses [Catch2](https://github.com/catchorg/Catch2) to run test units located at `worker/test/` folder.


### 'make test-asan'
### `make test-asan`

Run test with Address Sanitizer.

Expand Down Expand Up @@ -189,7 +188,7 @@ Runs all fuzzer cases.

### `make docker`

Builds a Linux image with fuzzer capable clang++.
Builds a Linux Ubuntu Docker image with fuzzer capable clang++ and all dependencies to run mediasoup.

**NOTE:** Before running this command, a specific version of Linux clang must be downloaded. To get it, run:

Expand All @@ -200,4 +199,16 @@ cd worker

### `make docker-run`

Runs a container of the Docker image created with `make docker`. It automatically executes a `bash` session in the `/mediasoup` directory, which is a Docker volume that points to the real `mediasoup` directory.
Runs a container of the Ubuntu Docker image created with `make docker`. It automatically executes a `bash` session in the `/mediasoup` directory, which is a Docker volume that points to the real `mediasoup` directory.

**NOTE:** To install and run mediasoup in the container, previous installation (if any) must be properly cleaned by entering the `worker` directory and running `make clean-all`.

### `make docker-alpine`

Builds a Linux Alpine Docker image with all dependencies to run mediasoup.

### `make docker-alpine-run`

Runs a container of the Alpine Docker image created with `make docker-alpine`. It automatically executes an `ash` session in the `/mediasoup` directory, which is a Docker volume that points to the real `mediasoup` directory.

**NOTE:** To install and run mediasoup in the container, previous installation (if any) must be properly cleaned by entering the `worker` directory and running `make clean-all`.
32 changes: 16 additions & 16 deletions worker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ RUN \
set -x \
&& apt-get update \
&& apt-get install --yes \
bash-completion wget curl subversion screen gcc g++ cmake ninja-build golang \
autoconf libtool apache2 python3-pip python3-dev pkg-config zlib1g-dev \
libgss-dev libssl-dev libxml2-dev nasm libarchive-dev make automake \
libdbus-1-dev libboost-dev autoconf-archive bash-completion python3-yaml \
clang
bash-completion wget curl subversion screen gcc g++ cmake ninja-build golang \
autoconf libtool apache2 python3-pip python3-dev pkg-config zlib1g-dev \
libgss-dev libssl-dev libxml2-dev nasm libarchive-dev make automake \
libdbus-1-dev libboost-dev autoconf-archive bash-completion python3-yaml \
clang

# Install node 20.
RUN set -x \
&& apt-get update \
&& apt-get install --yes ca-certificates curl gnupg \
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
| gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& NODE_MAJOR=20 \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" \
> /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install nodejs --yes
RUN set -x \
&& apt-get update \
&& apt-get install --yes ca-certificates curl gnupg \
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
| gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& NODE_MAJOR=20 \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" \
> /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install nodejs --yes

# Make CC and CXX point to clang/clang++ installed above.
ENV LANG="C.UTF-8"
Expand Down
17 changes: 17 additions & 0 deletions worker/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM alpine

# Install dependencies.
RUN \
set -x \
&& apk add \
nodejs-current npm python3 py3-pip \
make gcc g++

# Make CC and CXX point to gcc/g++.
ENV LANG="C.UTF-8"
ENV CC="gcc"
ENV CXX="g++"

WORKDIR /mediasoup

CMD ["ash"]
19 changes: 18 additions & 1 deletion worker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ endif
fuzzer \
fuzzer-run-all \
docker \
docker-run
docker-run \
docker-alpine \
docker-alpine-run

default: mediasoup-worker

Expand Down Expand Up @@ -266,3 +268,18 @@ docker-run:
--cap-add SYS_PTRACE \
-v $(shell pwd)/../:/mediasoup \
mediasoup/docker:latest

docker-alpine:
ifeq ($(DOCKER_NO_CACHE),true)
$(DOCKER) build -f Dockerfile.alpine --no-cache --tag mediasoup/docker-alpine:latest .
else
$(DOCKER) build -f Dockerfile.alpine --tag mediasoup/docker-alpine:latest .
endif

docker-alpine-run:
$(DOCKER) run \
--name=mediasoupDockerAlpine -it --rm \
--privileged \
--cap-add SYS_PTRACE \
-v $(shell pwd)/../:/mediasoup \
mediasoup/docker-alpine:latest

0 comments on commit 3d2556f

Please sign in to comment.