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

Bugfix/29963 fix missing config #775

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 1 addition & 4 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,7 @@ Check out the git repository and build the Docker image.
[source,bash]
----
git clone https://github.com/hivemq/hivemq-edge.git

cd hivemq-edge

docker/build.sh
./gradlew loadOciImage
----

The Docker image `hivemq/hivemq-edge:snapshot` is created locally.
Expand Down
88 changes: 88 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import java.time.Instant

group = "com.hivemq"

plugins {
id("com.hivemq.edge-version-updater")
id("io.github.sgtsilvio.gradle.oci") version "0.20.2"
}

tasks.register("clean") {
Expand Down Expand Up @@ -120,4 +123,89 @@ tasks.register("updateDependantVersions") {
}


val openSourceEdgeModuleBinaries: Configuration by configurations.creating {
isCanBeConsumed = false
isCanBeResolved = true
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named("binary"))
attribute(Usage.USAGE_ATTRIBUTE, objects.named("release"))
}
extendsFrom(edgeModule)
}

val hivemqEdgeJarRelease: Configuration by configurations.creating {
isCanBeConsumed = false
isCanBeResolved = true
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named("jar"))
attribute(Usage.USAGE_ATTRIBUTE, objects.named("release"))
}
extendsFrom(hivemq)
}

/* ******************** Docker ******************** */

oci {
registries {
dockerHub {
credentials()
}
}
imageDefinitions.register("main") {
imageName.set("hivemq/hivemq-edge")
allPlatforms {
dependencies {
runtime("library:eclipse-temurin:sha256!ec48c245e50016d20c36fd3cdd5b4e881eee68cab535955df74a8a9ec709faaa")
}
config {
creationTime.set(Instant.EPOCH)
user = "10000"
ports = setOf("1883", "2442", "8080")
environment = mapOf(
"JAVA_OPTS" to "-XX:+UnlockExperimentalVMOptions -XX:+UseNUMA",
"HIVEMQ_ALLOW_ALL_CLIENTS" to "true",
"LANG" to "en_US.UTF-8",
)
entryPoint = listOf("/opt/docker-entrypoint.sh")
arguments = listOf("/opt/hivemq/bin/run.sh")
volumes = setOf("/opt/hivemq/data", "/opt/hivemq/log")
workingDirectory = "/opt/hivemq"
}
layers {
layer("hivemq") {
metadata { creationTime.set(Instant.EPOCH) }
contents {
into("opt") {
filePermissions = 0b110_110_000
directoryPermissions = 0b111_111_000
permissions("**/*.sh", 0b111_111_000)
from("docker/docker-entrypoint.sh")
into("hivemq") {
from("./hivemq-edge/src/distribution") { filter { exclude("**/.gitkeep") } }
from(".docker/config-k8s.xml") {
into("conf-k8s")
rename("config-k8s.xml", "config.xml")
}
from("./docker/config.xml") { into("conf") }
from("./hivemq-edge/src/main/resources/config.xsd") { into("conf") }

// copy OSS modules
into("modules") {
from(openSourceEdgeModuleBinaries.elements)
}

from(hivemqEdgeJarRelease) { into("bin").rename(".*", "hivemq.jar") }
}
}
}
}
}
}
specificPlatform(platform("linux", "amd64"))
specificPlatform(platform("linux", "arm64", "v8"))
specificPlatform(platform("linux", "arm", "v7"))
}
}



75 changes: 0 additions & 75 deletions docker/DockerFile

This file was deleted.

9 changes: 9 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# How to create Docker Images via the OCI plugin

Context: We use an OCI plugin to create images for HiveMQ Edge instead of the DockerFile + build script approach.

```
./gradlew loadOciImage
```

Docker will load the image of HiveMQ Edge automatically into its image store
28 changes: 0 additions & 28 deletions docker/build.sh

This file was deleted.

44 changes: 5 additions & 39 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,53 +1,19 @@
#!/usr/bin/env bash

set -eo pipefail

# We set the bind address here to ensure HiveMQ uses the correct interface. Defaults to using the container hostname (which should be hardcoded in /etc/hosts)
if [ -z "${HIVEMQ_BIND_ADDRESS}" ]; then
if [[ -z "${HIVEMQ_BIND_ADDRESS}" ]]; then
echo "Getting bind address from container hostname"
ADDR=$(getent hosts ${HOSTNAME} | grep -v 127.0.0.1 | awk '{ print $1 }' | head -n 1)
HIVEMQ_BIND_ADDRESS=$(getent hosts ${HOSTNAME} | grep -v 127.0.0.1 | awk '{ print $1 }' | head -n 1)
export HIVEMQ_BIND_ADDRESS
else
echo "HiveMQ bind address was overridden by environment variable (value: ${HIVEMQ_BIND_ADDRESS})"
ADDR=${HIVEMQ_BIND_ADDRESS}
fi

# Remove allow all extension if applicable

if [[ "${HIVEMQ_ALLOW_ALL_CLIENTS}" != "true" ]]; then
echo "Disabling allow all extension"
rm -rf /opt/hivemq/extensions/hivemq-allow-all-extension &>/dev/null || true
fi

echo "set bind address from container hostname to ${ADDR}"
export HIVEMQ_BIND_ADDRESS=${ADDR}

# Step down from root privilege, only when we're attempting to run HiveMQ though.
if [[ "$1" = "/opt/hivemq/bin/run.sh" && "$(id -u)" = '0' && "${HIVEMQ_NO_ROOT_STEP_DOWN}" != "true" ]]; then
uid="hivemq"
gid="hivemq"
exec_cmd="exec gosu hivemq"
else
uid="$(id -u)"
gid="$(id -g)"
exec_cmd="exec"
fi

readonly uid
readonly gid
readonly exec_cmd

echo "setting uid '${uid}' and gid '${gid}'"

if [[ "$(id -u)" = "0" ]]; then
# Any of the following may fail but still allow HiveMQ to start normally, so lets ignore errors
set +e
chown -R "${uid}":"${gid}" /opt/hivemq
chown -R "${uid}":"${gid}" /opt/hivemq-*
chown "${uid}":"${gid}" /opt/hivemq/log
chown -R "${uid}":"${gid}" /opt/hivemq/conf
chown "${uid}":"${gid}" /opt/hivemq/conf/config.xml
chown -R "${uid}":"${gid}" /opt/hivemq/bin
chmod -R 700 /opt/hivemq-*
fi
echo "setting bind address to ${HIVEMQ_BIND_ADDRESS}"

HIVEMQ_BIND_ADDRESS=${ADDR} ${exec_cmd} "$@"
exec "$@"
31 changes: 0 additions & 31 deletions docker/publish-release.sh

This file was deleted.

1 change: 1 addition & 0 deletions hivemq-edge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ plugins {
id("com.hivemq.edge-version-updater")
id("com.hivemq.third-party-license-generator")


}

group = "com.hivemq"
Expand Down