Skip to content

Commit

Permalink
chore: emqx 5.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
id committed May 28, 2024
1 parent e0af461 commit d7d5134
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defaults:

jobs:
main:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
strategy:
matrix:
version:
Expand All @@ -23,6 +23,8 @@ jobs:
- '5.3'
- '5.4'
- '5.5'
- '5.6'
- '5.7'

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down
48 changes: 48 additions & 0 deletions 5.7/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
FROM debian:12-slim

ENV EMQX_VERSION=5.7.0
ENV AMD64_SHA256=910d6ff5af8c36df9d15ae99a9ffe03a9690849fd952b7666b5809d9f9c42180
ENV ARM64_SHA256=4e7c4e3f321f6ce8de5d9da93e96769a49174f62ffecc61451b2292e6f3e415f
ENV LC_ALL=C.UTF-8 LANG=C.UTF-8

RUN set -eu; \
apt-get update; \
apt-get install -y --no-install-recommends ca-certificates procps curl; \
arch=$(dpkg --print-architecture); \
if [ ${arch} = "amd64" ]; then sha256="$AMD64_SHA256"; fi; \
if [ ${arch} = "arm64" ]; then sha256="$ARM64_SHA256"; fi; \
. /etc/os-release; \
pkg="emqx-${EMQX_VERSION}-${ID}${VERSION_ID}-${arch}.tar.gz"; \
curl -f -O -L https://www.emqx.com/en/downloads/broker/v${EMQX_VERSION}/${pkg}; \
echo "$sha256 *$pkg" | sha256sum -c; \
mkdir /opt/emqx; \
tar zxf $pkg -C /opt/emqx; \
find /opt/emqx -name 'swagger*.js.map' -exec rm {} +; \
ln -s /opt/emqx/bin/* /usr/local/bin/; \
groupadd -r -g 1000 emqx; \
useradd -r -m -u 1000 -g emqx emqx; \
chown -R emqx:emqx /opt/emqx; \
rm -f $pkg; \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /opt/emqx

USER emqx

VOLUME ["/opt/emqx/log", "/opt/emqx/data"]

# emqx will occupy these port:
# - 1883 port for MQTT
# - 8083 for WebSocket/HTTP
# - 8084 for WSS/HTTPS
# - 8883 port for MQTT(SSL)
# - 18083 for dashboard and API
# - 4370 default Erlang distribution port
# - 5369 for backplain gen_rpc
EXPOSE 1883 8083 8084 8883 18083 4370 5369

COPY docker-entrypoint.sh /usr/bin/

ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"]

CMD ["/opt/emqx/bin/emqx", "foreground"]
53 changes: 53 additions & 0 deletions 5.7/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash

## Shell setting
if [[ -n "$DEBUG" ]]; then
set -ex
else
set -e
fi

shopt -s nullglob

## Local IP address setting

LOCAL_IP=$(hostname -i | grep -oE '((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])\.){3}(25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])' | head -n 1)

export EMQX_NAME="${EMQX_NAME:-emqx}"

## EMQX_NODE_NAME or EMQX_NODE__NAME to indicate the full node name to be used by EMQX
## If both are set EMQX_NODE_NAME takes higher precedence than EMQX_NODE__NAME
if [[ -z "${EMQX_NODE_NAME:-}" ]] && [[ -z "${EMQX_NODE__NAME:-}" ]]; then
# No node name is provide from environment variables
# try to resolve from other settings
if [[ -z "$EMQX_HOST" ]]; then
if [[ "$EMQX_CLUSTER__DISCOVERY_STRATEGY" == "dns" ]] && \
[[ "$EMQX_CLUSTER__DNS__RECORD_TYPE" == "srv" ]] && \
grep -q "$(hostname).$EMQX_CLUSTER__DNS__NAME" /etc/hosts; then
EMQX_HOST="$(hostname).$EMQX_CLUSTER__DNS__NAME"
elif [[ "$EMQX_CLUSTER__DISCOVERY_STRATEGY" == "k8s" ]] && \
[[ "$EMQX_CLUSTER__K8S__ADDRESS_TYPE" == "dns" ]] && \
[[ -n "$EMQX_CLUSTER__K8S__NAMESPACE" ]]; then
EMQX_CLUSTER__K8S__SUFFIX=${EMQX_CLUSTER__K8S__SUFFIX:-"pod.cluster.local"}
EMQX_HOST="${LOCAL_IP//./-}.$EMQX_CLUSTER__K8S__NAMESPACE.$EMQX_CLUSTER__K8S__SUFFIX"
elif [[ "$EMQX_CLUSTER__DISCOVERY_STRATEGY" == "k8s" ]] && \
[[ "$EMQX_CLUSTER__K8S__ADDRESS_TYPE" == 'hostname' ]] && \
[[ -n "$EMQX_CLUSTER__K8S__NAMESPACE" ]]; then
EMQX_CLUSTER__K8S__SUFFIX=${EMQX_CLUSTER__K8S__SUFFIX:-'svc.cluster.local'}
EMQX_HOST=$(grep -h "^$LOCAL_IP" /etc/hosts | grep -o "$(hostname).*.$EMQX_CLUSTER__K8S__NAMESPACE.$EMQX_CLUSTER__K8S__SUFFIX")
else
EMQX_HOST="$LOCAL_IP"
fi
export EMQX_HOST
fi
export EMQX_NODE_NAME="$EMQX_NAME@$EMQX_HOST"
fi

# The default rpc port discovery 'stateless' is mostly for clusters
# having static node names. So it's troulbe-free for multiple emqx nodes
# running on the same host.
# When start emqx in docker, it's mostly one emqx node in one container
# i.e. use port 5369 (or per tcp_server_port | ssl_server_port config) for gen_rpc
export EMQX_RPC__PORT_DISCOVERY="${EMQX_RPC__PORT_DISCOVERY:-manual}"

exec "$@"

0 comments on commit d7d5134

Please sign in to comment.