-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mediamtx: Add cronjob to publish mediamtx metrics to server (#3298)
* mediamtx: Add cronjob to publish mediamtx metrics to server * dockerfile.mediamtx: Replace `ENTRYPOINT` with `CMD` * mediamtx: Fix cron environment issues
- Loading branch information
1 parent
b971acc
commit 0e1c676
Showing
3 changed files
with
34 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,31 @@ | ||
FROM ubuntu:24.04 | ||
|
||
# we need curl in the image as it's later used in the runOnReady command | ||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
RUN apt update \ | ||
&& apt install -yqq \ | ||
ca-certificates \ | ||
curl \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
cron \ | ||
&& apt clean \ | ||
&& rm -rf /var/lib/apt/lists/* /etc/cron.* | ||
|
||
COPY --chmod=0644 crontab /etc/crontab | ||
|
||
# Setup cron job for publishing metrics | ||
RUN mkdir -p /var/log/ \ | ||
&& crontab /etc/crontab \ | ||
&& touch /var/log/cron.log | ||
|
||
COPY --chmod=0755 mediamtx-metrics.bash /opt/mediamtx-metrics.bash | ||
|
||
ENV MEDIAMTX_VERSION="1.9.3" | ||
|
||
ADD "https://github.com/bluenviron/mediamtx/releases/download/v${MEDIAMTX_VERSION}/mediamtx_v${MEDIAMTX_VERSION}_linux_amd64.tar.gz" /opt/mediamtx.tar.gz | ||
ADD "https://github.com/bluenviron/mediamtx/releases/download/v${MEDIAMTX_VERSION}/mediamtx_v${MEDIAMTX_VERSION}_linux_amd64.tar.gz" /opt/mediamtx/mediamtx.tar.gz | ||
|
||
RUN tar xzf /opt/mediamtx.tar.gz -C /opt/ \ | ||
RUN tar xzf /opt/mediamtx/mediamtx.tar.gz -C /opt/mediamtx/ \ | ||
&& mkdir -p /usr/local/bin /etc/mediamtx/ \ | ||
&& mv /opt/mediamtx /usr/local/bin/mediamtx \ | ||
&& mv /opt/mediamtx.yml /etc/mediamtx/mediamtx.yml \ | ||
&& rm -rf /opt/ | ||
|
||
COPY mediamtx-entry.bash / | ||
&& mv /opt/mediamtx/mediamtx /usr/local/bin/mediamtx \ | ||
&& mv /opt/mediamtx/mediamtx.yml /etc/mediamtx/mediamtx.yml \ | ||
&& rm -rf /opt/mediamtx/ | ||
|
||
ENTRYPOINT ["/mediamtx-entry.bash"] | ||
CMD [ "/bin/bash", "-c", "declare -p >> /etc/environment && cron && /usr/local/bin/mediamtx" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SHELL=/bin/bash | ||
BASH_ENV=/etc/environment | ||
|
||
*/5 * * * * /opt/mediamtx-metrics.bash >> /var/log/cron.log 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters