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

mediamtx: Publish deployed version if runtime args are present #3285

Merged
merged 3 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ end_of_line = unset
insert_final_newline = unset

# Makefiles/Dockerfile/golang files
[{Makefile,Dockerfile{,.debian},*.go}]
[{Makefile,Dockerfile{,.cuda-base,.mediamtx},*.go}]
indent_style = tab
indent_size = 8

# YAML/JSON Files
[{.ecrc,*.{yml,yaml,sh,json}}]
# YAML/JSON/sh Files
[{.ecrc,*.{yml,yaml,sh,json,bash}}]
indent_size = 2

[{server/handlers_test,eth/accountmanager_test}.go]
Expand Down
5 changes: 5 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ docker:
- any-glob-to-any-file:
- "docker/**"

docs:
- changed-files:
- any-glob-to-any-file:
- "doc/**"

github_actions:
- changed-files:
- any-glob-to-any-file:
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/docker-mediamtx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ name: MediaMTX Docker build

on:
pull_request:
branches:
- master
paths:
- 'docker/*mediamtx*'
push:
branches:
- master
paths:
- 'docker/Dockerfile.mediamtx'
- 'docker/mediamtx.yml'
- 'docker/*mediamtx*'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -20,7 +23,7 @@ jobs:
permissions:
packages: write
contents: read
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/[email protected]
Expand Down
30 changes: 18 additions & 12 deletions docker/Dockerfile.mediamtx
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
FROM ubuntu:24.04
FROM ubuntu:24.04

ENV MEDIAMTX_VERSION="v1.9.3"
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

pwilczynskiclearcode marked this conversation as resolved.
Show resolved Hide resolved
# we need curl in the image as it's later used in the runOnReady command
RUN apt-get update \
&& apt-get install -y \
ca-certificates \
curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update \
&& apt-get install -y \
ca-certificates \
curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN tar xzf /opt/mediamtx.tar.gz -C /opt/ \
&& 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/

RUN curl -L https://github.com/bluenviron/mediamtx/releases/download/${MEDIAMTX_VERSION}/mediamtx_${MEDIAMTX_VERSION}_linux_amd64.tar.gz -o /mediamtx.tar.gz \
&& tar xzvf /mediamtx.tar.gz \
&& rm /mediamtx.tar.gz
COPY mediamtx-entry.bash /

ENTRYPOINT ["/mediamtx"]
ENTRYPOINT ["/mediamtx-entry.bash"]
19 changes: 19 additions & 0 deletions docker/mediamtx-entry.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

[ -v DEBUG ] && set -x

set -euo pipefail

if [ -v LP_PUBLISH_MEDIAMTX_METRICS ]; then
if [ -z "$LP_PUBLISH_MEDIAMTX_METRICS_ENDPOINT" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we exit if the endpoint is not specified?

if [ -z "$LP_PUBLISH_MEDIAMTX_METRICS_ENDPOINT" ]; then
    echo >&2 "No endpoint specified for publishing mediamtx metrics."
    exit 1
fi

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was thinking it more as a warning than a fail condition.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if LP_PUBLISH_MEDIAMTX_METRICS_ENDPOINT is missing then curl would fail few lines below.

But yeah warning is fine... I think we'd catch it missing anyway as not having mediamtx version on grafana

echo >&2 "No endpoint specified for publishing mediamtx metrics."
fi
echo <<EOF |
# HELP version Current software version as a tag, always 1
# TYPE version gauge
version{app="MediaMTX",version="$MEDIAMTX_VERSION"} 1
EOF
curl -X POST --data-binary @- "$LP_PUBLISH_MEDIAMTX_METRICS_ENDPOINT"
fi

/usr/local/bin/mediamtx
pwilczynskiclearcode marked this conversation as resolved.
Show resolved Hide resolved
Loading