From 262d6f2fbc64099e5298b15227f0850839c2025d Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Tue, 10 Dec 2024 19:27:07 +0300 Subject: [PATCH 1/6] Add supervisor to Dockerfile for process management --- docker/Dockerfile_Process | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docker/Dockerfile_Process b/docker/Dockerfile_Process index 013923b3..81fdd2e4 100644 --- a/docker/Dockerfile_Process +++ b/docker/Dockerfile_Process @@ -92,4 +92,23 @@ RUN if [ "true" = "$InstallMediaPush" ]; then \ # Example usage: ./start.sh -e 60 +##################### supervisor configuration ############################## +#RUN apt-get update && apt-get install -y supervisor +# +#RUN echo '[supervisord]\n\ +#nodaemon=true\n\ +#\n\ +#[program:antmedia]\n\ +#command=/usr/local/antmedia/start.sh\n\ +#autostart=true\n\ +#autorestart=true\n\ +#user=antmedia\n\ +#stdout_logfile_maxbytes = 0\n\ +#stderr_logfile_maxbytes = 0\n\ +#stdout_logfile=/dev/stdout\n\ +#stderr_logfile=/dev/stderr' > /etc/supervisor/supervisord.conf +# +#ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"] +############################################################################## + ENTRYPOINT ["/usr/local/antmedia/start.sh"] From 159979e39b0096512349f8a1abcd94556abe7fe8 Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Mon, 23 Dec 2024 11:24:49 +0300 Subject: [PATCH 2/6] Update Usage section --- docker/Dockerfile_Process | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker/Dockerfile_Process b/docker/Dockerfile_Process index 81fdd2e4..62d6521c 100644 --- a/docker/Dockerfile_Process +++ b/docker/Dockerfile_Process @@ -14,6 +14,9 @@ # * InstallMediaPush: Set this variable to 'true' to enable headless Chrome on the server for recording and streaming web pages back to Ant Media Server. # --build-arg InstallMediaPush='true' # +# * Supervisor Configuration (Optional) +# If you want to use Supervisor to manage the Ant Media Server process, you can uncomment the Supervisor-related section in the Dockerfile. +# With this configuration, you can easily restart, stop the service, or run the `enable_ssl.sh` script for Ant Media Server. FROM ubuntu:22.04 From b321f85724c6e127acc9c5c2d1598b910e2f624a Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Mon, 6 Jan 2025 07:39:02 +0300 Subject: [PATCH 3/6] Add Supervisor as build parameter --- docker/Dockerfile_Process | 44 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/docker/Dockerfile_Process b/docker/Dockerfile_Process index 62d6521c..940d14cd 100644 --- a/docker/Dockerfile_Process +++ b/docker/Dockerfile_Process @@ -14,18 +14,20 @@ # * InstallMediaPush: Set this variable to 'true' to enable headless Chrome on the server for recording and streaming web pages back to Ant Media Server. # --build-arg InstallMediaPush='true' # -# * Supervisor Configuration (Optional) -# If you want to use Supervisor to manage the Ant Media Server process, you can uncomment the Supervisor-related section in the Dockerfile. -# With this configuration, you can easily restart, stop the service, or run the `enable_ssl.sh` script for Ant Media Server. +# * Supervisor Configuration (Optional): If you want to use Supervisor to manage the Ant Media Server process, you can enable as follows. With this configuration, you can easily restart, stop the service, or run the `enable_ssl.sh` script for Ant Media Server. +# --build-arg UseSupervisor='true' +# FROM ubuntu:22.04 ARG AntMediaServer ARG LicenseKey ARG InstallMediaPush - +ARG UseSupervisor=false ARG BranchName=master +ENV UseSupervisor=${UseSupervisor} + #Running update and install makes the builder not to use cache which resolves some updates RUN apt-get update && apt-get install -y curl wget iproute2 cron logrotate dnsutils iptables @@ -96,22 +98,22 @@ RUN if [ "true" = "$InstallMediaPush" ]; then \ ##################### supervisor configuration ############################## -#RUN apt-get update && apt-get install -y supervisor -# -#RUN echo '[supervisord]\n\ -#nodaemon=true\n\ -#\n\ -#[program:antmedia]\n\ -#command=/usr/local/antmedia/start.sh\n\ -#autostart=true\n\ -#autorestart=true\n\ -#user=antmedia\n\ -#stdout_logfile_maxbytes = 0\n\ -#stderr_logfile_maxbytes = 0\n\ -#stdout_logfile=/dev/stdout\n\ -#stderr_logfile=/dev/stderr' > /etc/supervisor/supervisord.conf -# -#ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"] +RUN if [ "true" = "$UseSupervisor" ]; then \ + apt-get update && apt-get install -y supervisor && \ + echo '[supervisord]\n\ + nodaemon=true\n\ + \n\ + [program:antmedia]\n\ + command=/usr/local/antmedia/start.sh\n\ + autostart=true\n\ + autorestart=true\n\ + user=antmedia\n\ + stdout_logfile_maxbytes = 0\n\ + stderr_logfile_maxbytes = 0\n\ + stdout_logfile=/dev/stdout\n\ + stderr_logfile=/dev/stderr' > /etc/supervisor/supervisord.conf; \ + fi + ############################################################################## -ENTRYPOINT ["/usr/local/antmedia/start.sh"] +ENTRYPOINT [ "sh", "-c", "if [ \"$UseSupervisor\" = \"true\" ]; then exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf; else exec /usr/local/antmedia/start.sh; fi" ] From 15c1838e8965c8bfaa723657b90aa5ce8d492783 Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Mon, 6 Jan 2025 07:59:54 +0300 Subject: [PATCH 4/6] Add argument parameter to start.sh for Supervisor --- docker/Dockerfile_Process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile_Process b/docker/Dockerfile_Process index 940d14cd..7870e1c9 100644 --- a/docker/Dockerfile_Process +++ b/docker/Dockerfile_Process @@ -104,7 +104,7 @@ RUN if [ "true" = "$UseSupervisor" ]; then \ nodaemon=true\n\ \n\ [program:antmedia]\n\ - command=/usr/local/antmedia/start.sh\n\ + command="/usr/local/antmedia/start.sh $@"\n\ autostart=true\n\ autorestart=true\n\ user=antmedia\n\ From cf8527a3ef75063d1e6e6082a4ae7d038b10479f Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Mon, 6 Jan 2025 10:47:22 +0300 Subject: [PATCH 5/6] Add Docker build and test workflow for supervisord --- .github/workflows/docker-test-supervisor.yml | 62 ++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/docker-test-supervisor.yml diff --git a/.github/workflows/docker-test-supervisor.yml b/.github/workflows/docker-test-supervisor.yml new file mode 100644 index 00000000..e49943a8 --- /dev/null +++ b/.github/workflows/docker-test-supervisor.yml @@ -0,0 +1,62 @@ + +name: Ant Media Server Docker Test (Supervisor/No-Supervisor) +on: [push] +#on: +# push: +# branches: +# - main +# pull_request: +# branches: +# - main + +jobs: + build-and-test: + runs-on: ubuntu-latest + strategy: + matrix: + use_supervisor: [false, true] + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build Docker Image + id: build-image + run: | + docker build \ + --build-arg UseSupervisor=${{ matrix.use_supervisor }} \ + --build-arg LicenseKey=${{ secrets.DOCKER_TEST_AMS_LICENSE_KEY }} \ + -t my-docker-image:${{ github.run_id }}-${{ matrix.use_supervisor }} . + + - name: Run Docker Container (No Supervisor) + if: ${{ matrix.use_supervisor == false }} + run: | + docker run --name test-container-${{ github.run_id }}-${{ matrix.use_supervisor }} \ + -d my-docker-image:${{ github.run_id }}-${{ matrix.use_supervisor }} + + sleep 10 + + docker logs test-container-${{ github.run_id }}-${{ matrix.use_supervisor }} + + docker inspect -f '{{.State.Running}}' test-container-${{ github.run_id }}-${{ matrix.use_supervisor }} + + docker stop test-container-${{ github.run_id }}-${{ matrix.use_supervisor }} + docker rm test-container-${{ github.run_id }}-${{ matrix.use_supervisor }} + + - name: Run Docker Container (With Supervisor) + if: ${{ matrix.use_supervisor == true }} + run: | + docker run --name test-container-${{ github.run_id }}-${{ matrix.use_supervisor }} \ + -d -e ENABLE_SUPERVISOR=true my-docker-image:${{ github.run_id }}-${{ matrix.use_supervisor }} + + sleep 10 + + docker logs test-container-${{ github.run_id }}-${{ matrix.use_supervisor }} + + docker inspect -f '{{.State.Running}}' test-container-${{ github.run_id }}-${{ matrix.use_supervisor }} + + docker stop test-container-${{ github.run_id }}-${{ matrix.use_supervisor }} + docker rm test-container-${{ github.run_id }}-${{ matrix.use_supervisor }} From 365b06473d818af69471f52f1deb3949f161c0d5 Mon Sep 17 00:00:00 2001 From: Murat Ugur Eminoglu Date: Mon, 6 Jan 2025 10:51:10 +0300 Subject: [PATCH 6/6] Update docker-test-supervisor.yml --- .github/workflows/docker-test-supervisor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-test-supervisor.yml b/.github/workflows/docker-test-supervisor.yml index e49943a8..c86615ed 100644 --- a/.github/workflows/docker-test-supervisor.yml +++ b/.github/workflows/docker-test-supervisor.yml @@ -26,7 +26,7 @@ jobs: - name: Build Docker Image id: build-image run: | - docker build \ + docker build -f docker/Dockerfile_Process \ --build-arg UseSupervisor=${{ matrix.use_supervisor }} \ --build-arg LicenseKey=${{ secrets.DOCKER_TEST_AMS_LICENSE_KEY }} \ -t my-docker-image:${{ github.run_id }}-${{ matrix.use_supervisor }} .