From 5ee07c57a995b522b56ef9870bf9dcc80b213d45 Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 6 Jun 2024 13:35:00 +0530 Subject: [PATCH] Add Env variable for exhook.server.default.url in configs --- Dockerfile | 5 ++++- configs/emqx_exhook.conf | 2 +- docker-compose.yml | 4 ++-- entrypoint.sh | 9 +++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 97e7ca0..c38e0f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,4 +12,7 @@ COPY /data/loaded_plugins /opt/emqx/data/ EXPOSE 1883 8083 8084 8883 11883 18083 4370 5369 -ENTRYPOINT ["sh", "/opt/emqx/bin/emqx", "foreground"] \ No newline at end of file +COPY ./entrypoint.sh /opt/emqx/bin/entrypoint.sh +USER root +RUN chmod +x /opt/emqx/bin/entrypoint.sh +ENTRYPOINT ["/opt/emqx/bin/entrypoint.sh"] diff --git a/configs/emqx_exhook.conf b/configs/emqx_exhook.conf index 2804d78..405283c 100644 --- a/configs/emqx_exhook.conf +++ b/configs/emqx_exhook.conf @@ -48,7 +48,7 @@ ## The gRPC server url ## ## exhook.server.$name.url = url() -exhook.server.default.url = http://switch-gear:9000 +exhook.server.default.url = http://${SG_HOSTNAME}:9000 #exhook.server.default.ssl.cacertfile = etc/certs/cacert.pem #exhook.server.default.ssl.certfile = etc/certs/cert.pem diff --git a/docker-compose.yml b/docker-compose.yml index 0b11352..864e94e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,9 +18,9 @@ services: - ./static:/opt/emqx/static - ./configs:/opt/emqx/configs -# environment: + environment: # Hostname configurations -# - MGT_HOSTNAME=localhost + - SG_HOSTNAME=switchgear # - MGT_HTTPS_PORT=9443 # - MGT_HTTP_PORT=9763 # diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..18f53c6 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +CONFIG_PATH=/opt/emqx/etc/plugins/emqx_exhook.conf + +# Set emqx_exhook.conf configs +sed -i 's/${SG_HOSTNAME}/'$SG_HOSTNAME'/g' $CONFIG_PATH + +echo "Starting server.." +sh /opt/emqx/bin/emqx foreground