Skip to content

Commit

Permalink
improve install in docker (#722)
Browse files Browse the repository at this point in the history
* use install target instead of manual install
  • Loading branch information
mpromonet authored Sep 11, 2024
1 parent 11f1a19 commit 5e38b71
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 38 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cpp-cross-linux-arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- run: git fetch --prune --unshallow --tags

- name: pkg
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cpp-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- run: git fetch --prune --unshallow --tags

- name: Build an image from Dockerfile
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cpp-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- run: git fetch --prune --unshallow --tags

- name: pkg
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends g++ autoconf automake libtool xz-utils libasound2-dev libpulse-dev libgtk-3-dev cmake p7zip-full
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cpp-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- run: git fetch --prune --unshallow --tags

- name: pkg
run: brew install cmake p7zip gcc openssl rtmpdump && brew link --force openssl
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cpp-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- run: git fetch --prune --unshallow --tags

- name: pkg
shell: cmd
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deploy-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true


- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand Down
21 changes: 11 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
FROM ubuntu:24.04 AS builder
LABEL [email protected]
ARG USERNAME=dev
WORKDIR /webrtc-streamer
COPY . /webrtc-streamer
WORKDIR /build/webrtc-streamer

COPY . .

ENV PATH /depot_tools:$PATH

Expand All @@ -12,22 +13,22 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git /depot_tools \
&& mkdir /webrtc \
&& cd /webrtc \
&& mkdir ../webrtc \
&& cd ../webrtc \
&& fetch --no-history --nohooks webrtc \
&& sed -i -e "s|'src/resources'],|'src/resources'],'condition':'rtc_include_tests==true',|" src/DEPS \
&& gclient sync \
&& cd /webrtc-streamer \
&& cmake . && make \
&& cpack \
&& mkdir /app && tar xvzf webrtc-streamer*.tar.gz --strip=1 -C /app/ && rm webrtc-streamer*.tar.gz \
&& rm -rf /webrtc/src/out \
&& cd ../webrtc-streamer \
&& cmake -DCMAKE_INSTALL_PREFIX=/app . && make \
&& make install \
&& rm -rf ../webrtc/src/out \
&& apt-get clean && rm -rf /var/lib/apt/lists/

# run
FROM ubuntu:24.04

WORKDIR /app
WORKDIR /app/webrtc-streamer

COPY --from=builder /app/ /app/

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libssl-dev libasound2-dev libgtk-3-0 libxtst6 libpulse0 librtmp1 avahi-utils \
Expand Down
24 changes: 13 additions & 11 deletions Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,31 @@ ARG IMAGE=arm64v8/ubuntu
FROM ubuntu:24.04 AS builder
LABEL [email protected]

WORKDIR /webrtc-streamer
COPY . /webrtc-streamer
WORKDIR /build/webrtc-streamer

COPY . .

ENV PATH /depot_tools:$PATH

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates wget git python3 python3-pkg-resources xz-utils cmake make pkg-config gcc-aarch64-linux-gnu g++-aarch64-linux-gnu build-essential \
&& mkdir /webrtc \
&& git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git /depot_tools \
&& export PATH=/depot_tools:$PATH \
&& cd /webrtc \
&& mkdir ../webrtc \
&& cd ../webrtc \
&& fetch --no-history --nohooks webrtc \
&& sed -i -e "s|'src/resources'],|'src/resources'],'condition':'rtc_include_tests==true',|" src/DEPS \
&& src/build/linux/sysroot_scripts/install-sysroot.py --arch=arm64 \
&& gclient sync \
&& cd /webrtc-streamer \
&& cmake -DCMAKE_SYSTEM_PROCESSOR=arm64 -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY -DWEBRTCDESKTOPCAPTURE=OFF . && make \
&& cpack \
&& mkdir /app && tar xvzf webrtc-streamer*.tar.gz --strip=1 -C /app/ \
&& rm -rf /webrtc && rm -f *.a && rm -f src/*.o \
&& cd ../webrtc-streamer \
&& cmake -DCMAKE_INSTALL_PREFIX=/app -DCMAKE_SYSTEM_PROCESSOR=arm64 -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY -DWEBRTCDESKTOPCAPTURE=OFF . && make \
&& make install \
&& rm -rf ../webrtc && rm -f *.a && rm -f src/*.o \
&& apt-get clean && rm -rf /var/lib/apt/lists/

# run
FROM $IMAGE

WORKDIR /app
WORKDIR /app/webrtc-streamer

COPY --from=builder /app/ /app/

ENTRYPOINT [ "./webrtc-streamer" ]
Expand Down
28 changes: 15 additions & 13 deletions Dockerfile.rpi
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,33 @@ LABEL [email protected]
ARG ARCH=armv6l
ARG CROSSCOMPILER=https://sourceforge.net/projects/raspberry-pi-cross-compilers/files/Raspberry%20Pi%20GCC%20Cross-Compiler%20Toolchains/Buster/GCC%2010.2.0/Raspberry%20Pi%201%2C%20Zero/cross-gcc-10.2.0-pi_0-1.tar.gz

WORKDIR /webrtc-streamer
COPY . /webrtc-streamer
WORKDIR /build/webrtc-streamer

COPY . .

ENV PATH /depot_tools:$PATH

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates build-essential gcc wget git python3 python3-pkg-resources xz-utils cmake make pkg-config \
&& mkdir /webrtc \
&& wget -qO- ${CROSSCOMPILER} | tar xz -C /webrtc \
&& export PATH=$(ls -d /webrtc/cross-pi-gcc-*/bin):$PATH \
&& wget -qO- ${CROSSCOMPILER} | tar xz -C /build \
&& export PATH=$(ls -d /build/cross-pi-gcc-*/bin):$PATH \
&& git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git /depot_tools \
&& export PATH=/depot_tools:$PATH \
&& cd /webrtc \
&& mkdir ../webrtc \
&& cd ../webrtc \
&& fetch --no-history --nohooks webrtc \
&& sed -i -e "s|'src/resources'],|'src/resources'],'condition':'rtc_include_tests==true',|" src/DEPS \
&& src/build/linux/sysroot_scripts/install-sysroot.py --arch=arm \
&& gclient sync \
&& cd /webrtc-streamer \
&& cmake -DCMAKE_SYSTEM_PROCESSOR=${ARCH} -DCMAKE_LIBRARY_ARCHITECTURE=arm-linux-gnueabihf -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY -DWEBRTCDESKTOPCAPTURE=OFF . && make \
&& cpack \
&& mkdir /app && tar xvzf webrtc-streamer*.tar.gz --strip=1 -C /app/ \
&& rm -rf /webrtc && rm -f *.a && rm -f src/*.o \
&& cd ../webrtc-streamer \
&& cmake -DCMAKE_INSTALL_PREFIX=/app -DCMAKE_SYSTEM_PROCESSOR=${ARCH} -DCMAKE_LIBRARY_ARCHITECTURE=arm-linux-gnueabihf -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY -DWEBRTCDESKTOPCAPTURE=OFF . && make \
&& make install \
&& rm -rf ../webrtc && rm -f *.a && rm -f src/*.o \
&& apt-get clean && rm -rf /var/lib/apt/lists/

# run
FROM $IMAGE

WORKDIR /app
WORKDIR /app/webrtc-streamer

COPY --from=builder /app/ /app/

ENTRYPOINT [ "./webrtc-streamer" ]
Expand Down
7 changes: 4 additions & 3 deletions Dockerfile.windows
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ RUN git config --global core.autocrlf false \
&& gclient sync \
&& time /t \
&& cd C:\webrtc-streamer \
&& cmake -G Ninja -DCMAKE_C_COMPILER=clang-cl.exe -DCMAKE_CXX_COMPILER=clang-cl.exe -DCMAKE_MAKE_PROGRAM=ninja.bat . \
&& cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/app -DCMAKE_C_COMPILER=clang-cl.exe -DCMAKE_CXX_COMPILER=clang-cl.exe -DCMAKE_MAKE_PROGRAM=ninja.bat . \
&& time /t \
&& ninja \
&& mkdir c:\app && copy webrtc-streamer.exe c:\app && copy config.json c:\app && xcopy /E html c:\app\html\ \
&& ninja install \
&& del /f /s /q c:\webrtc > nul && rmdir /s /q c:\webrtc \
&& time /t

Expand All @@ -48,7 +48,8 @@ RUN powershell -c "sleep -Seconds 60" && time /t
# run
FROM mcr.microsoft.com/windows/server:ltsc2022

WORKDIR /app
WORKDIR /app/webrtc-streamer

COPY --from=builder /app/ /app/

RUN dir /w && set
Expand Down

0 comments on commit 5e38b71

Please sign in to comment.