Dockerize hawkular-services #25

Closed
wants to merge 36 commits into
from

Projects

None yet

6 participants

@pilhuhn
Member
pilhuhn commented Jun 22, 2016

This PR introduces a way to create and start a Docker container with Hawkular services inside.

The current state to get it to work is

$ mvn clean install
$ cd docker-dist
$ mvn docker:build docker:run

The created container will have a user of jdoe/password and the agent enabled.

@jmazzitelli
Contributor

Can you get this to optionally disable the agent?

@jmazzitelli jmazzitelli commented on an outdated diff Jun 22, 2016
dist/Dockerfile
+# limitations under the License.
+#
+
+# Dockerfile for hawkular-services
+
+FROM jboss/base-jdk:8
+
+MAINTAINER Heiko W. Rupp <hrupp@redhat.com>
+
+ADD target/hawkular-services-dist-0.0.2.Final-SNAPSHOT.zip /opt/hawkular.zip
+
+USER root
+
+env HAWKULAR_USER=jdoe
+env HAWKULAR_PASSWORD=password
+
@jmazzitelli
jmazzitelli Jun 22, 2016 Contributor

env HAWKULAR_AGENT_ENABLED=true

@jmazzitelli jmazzitelli commented on an outdated diff Jun 22, 2016
dist/startcmd.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+/opt/hawkular/bin/standalone.sh -b 0.0.0.0 \
+ -bmanagement 0.0.0.0 \
+ -Djboss.server.data.dir=/opt/data \
+ -Dhawkular.rest.user=${HAWKULAR_USER} \
+ -Dhawkular.rest.password=${HAWKULAR_PASSWORD}
@jmazzitelli
jmazzitelli Jun 22, 2016 Contributor

-Dhawkular.agent.enabled=${HAWKULAR_AGENT_ENABLED}

@jmazzitelli jmazzitelli commented on an outdated diff Jun 22, 2016
docker-dist/pom.xml
+
+ <parent>
+ <groupId>org.hawkular.services</groupId>
+ <artifactId>hawkular-services</artifactId>
+ <version>0.0.4.Final-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>hawkular-services-dist-docker</artifactId>
+ <packaging>pom</packaging>
+
+ <properties>
+ <docker-plugin.project.version>0.15.6</docker-plugin.project.version>
+ <docker.base-image>jboss/wildfly:10.0.0.Final</docker.base-image>
+ <plexus-utils.version>3.0.15</plexus-utils.version>
+ <alpn-boot.version>8.1.7.v20160121</alpn-boot.version>
+ <version.cassandra>3.7</version.cassandra>
@jmazzitelli
jmazzitelli Jun 22, 2016 edited Contributor

<hawkular.agent.enabled>true</hawkular.agent.enabled>

@jmazzitelli jmazzitelli commented on the diff Jun 22, 2016
docker-dist/pom.xml
+ <tag>latest</tag>
+ <tag>${project.version}</tag>
+ </tags>
+ <ports>
+ <port>8080</port>
+ <port>8443</port>
+ </ports>
+ <volumes>
+ <volume>/opt/data</volume>
+ </volumes>
+ <user>root</user>
+ <env>
+ <HAWKULAR_BACKEND>cassandra</HAWKULAR_BACKEND>
+ <CASSANDRA_NODES>myCassandra</CASSANDRA_NODES>
+ <HAWKULAR_USER>jdoe</HAWKULAR_USER>
+ <HAWKULAR_PASSWORD>password</HAWKULAR_PASSWORD>
@jmazzitelli
jmazzitelli Jun 22, 2016 Contributor

<HAWKULAR_AGENT_ENABLED>${hawkular.agent.enabled}</HAWKULAR_AGENT_ENABLED>

@jmazzitelli jmazzitelli commented on an outdated diff Jun 22, 2016
docker-dist/src/main/resources/startcmd.sh
+#
+# 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.
+#
+
+
+/opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 \
+ -bmanagement 0.0.0.0 \
+ -Djboss.server.data.dir=/opt/data/data \
+ -Djboss.server.log.dir=/opt/data/log \
+ -Dhawkular.agent.enabled=true \
@jmazzitelli
jmazzitelli Jun 22, 2016 Contributor

-Dhawkular.agent.enabled=${HAWKULAR_AGENT_ENABLED} \

@jmazzitelli
Contributor

When you start the docker container, this gets run:

/opt/hawkular/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0 ...

Does this prohibit the ability to run additional WildFly servers on your machine on different IPs like "127.0.0.5"? Rather than launch with different ports, I just always launch my servers on different IPs, that way all the ports always remain the same (8080, 9999, 9990, etc) - so I just have to remember 1 new number (the last digit of the new local IP - "5" in my example) rather than several new port numbers that are all offset from the other servers).

If not, can we make this configurable to be able to set the binding address with the default still 0.0.0.0? Make it configurable like the others (e.g. like the new HAWKULAR_AGENT_ENABLED I just commented about above).

@jmazzitelli jmazzitelli commented on an outdated diff Jun 22, 2016
docker-dist/pom.xml
@@ -35,6 +35,7 @@
<plexus-utils.version>3.0.15</plexus-utils.version>
<alpn-boot.version>8.1.7.v20160121</alpn-boot.version>
<version.cassandra>3.7</version.cassandra>
+ <hawkular.agent.enabled></hawkular.agent.enabled>
@jmazzitelli
jmazzitelli Jun 22, 2016 Contributor

you should set this to "true" rather than an empty string.

@pilhuhn
Member
pilhuhn commented Jun 22, 2016

On 22 Jun 2016, at 14:34, John Mazzitelli wrote:

When you start the docker container, this gets run:

/opt/hawkular/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0 ...

Does this prohibit the ability to run additional WildFly servers on
your machine on different IPs like "127.0.0.5"? Rather than launch
with

No. Those bindings are strictly internal to the container.
What is visible outside is at the end determined by the -p parameters
on docker run.
Or the ports section in docker-compose.yml
ports:
- "8080:8080"
- "8443:8443"
- "9990:9990"

Or this in the pom

             <ports>
               <port>8080</port>
               <port>8443</port>
             </ports>

I am not sure how to set the bind addr of the container, but from the
docs it looks like --ip= would do it.

hwr@pilhuhn.de m:0179/207 4919 b:http://pilhuhn.blogspot.com

@jmazzitelli
Contributor

I followed the instructions:

$ mvn clean install
$ cd docker-dist
$ mvn docker:build docker:run

But during the mvn docker:build, I get this error:

[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.15.6:build (default-cli) on project hawkular-services-dist-docker: Execution default-cli of goal io.fabric8:docker-maven-plugin:0.15.6:build failed: No url given, no DOCKER_HOST environment variable and no read/writable '/var/run/docker.sock' -> [Help 1]
@rhuss
rhuss commented Jun 22, 2016

You need to expose a DOCKER_HOST variable for accessing the Docker daemon. When using docker-machine use an eval $(docker-machine env) before.

@jmazzitelli
Contributor

This brings up two points then:

  1. you must have a docker daemon running (which I believe requires root)
  2. I guess for the maven build, we have to assume the host to the daemon is "localhost" if we are to set DOCKER_HOST to some reasonable default.
@jmazzitelli
Contributor
jmazzitelli commented Jun 22, 2016 edited

On Fedora 23. I export DOCKER_HOST in my shell (setting it to tcp://127.0.0.1). I have a docker daemon running as root. When I run mvn docker:build, I get this:

[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.15.6:build (default-cli) on project hawkular-services-dist-docker: Unable to pull 'jboss/wildfly:10.0.0.Final': <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
[ERROR] <html><head>
[ERROR] <title>404 Not Found</title>
[ERROR] </head><body>
[ERROR] <h1>Not Found</h1>
[ERROR] <p>The requested URL /v1.18/images/create was not found on this server.</p>
[ERROR] </body></html> (Not Found: 404)
pilhuhn and others added some commits Jun 15, 2016
@pilhuhn pilhuhn Initial cut at dockerizing of Hawkular-services. 421b754
@pilhuhn pilhuhn Add a way to dockerize Hawkular-server and run with linked C* container 43d9172
@pilhuhn pilhuhn Explicitly enable the agent. 0a2770d
@pilhuhn pilhuhn Make agent-enabled variable in startcmd and set the machine-id when s…
…tarting the container.
a0ad212
@pilhuhn pilhuhn Actually set the property :) 52a8880
@pilhuhn pilhuhn These files in dist/ are not needed and were pushed by accident 8eb1bf5
@pilhuhn pilhuhn Add the welcome-content. We should pull that in from dist/ though. c8427bc
@pilhuhn pilhuhn Bump docker plugin version 88c3d31
@pilhuhn pilhuhn Fix template syntax e385120
@pilhuhn pilhuhn Bump project version 377cd8b
@pilhuhn pilhuhn Parametrize the root directory of the application server. ed29c17
@Jiri-Kremser @jmazzitelli Jiri-Kremser Do not build the zip and tar.gz if the 'dev' Maven profile is activat…
…ed. (#30)
93b7743
@pilhuhn @metlos pilhuhn Bump agent to v 0.20.0 10cbddc
@metlos metlos Update inventory to 0.17.2.Final ffd941c
@pilhuhn pilhuhn Merge pull request #34 from metlos/inv-0.17.2.Final+agent-0.20.0.Final
Inventory 0.17.2.final + Agent 0.20.0.final
1b92033
@pilhuhn pilhuhn Bump metrics to v 0.17.0 4cbe002
@stefannegrea stefannegrea Merge pull request #35 from pilhuhn/metrics-0.17
Bump metrics to v 0.17.0
7c2fc2e
Jenkins @ torii [maven-release-plugin] prepare release 0.0.5.Final 2a00138
Jenkins @ torii [maven-release-plugin] prepare for next development iteration d22de71
@pilhuhn pilhuhn Initial cut at dockerizing of Hawkular-services. 26583f1
@pilhuhn pilhuhn Revert "Initial cut at dockerizing of Hawkular-services."
This reverts commit 26d630826bcd0365a5b02d12bab5010d8378777e.
3517173
@pilhuhn pilhuhn Add a way to dockerize Hawkular-server and run with linked C* container 25f501a
@pilhuhn pilhuhn Explicitly enable the agent. 1d22f7d
@pilhuhn pilhuhn Make agent-enabled variable in startcmd and set the machine-id when s…
…tarting the container.
f06802b
@pilhuhn pilhuhn Actually set the property :) efed5ad
@pilhuhn pilhuhn Add the welcome-content. We should pull that in from dist/ though. 0d13f53
@pilhuhn pilhuhn Bump docker plugin version 674c9be
@pilhuhn pilhuhn Fix template syntax a6a2292
@pilhuhn pilhuhn Bump project version 105f83f
@pilhuhn pilhuhn Parametrize the root directory of the application server. 7e28388
@pilhuhn pilhuhn remove -eap from image name d9534b5
@pilhuhn pilhuhn Bump project version. 2a8f6d6
@Jiri-Kremser Jiri-Kremser commented on an outdated diff Jul 8, 2016
docker-dist/pom.xml
+ </image>
+ <!-- A cassandra container that is used as backend storage -->
+ <image>
+ <alias>myCassandra</alias>
+ <name>cassandra:${version.cassandra}</name>
+ <run>
+ <env>
+ <CASSANDRA_START_RPC>true</CASSANDRA_START_RPC>
+ </env>
+ <volumes>
+ <bind>
+ <volume>/tmp/opt/hawkular/cassandra:/var/lib/cassandra</volume>
+ </bind>
+ </volumes>
+ </run>
+ </image>-->
@Jiri-Kremser
Jiri-Kremser Jul 8, 2016 edited Member

><(((°>

@Jiri-Kremser Jiri-Kremser commented on an outdated diff Jul 8, 2016
docker-dist/pom.xml
+ <CASSANDRA_NODES>myCassandra</CASSANDRA_NODES>
+ <HAWKULAR_USER>jdoe</HAWKULAR_USER>
+ <HAWKULAR_PASSWORD>password</HAWKULAR_PASSWORD>
+ <HAWKULAR_AGENT_ENABLE>${hawkular.agent.enabled}</HAWKULAR_AGENT_ENABLE>
+ <AS_ROOT>${docker.as.root}</AS_ROOT>
+ </env>
+ <cmd>
+ <shell>/opt/hawkular/bin/startcmd.sh</shell>
+ </cmd>
+ <assembly>
+ <basedir>/</basedir>
+ <descriptor>docker-assembly.xml</descriptor>
+ </assembly>
+ <runCmds>
+ <run>ls -lsa ${docker.as.root}/standalone/configuration</run>
+ <rum>whoami</rum>
@Jiri-Kremser
Jiri-Kremser Jul 8, 2016 edited Member

🍺
EDIT: rum - typo

@Jiri-Kremser Jiri-Kremser commented on an outdated diff Jul 14, 2016
docker-dist/pom.xml
+ <HAWKULAR_USER>jdoe</HAWKULAR_USER>
+ <HAWKULAR_PASSWORD>password</HAWKULAR_PASSWORD>
+ <HAWKULAR_AGENT_ENABLE>${hawkular.agent.enabled}</HAWKULAR_AGENT_ENABLE>
+ <AS_ROOT>${docker.as.root}</AS_ROOT>
+ </env>
+ <cmd>
+ <shell>/opt/hawkular/bin/startcmd.sh</shell>
+ </cmd>
+ <assembly>
+ <basedir>/</basedir>
+ <descriptor>docker-assembly.xml</descriptor>
+ </assembly>
+ <runCmds>
+ <run>ls -lsa ${docker.as.root}/standalone/configuration</run>
+ <rum>whoami</rum>
+ <run>${docker.as.root}/bin/add-user.sh -a -u ${HAWKULAR_USER} -p ${HAWKULAR_PASSWORD} -g read-write,read-only</run>
@Jiri-Kremser
Jiri-Kremser Jul 14, 2016 Member

this will end up in having 3 different RUN directives in a resulting docker file, which creates 3 different layers when building it => it'll increase the resulting size

a good practice is doing RUN foo && bar && baz

pilhuhn added some commits Jul 15, 2016
@pilhuhn pilhuhn remove two run commands, that were for debugging cad70d4
@pilhuhn pilhuhn remove superflous --> 63ab189
@pilhuhn pilhuhn Don't burn the user into the image, but pass via env-variables.
Also enable remote debugging port.
1da654b
@pilhuhn pilhuhn Merge remote-tracking branch 'origin/dockerize' into dockerize
# Conflicts:
#	docker-dist/docker-compose-template.yml
#	docker-dist/pom.xml
#	docker-dist/src/main/resources/startcmd.sh
12383c1
@pilhuhn pilhuhn closed this Jul 19, 2016
@pilhuhn pilhuhn deleted the unknown repository branch Jul 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment