From 35d698672fbf0452bdc9b34aab0f31e0c4b8ef24 Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Sat, 18 Apr 2026 19:11:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B8=A6pymkui=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E7=AE=A1=E7=90=86=E7=9A=84docker=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker_py.yml | 89 ++++++++++++++++++++++ README.md | 7 +- README_en.md | 5 ++ dockerfile_py | 130 ++++++++++++++++++++++++++++++++ 4 files changed, 230 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker_py.yml create mode 100644 dockerfile_py diff --git a/.github/workflows/docker_py.yml b/.github/workflows/docker_py.yml new file mode 100644 index 00000000..7136a00a --- /dev/null +++ b/.github/workflows/docker_py.yml @@ -0,0 +1,89 @@ +name: DockerPy + +on: + push: + branches: + - "master" + - "feature/*" + - "release/*" + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: docker.io + IMAGE_NAME: zlmediakit/zlmediakit + +jobs: + build: + + runs-on: ubuntu-24.04 + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: 下载submodule源码 + run: mv -f .gitmodules_github .gitmodules && git submodule sync && git submodule update --init + + # Install the cosign tool except on PR + # https://github.com/sigstore/cosign-installer + - name: Install cosign + uses: sigstore/cosign-installer@d572c9c13673d2e0a26fabf90b5748f36886883f + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.REGISTRY }} + username: zlmediakit + password: ${{ secrets.DOCKER_IO_SECRET }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + if: github.event_name != 'pull_request' && github.ref != 'refs/heads/feature/test' + id: build-and-push + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }}_py + labels: ${{ steps.meta.outputs.labels }} + build-args: MODEL=Release + file: ./dockerfile_py + platforms: linux/amd64,linux/arm64 + + # Sign the resulting Docker image digest except on PRs. + # This will only write to the public Rekor transparency log when the Docker + # repository is public to avoid leaking data. If you would like to publish + # transparency data even for private images, pass --force to cosign below. + # https://github.com/sigstore/cosign +# - name: Sign the published Docker image +# if: ${{ github.event_name != 'pull_request' }} +# env: +# COSIGN_EXPERIMENTAL: "true" +# # This step uses the identity token to provision an ephemeral certificate +# # against the sigstore community Fulcio instance. +# run: cosign sign ${{ steps.meta.outputs.tags }}@${{ steps.build-and-push.outputs.digest }} diff --git a/README.md b/README.md index b77f1725..487ebc83 100644 --- a/README.md +++ b/README.md @@ -210,10 +210,15 @@ zlmediakit采用 github action 持续集成自动编译打包上传编译产出 你可以从Docker Hub下载已经编译好的镜像并启动它: ```bash -#此镜像为github action 持续集成自动编译推送,跟代码(master分支)保持最新状态 +# 此镜像为github action 持续集成自动编译推送,跟代码(master分支)保持最新状态 docker run -id -p 1935:1935 -p 8080:80 -p 8443:443 -p 8554:554 -p 10000:10000 -p 10000:10000/udp -p 8000:8000/udp -p 9000:9000/udp zlmediakit/zlmediakit:master ``` +```bash +# 此镜像为github action 持续集成自动编译推送,跟代码(master分支)保持最新状态, 并开启了pymkui后台管理系统,支持web管理界面 +docker run -id -p 1935:1935 -p 8080:80 -p 8443:443 -p 8554:554 -p 10000:10000 -p 10000:10000/udp -p 8000:8000/udp -p 9000:9000/udp zlmediakit/zlmediakit:master_py +``` + 你也可以根据Dockerfile编译镜像: ```bash diff --git a/README_en.md b/README_en.md index d9b68db4..4b371e50 100644 --- a/README_en.md +++ b/README_en.md @@ -367,6 +367,11 @@ You can download the pre-compiled image from Docker Hub and start it: #This image is pushed by the GitHub continuous integration automatic compilation to keep up with the latest code (master branch) docker run -id -p 1935:1935 -p 8080:80 -p 8443:443 -p 8554:554 -p 10000:10000 -p 10000:10000/udp -p 8000:8000/udp -p 9000:9000/udp zlmediakit/zlmediakit:master ``` +```bash +# This image is automatically built and pushed via GitHub Actions CI, stays up-to-date with the latest code (master branch), +# and includes the pymkui backend management system with a web-based UI. +docker run -id -p 1935:1935 -p 8080:80 -p 8443:443 -p 8554:554 -p 10000:10000 -p 10000:10000/udp -p 8000:8000/udp -p 9000:9000/udp zlmediakit/zlmediakit:master_py +``` You can also compile the image based on the Dockerfile: diff --git a/dockerfile_py b/dockerfile_py new file mode 100644 index 00000000..5c6bc95f --- /dev/null +++ b/dockerfile_py @@ -0,0 +1,130 @@ +FROM ubuntu:24.04 AS build +#shell,rtmp,rtsp,rtsps,http,https,rtp +EXPOSE 1935/tcp +EXPOSE 554/tcp +EXPOSE 80/tcp +EXPOSE 443/tcp +EXPOSE 10000/udp +EXPOSE 10000/tcp +EXPOSE 8000/udp +EXPOSE 8000/tcp +EXPOSE 9000/udp + +# 设置环境变量,避免交互提示 +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y \ + git \ + build-essential \ + cmake \ + curl \ + unzip \ + zip \ + nasm \ + autoconf \ + automake \ + libtool \ + autoconf-archive \ + pkg-config \ + libavcodec-dev \ + libavformat-dev \ + libavutil-dev \ + libswscale-dev \ + libavfilter-dev \ + python3 \ + python3-dev \ + python3-pip \ + && rm -rf /var/lib/apt/lists/* + +RUN git clone https://github.com/ZLMediaKit/pymkui.git /opt/media/ZLMediaKit/pymkui + +# 克隆 vcpkg 并编译 +RUN git clone https://github.com/microsoft/vcpkg.git /opt/vcpkg \ + && /opt/vcpkg/bootstrap-vcpkg.sh + +# 将 vcpkg 路径加入环境变量 +ENV PATH="/opt/vcpkg:$PATH" +ENV VCPKG_ROOT=/opt/vcpkg +ENV CMAKE_TOOLCHAIN_FILE=/opt/vcpkg/scripts/buildsystems/vcpkg.cmake + +# 自动选择 triplet(x64-linux 或 arm64-linux) +RUN ARCH=$(dpkg --print-architecture) && \ + if [ "$ARCH" = "amd64" ]; then \ + TRIPLET="x64-linux"; \ + elif [ "$ARCH" = "arm64" ]; then \ + TRIPLET="arm64-linux"; \ + else \ + echo "Unsupported architecture: $ARCH" && exit 1; \ + fi && \ + echo "Using vcpkg triplet: $TRIPLET" && \ + /opt/vcpkg/vcpkg install jemalloc openssl libsrtp[openssl] --triplet $TRIPLET-dynamic + + +RUN mkdir -p /opt/media +COPY . /opt/media/ZLMediaKit +WORKDIR /opt/media/ZLMediaKit + +RUN mkdir -p build release/linux/Release/lib + +# 根据 dpkg 架构选择 vcpkg 动态库路径 +RUN ARCH=$(dpkg --print-architecture) && \ + if [ "$ARCH" = "amd64" ]; then VCPKG_LIB_PATH="/opt/vcpkg/installed/x64-linux-dynamic/lib"; \ + elif [ "$ARCH" = "arm64" ]; then VCPKG_LIB_PATH="/opt/vcpkg/installed/arm64-linux-dynamic/lib"; \ + else echo "Unsupported architecture: $ARCH" && exit 1; fi && \ + echo "Copying libs from $VCPKG_LIB_PATH" && \ + cp -rfP $VCPKG_LIB_PATH/* release/linux/Release/lib/ + +WORKDIR /opt/media/ZLMediaKit/build + +RUN ARCH=$(dpkg --print-architecture) && \ + if [ "$ARCH" = "amd64" ]; then TRIPLET="x64-linux"; \ + elif [ "$ARCH" = "arm64" ]; then TRIPLET="arm64-linux"; \ + else echo "Unsupported architecture: $ARCH" && exit 1; fi && \ + echo "Using vcpkg triplet: $TRIPLET" && \ + cmake -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \ + -DVCPKG_TARGET_TRIPLET=${TRIPLET}-dynamic \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_PYTHON=ON \ + -DPython3_EXECUTABLE=$(which python3) \ + -DENABLE_WEBRTC=ON -DENABLE_FFMPEG=ON \ + -DENABLE_TESTS=OFF -DENABLE_API=OFF .. && \ + make -j $(nproc) + +FROM ubuntu:24.04 + +RUN apt-get update && \ + DEBIAN_FRONTEND="noninteractive" \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + tzdata \ + libavcodec-dev \ + libavformat-dev \ + libavutil-dev \ + libswscale-dev \ + libavfilter-dev \ + ffmpeg \ + python3 \ + python3-dev \ + python3-pip && \ + apt-get autoremove -y && \ + apt-get clean -y && \ + rm -rf /var/lib/apt/lists/* + +ENV TZ=Asia/Shanghai +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \ + && echo $TZ > /etc/timezone && \ + mkdir -p /opt/media/bin/www && mkdir -p /opt/media/bin/lib + +WORKDIR /opt/media/bin/ + +COPY --from=build /opt/media/ZLMediaKit/release/linux/Release/MediaServer /opt/media/ZLMediaKit/default.pem /opt/media/bin/ +COPY --from=build /opt/media/ZLMediaKit/release/linux/Release/lib /opt/media/bin/lib +COPY --from=build /opt/media/ZLMediaKit/release/linux/Release/config.ini /opt/media/conf/ +RUN echo -e "\n[python]\nplugin=mk_plugin" >> /opt/media/conf/config.ini +COPY --from=build /opt/media/ZLMediaKit/www/ /opt/media/bin/www/ +COPY --from=build /opt/media/ZLMediaKit/pymkui /opt/media/bin/pymkui +RUN pip3 install --no-cache-dir --break-system-packages -r /opt/media/bin/pymkui/backend/requirements.txt +ENV PATH="/opt/media/bin:$PATH" +ENV PYTHONPATH="/opt/media/bin/pymkui/backend" +ENV LD_LIBRARY_PATH="/opt/media/bin/lib" +CMD ["./MediaServer","-s", "default.pem", "-c", "../conf/config.ini", "-l","1"]