From c88adc86266bb89e287cc97fcf5f74fd693f4dcd Mon Sep 17 00:00:00 2001 From: pasindu Date: Tue, 28 May 2024 12:49:11 +0530 Subject: [PATCH 1/4] Added conf and data files to the container --- .gitignore | 21 +++++++++++++++++++++ Dockerfile | 15 +++++++++++---- configs/emqx_exhook.conf | 2 +- data/loaded_plugins | 9 +++++++++ entrypoint.sh | 11 ----------- 5 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 .gitignore create mode 100644 data/loaded_plugins delete mode 100644 entrypoint.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..61d85f1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Ignore everything in this directory +target +.classpath +.settings +.project +*.iml +*.iws +*.ipr +.idea +*.ids +.editorconfig +.gradle + +# Mac crap +.DS_Store diff --git a/Dockerfile b/Dockerfile index 9b9e88d..97e7ca0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,15 @@ FROM emqx/emqx:4.4.11 +ARG STATIC_CONFIG_PATH=/opt/emqx/lib/emqx_dashboard-4.4.10/priv/www/static/ + +# Copy static files +COPY /static/css/* ${STATIC_CONFIG_PATH}/css/ +COPY /static/img/* ${STATIC_CONFIG_PATH}/img/ + +# Copy configuration and data files +COPY /configs/emqx_exhook.conf /opt/emqx/etc/plugins/ +COPY /data/loaded_plugins /opt/emqx/data/ + EXPOSE 1883 8083 8084 8883 11883 18083 4370 5369 -COPY ./entrypoint.sh /opt/emqx/bin/entrypoint.sh -USER root -RUN chmod +x /opt/emqx/bin/entrypoint.sh -ENTRYPOINT ["/opt/emqx/bin/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["sh", "/opt/emqx/bin/emqx", "foreground"] \ No newline at end of file diff --git a/configs/emqx_exhook.conf b/configs/emqx_exhook.conf index 6bb3a63..2804d78 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://host.docker.internal:9000 +exhook.server.default.url = http://switch-gear:9000 #exhook.server.default.ssl.cacertfile = etc/certs/cacert.pem #exhook.server.default.ssl.certfile = etc/certs/cert.pem diff --git a/data/loaded_plugins b/data/loaded_plugins new file mode 100644 index 0000000..492bf24 --- /dev/null +++ b/data/loaded_plugins @@ -0,0 +1,9 @@ +{emqx_management,true}. +{emqx_dashboard,true}. +{emqx_modules,false}. +{emqx_retainer,true}. +{emqx_recon,true}. +{emqx_telemetry,true}. +{emqx_rule_engine,true}. +{emqx_bridge_mqtt,false}. +{emqx_exhook,true}. diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100644 index de15cd3..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -echo "copying static content" -STATIC_CONFIG_PATH=/opt/emqx/lib/emqx_dashboard-4.4.10/priv/www/static/ -cp /opt/emqx/static/css/* $STATIC_CONFIG_PATH/css/ -cp /opt/emqx/static/img/* $STATIC_CONFIG_PATH/img/ - -cp /opt/emqx/configs/emqx_exhook.conf /opt/emqx/etc/plugins/ - -echo "Starting server.." -sh /opt/emqx/bin/emqx foreground From 5ee07c57a995b522b56ef9870bf9dcc80b213d45 Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 6 Jun 2024 13:35:00 +0530 Subject: [PATCH 2/4] 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 From b6fa700fdca0abf4167aef0807946ccb791e784d Mon Sep 17 00:00:00 2001 From: pasindu Date: Fri, 12 Jul 2024 09:27:04 +0530 Subject: [PATCH 3/4] Change template name as generic vlues --- ReadMe.md | 14 ++++++-------- configs/emqx_exhook.conf | 2 +- docker-compose.yml | 4 ++-- entrypoint.sh | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/ReadMe.md b/ReadMe.md index b188303..02769c1 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,14 +1,12 @@ -1. docker build -t registry.entgra.io/entgra-emqx:4.4.11 -f Dockerfile . -2. docker-compose up -d -3. docker exec -it $(docker ps -aq -n 1) /bin/bash -4. docker-compose down - - -Note: +1. docker build -t registry.entgra.io/entgra-emqx:4.4.11-entgra-v2 -f Dockerfile . +2. Change Application server hostname in docker-compose +3. docker-compose up -d +4. docker exec -it $(docker ps -aq -n 1) /bin/bash +5. docker-compose down ``` For more emqx-docker things: https://github.com/emqx/emqx/tree/master/deploy/docker -``` \ No newline at end of file +``` diff --git a/configs/emqx_exhook.conf b/configs/emqx_exhook.conf index 405283c..d258430 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://${SG_HOSTNAME}:9000 +exhook.server.default.url = http://${SERVER_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 864e94e..038ddb2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.8" services: entgra-emqx: - image: registry.entgra.io/entgra-emqx:4.4.11 + image: registry.entgra.io/entgra-emqx:4.4.11-entgra-v2 container_name: entgra-emqx restart: always extra_hosts: @@ -20,7 +20,7 @@ services: environment: # Hostname configurations - - SG_HOSTNAME=switchgear + - SERVER_HOSTNAME=host_name # - MGT_HTTPS_PORT=9443 # - MGT_HTTP_PORT=9763 # diff --git a/entrypoint.sh b/entrypoint.sh index 18f53c6..8319bff 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,7 +3,7 @@ CONFIG_PATH=/opt/emqx/etc/plugins/emqx_exhook.conf # Set emqx_exhook.conf configs -sed -i 's/${SG_HOSTNAME}/'$SG_HOSTNAME'/g' $CONFIG_PATH +sed -i 's/${SERVER_HOSTNAME}/'$SERVER_HOSTNAME'/g' $CONFIG_PATH echo "Starting server.." sh /opt/emqx/bin/emqx foreground From b3dcc15f4c70dec5bf0d8721a8e0276c9324abbf Mon Sep 17 00:00:00 2001 From: pasindu Date: Fri, 12 Jul 2024 14:34:03 +0530 Subject: [PATCH 4/4] Add license headers to the files --- Dockerfile | 16 ++++++++++++++++ configs/emqx_exhook.conf | 16 ++++++++++++++++ docker-compose.yml | 16 ++++++++++++++++ entrypoint.sh | 16 ++++++++++++++++ 4 files changed, 64 insertions(+) diff --git a/Dockerfile b/Dockerfile index c38e0f8..b677ee2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,19 @@ +# Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. +# +# Entgra (Pvt) Ltd. licenses this file to you under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + FROM emqx/emqx:4.4.11 ARG STATIC_CONFIG_PATH=/opt/emqx/lib/emqx_dashboard-4.4.10/priv/www/static/ diff --git a/configs/emqx_exhook.conf b/configs/emqx_exhook.conf index d258430..2364d1b 100644 --- a/configs/emqx_exhook.conf +++ b/configs/emqx_exhook.conf @@ -1,3 +1,19 @@ +## Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. +## +## Entgra (Pvt) Ltd. licenses this file to you under the Apache License, +## Version 2.0 (the "License"); you may not use this file except +## in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, +## software distributed under the License is distributed on an +## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +## KIND, either express or implied. See the License for the +## specific language governing permissions and limitations +## under the License. + ##==================================================================== ## EMQX Hooks ##==================================================================== diff --git a/docker-compose.yml b/docker-compose.yml index 038ddb2..c541ac0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,19 @@ +# Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. +# +# Entgra (Pvt) Ltd. licenses this file to you under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + version: "3.8" services: diff --git a/entrypoint.sh b/entrypoint.sh index 8319bff..481bab8 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,21 @@ #!/bin/bash +# Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. +# +# Entgra (Pvt) Ltd. licenses this file to you under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + CONFIG_PATH=/opt/emqx/etc/plugins/emqx_exhook.conf # Set emqx_exhook.conf configs