add git hash
parent
441729d0a1
commit
ca5ff418f9
|
@ -1,4 +1,4 @@
|
|||
FROM debian:12
|
||||
FROM debian:12 as prepare
|
||||
RUN apt-get update && apt-get upgrade -y
|
||||
RUN apt-get install -y php-dev php-cli php-pear php-mbstring php-curl git build-essential libmosquitto-dev libmosquitto-dev php-sqlite3
|
||||
WORKDIR /tmp
|
||||
|
@ -11,4 +11,12 @@ RUN make install
|
|||
RUN echo "extension=mosquitto.so" > /etc/php/8.2/cli/php.ini
|
||||
ADD run /usr/local/bin/entrypoint
|
||||
RUN chmod +x /usr/local/bin/entrypoint
|
||||
FROM prepare as make_git_id
|
||||
WORKDIR /tmp/repo
|
||||
ADD .git /tmp/repo/.git
|
||||
RUN git rev-parse HEAD > /tmp/git_id
|
||||
FROM prepare as runner
|
||||
ENV GIT_ID=unknown
|
||||
COPY --from=make_git_id /tmp/git_id /var/lib/git_id
|
||||
|
||||
CMD ["/usr/local/bin/entrypoint"]
|
||||
|
|
|
@ -14,13 +14,16 @@ pcntl_signal(SIGTERM, "endit");
|
|||
pcntl_signal(SIGHUP, "endit");
|
||||
|
||||
$mqttPort = getEnvWithDefaultInt("MQTT_PORT", 1883);
|
||||
|
||||
$mqttUser = getEnvWithDefaultStr("MQTT_USER", "");
|
||||
$mqttPass = getEnvWithDefaultStr("MQTT_PASS", "");
|
||||
$mqttClientId = getEnvWithDefaultStr("MQTT_CLIENT_ID", "mqtt2prometheus");
|
||||
$mqttTopic = getEnvWithDefaultStr("MQTT_TOPIC", "prometheus");
|
||||
$qos = getEnvWithDefaultInt("MQTT_QOS", 2);
|
||||
$ignoreRetained = getEnvWithDefaultInt("IGNORE_RETAINED", 1) ? 1 : 0;
|
||||
$gitId="Unknown";
|
||||
if (is_file("/var/lib/git_id")) {
|
||||
$gitId = trim(file_get_contents("/var/lib/git_id"));
|
||||
}
|
||||
|
||||
$mqtt = new Mosquitto\Client($mqttClientId);
|
||||
|
||||
|
@ -185,10 +188,11 @@ function precheck(Message $message): bool
|
|||
function output(): void
|
||||
{
|
||||
filter();
|
||||
global $data, $stats, $globalCounter;
|
||||
global $data, $stats, $globalCounter,$gitId;
|
||||
$t = time();
|
||||
|
||||
$prom = "";
|
||||
$prom .= "# from git-id : $gitId\n";
|
||||
$prom .=
|
||||
"# service started at : " .
|
||||
STARTED .
|
||||
|
|
Loading…
Reference in New Issue