diff --git a/.github/workflows/docker-test-supervisor.yml b/.github/workflows/docker-test-supervisor.yml new file mode 100644 index 00000000..c86615ed --- /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 -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 }} . + + - 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 }} diff --git a/docker/Dockerfile_Process b/docker/Dockerfile_Process index 013923b3..7870e1c9 100644 --- a/docker/Dockerfile_Process +++ b/docker/Dockerfile_Process @@ -14,15 +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 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 @@ -92,4 +97,23 @@ RUN if [ "true" = "$InstallMediaPush" ]; then \ # Example usage: ./start.sh -e 60 -ENTRYPOINT ["/usr/local/antmedia/start.sh"] +##################### supervisor configuration ############################## +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 [ "sh", "-c", "if [ \"$UseSupervisor\" = \"true\" ]; then exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf; else exec /usr/local/antmedia/start.sh; fi" ]