Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add supervisor to Dockerfile for process management #322

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/docker-test-supervisor.yml
Original file line number Diff line number Diff line change
@@ -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 }}
28 changes: 26 additions & 2 deletions docker/Dockerfile_Process
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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" ]
Loading