Compare commits
21 Commits
v11.0.10-v
...
jbr-v17.0.
Author | SHA1 | Date | |
---|---|---|---|
fb0267bb13 | |||
e80b70a0cb | |||
7a1ccfead3 | |||
315bf2c9e1 | |||
27abe6e394 | |||
bf5701b959 | |||
a2f80820eb | |||
69701fba42 | |||
fd6866da82 | |||
4850fe8183 | |||
7b23df70db | |||
8ae643f2e2 | |||
2f382d09c8 | |||
f25e3e374a | |||
afe871cc05 | |||
2a1ce87bfc | |||
12942fc38e | |||
8480c96ae3 | |||
0ab2648e3e | |||
1e048ff961 | |||
bc6f05b1f8 |
35
Dockerfile
35
Dockerfile
@@ -4,18 +4,28 @@ FROM ubuntu:${ubuntu.version}
|
||||
# Configure standard JAVA parameters
|
||||
ENV JAVA_MEMORY_INIT=128m
|
||||
ENV JAVA_MEMORY_MAX=512m
|
||||
ENV JAVA_HOME=/usr/local/lib/jvm/java-openjdk-jbr
|
||||
ENV JRE_HOME=/usr/local/lib/jvm/java-openjdk-jbr
|
||||
ENV JAVA_OPTS=
|
||||
ENV ENABLE_HOTSWAP=true
|
||||
ENV ENABLE_JDWP=true
|
||||
ENV DISABLE_HOTSWAP_PLUGINS=
|
||||
|
||||
# Install curl
|
||||
RUN apt update && apt -y install curl
|
||||
# Install curl & essentials
|
||||
RUN apt update && \
|
||||
apt -y install curl libfreetype6
|
||||
|
||||
# Download & Install DCEVM Java
|
||||
# Download & Install JBR Java
|
||||
RUN mkdir -p /usr/local/lib/jvm && \
|
||||
curl -L https://github.com/TravaOpenJDK/trava-jdk-${dcevm.majorVersion}-dcevm/releases/download/dcevm-${dcevm.version}/java${dcevm.majorVersion}-openjdk-dcevm-linux.tar.gz -o /usr/local/lib/jvm/java-openjdk-dcevm.tar.gz && \
|
||||
cd /usr/local/lib/jvm && tar xzvf java-openjdk-dcevm.tar.gz && mv dcevm-${dcevm.version} java-openjdk-dcevm && rm java-openjdk-dcevm.tar.gz
|
||||
curl -L https://cache-redirector.jetbrains.com/intellij-jbr/${jbr.filename} -o /usr/local/lib/jvm/java-openjdk-jbr.tar.gz && \
|
||||
cd /usr/local/lib/jvm && \
|
||||
tar xzvf java-openjdk-jbr.tar.gz && \
|
||||
mv ${jbr.basename} java-openjdk-jbr && \
|
||||
mkdir -p java-openjdk-jbr/lib/hotswap && \
|
||||
rm java-openjdk-jbr.tar.gz
|
||||
|
||||
# Download Hotswap Agent
|
||||
RUN curl -L https://github.com/HotswapProjects/HotswapAgent/releases/download/RELEASE-${hotswap.version}/hotswap-agent-${hotswap.version}.jar -o /usr/local/lib/jvm/hotswap-agent.jar
|
||||
RUN curl -L https://github.com/HotswapProjects/HotswapAgent/releases/download/RELEASE-${hotswap.version}/hotswap-agent-${hotswap.version}.jar -o /usr/local/lib/jvm/java-openjdk-jbr/lib/hotswap/hotswap-agent.jar
|
||||
|
||||
# Add directories for dynamic injection points
|
||||
RUN mkdir -p /var/lib/jvm && cd /var/lib/jvm && \
|
||||
@@ -23,11 +33,13 @@ RUN mkdir -p /var/lib/jvm && cd /var/lib/jvm && \
|
||||
mkdir classes classes-extra1 classes-extra2 classes-extra3 classes-extra4 classes-extra5 classes-extra6 classes-extra7 && \
|
||||
mkdir lib lib-extra1 lib-extra2 lib-extra3 lib-extra4 lib-extra5 lib-extra6 lib-extra7
|
||||
|
||||
# Add our Docker container initialization script
|
||||
ADD docker-entrypoint.sh /usr/local/bin
|
||||
# Add our Docker container initialization scripts
|
||||
ADD maven/target/setenv.sh /usr/local/bin/${namespace.prefix}-setenv.sh
|
||||
ADD maven/target/docker-entrypoint.sh /usr/local/bin
|
||||
RUN chmod 755 /usr/local/bin/docker-entrypoint.sh
|
||||
|
||||
# Add our default hotswap configuration; may be overwritten
|
||||
ADD hotswap-agent.properties /var/lib/jvm/lib
|
||||
# Add our default hotswap configuration; may be overwritten in dev/classes* volumes
|
||||
ADD maven/target/hotswap-agent.properties /var/lib/jvm/lib
|
||||
|
||||
# Listening for Java debugger traffic
|
||||
EXPOSE 8000
|
||||
@@ -37,6 +49,3 @@ EXPOSE 8000
|
||||
|
||||
# Execute the Docker container initialization script
|
||||
ENTRYPOINT [ "/usr/local/bin/docker-entrypoint.sh" ]
|
||||
|
||||
# Do nothing meaningful; made to be overridden
|
||||
CMD [ "-version" ]
|
||||
|
38
README.md
Normal file
38
README.md
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
# Java Application Container Image with Hot-Reloading
|
||||
|
||||
This project creates a Docker image that has uses both the [Jetbrains JDK](https://github.com/JetBrains/JetBrainsRuntime) and [Hotswap Agent](http://hotswapagent.org/) and the Java JDWP debugger. The combination of these utilities allows for the hot-reloading of Java resources and classes to enable rapid application development and debugging capabilties. As a Docker image, containers can be started to facilitate development without requiring complicated installations on developer workstations.
|
||||
|
||||
It is expected that containers are configured in Maven using the Fabric8 or Spotify Docker plugins. These configurations should expose the 8000 (debugger) port and any other port that the application may open. Most importantly, it should mount/bind the source code to the following possible paths.
|
||||
|
||||
| Directory | Type | Hot-Reloaded |
|
||||
| --------------------------------- |:---------:|:------------:|
|
||||
| `/var/lib/jvm/dev/classes` | Classpath | Yes |
|
||||
| `/var/lib/jvm/dev/classes-extra1` | Classpath | Yes |
|
||||
| `/var/lib/jvm/dev/classes-extra2` | Classpath | Yes |
|
||||
| `/var/lib/jvm/dev/classes-extra3` | Classpath | Yes |
|
||||
| `/var/lib/jvm/dev/classes-extra4` | Classpath | Yes |
|
||||
| `/var/lib/jvm/dev/classes-extra5` | Classpath | Yes |
|
||||
| `/var/lib/jvm/dev/classes-extra6` | Classpath | Yes |
|
||||
| `/var/lib/jvm/dev/classes-extra7` | Classpath | Yes |
|
||||
| `/var/lib/jvm/dev/lib` | JARs | No |
|
||||
| `/var/lib/jvm/dev/lib-extra1` | JARs | No |
|
||||
| `/var/lib/jvm/dev/lib-extra2` | JARs | No |
|
||||
| `/var/lib/jvm/dev/lib-extra3` | JARs | No |
|
||||
| `/var/lib/jvm/dev/lib-extra4` | JARs | No |
|
||||
| `/var/lib/jvm/dev/lib-extra5` | JARs | No |
|
||||
| `/var/lib/jvm/dev/lib-extra6` | JARs | No |
|
||||
| `/var/lib/jvm/dev/lib-extra7` | JARs | No |
|
||||
|
||||
You may include your own `hotswap-agent.properties` in any of the `classes` folders. The one loaded by default is usually sufficient.
|
||||
|
||||
You can specify the following environment variables when running the container.
|
||||
|
||||
| Environment Variable | Default Value | Description |
|
||||
| ------------------------- | ------------- | ----------- |
|
||||
| `JAVA_MEMORY_INIT` | `128m` | The initial and minimum JVM memory. |
|
||||
| `JAVA_MEMORY_MAX` | `512m` | The maximum JVM memory allowed. |
|
||||
| `ENABLE_HOTSWAP` | `true` | Set to `false` to disable the HotSwap agent. |
|
||||
| `DISABLE_HOTSWAP_PLUGINS` | | Provide a comma-delimited list of HotSwap plugins to disable. You can find a list of those plugins here: https://github.com/HotswapProjects/HotswapAgent/tree/master/plugin. The name is only specified in the source, like [*Spring*](https://github.com/HotswapProjects/HotswapAgent/blob/master/plugin/hotswap-agent-spring-plugin/src/main/java/org/hotswap/agent/plugin/spring/SpringPlugin.java). |
|
||||
| `ENABLE_JDWP` | `true` | Set to `false` to disable the Java debugger. |
|
||||
| `JAVA_OPTS` | | Set to extend the standard `JAVA_OPTS` environment variable. |
|
@@ -1,4 +1,9 @@
|
||||
#!/bin/bash
|
||||
JAVA_OPTS="-Xms${JAVA_MEMORY_INIT} -Xmx${JAVA_MEMORY_MAX} -XX:HotswapAgent=external -javaagent:/usr/local/lib/jvm/hotswap-agent.jar -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n $JAVA_OPTS"
|
||||
#!/bin/sh
|
||||
. /usr/local/bin/${namespace.prefix}-setenv.sh
|
||||
|
||||
exec "/usr/local/lib/jvm/java-openjdk-dcevm/bin/java ${JAVA_OPTS} $@"
|
||||
JAVA_CP="/var/lib/jvm/lib:/var/lib/jvm/lib/*"
|
||||
JAVA_CP="${JAVA_CP}:/var/lib/jvm/dev/classes:/var/lib/jvm/dev/classes-extra1:/var/lib/jvm/dev/classes-extra2:/var/lib/jvm/dev/classes-extra3:/var/lib/jvm/dev/classes-extra4:/var/lib/jvm/dev/classes-extra5:/var/lib/jvm/dev/classes-extra6:/var/lib/jvm/dev/classes-extra7"
|
||||
JAVA_CP="${JAVA_CP}:/var/lib/jvm/dev/lib/*:/var/lib/jvm/dev/lib-extra1/*:/var/lib/jvm/dev/lib-extra2/*:/var/lib/jvm/dev/lib-extra3/*:/var/lib/jvm/dev/lib-extra4/*:/var/lib/jvm/dev/lib-extra5/*:/var/lib/jvm/dev/lib-extra6/*:/var/lib/jvm/dev/lib-extra7/*"
|
||||
EXEC_JAVA_OPTS="${JAVA_OPTS} -classpath ${JAVA_CP}"
|
||||
|
||||
exec ${JAVA_HOME}/bin/java ${EXEC_JAVA_OPTS} ${JAVA_CLASS}
|
||||
|
@@ -7,7 +7,14 @@
|
||||
# This may be useful for example in multi module maven project to load class changes from upstream project
|
||||
# classes. Set extraClasspath to upstream project compiler output and .class file will have precedence to
|
||||
# classes from built JAR file.
|
||||
extraClasspath=/tmp/java/classpath
|
||||
extraClasspath=/var/lib/jvm/dev/classes; \
|
||||
/var/lib/jvm/dev/classes-extra1; \
|
||||
/var/lib/jvm/dev/classes-extra2; \
|
||||
/var/lib/jvm/dev/classes-extra3; \
|
||||
/var/lib/jvm/dev/classes-extra4; \
|
||||
/var/lib/jvm/dev/classes-extra5; \
|
||||
/var/lib/jvm/dev/classes-extra6; \
|
||||
/var/lib/jvm/dev/classes-extra7
|
||||
|
||||
# Watch for changes in a directory (resources only). If not set, changes of resources won't be observed.
|
||||
#
|
||||
@@ -19,19 +26,26 @@ extraClasspath=/tmp/java/classpath
|
||||
# replacements of resources in a building step (maven filtering resource option).
|
||||
# This setting will leave i.e. src/target/classes as default source for resources, but after the resource is modified
|
||||
# in src/main/resources, the new changed resource is served instead.
|
||||
watchResources=/tmp/java/resources
|
||||
watchResources=/var/lib/jvm/dev/classes; \
|
||||
/var/lib/jvm/dev/classes-extra1; \
|
||||
/var/lib/jvm/dev/classes-extra2; \
|
||||
/var/lib/jvm/dev/classes-extra3; \
|
||||
/var/lib/jvm/dev/classes-extra4; \
|
||||
/var/lib/jvm/dev/classes-extra5; \
|
||||
/var/lib/jvm/dev/classes-extra6; \
|
||||
/var/lib/jvm/dev/classes-extra7
|
||||
|
||||
# Load static web resources from different directory.
|
||||
#
|
||||
# This setting is dependent on application server plugin(Jetty, Tomcat, ...).
|
||||
# Jboss and Glassfish are not yet supported.
|
||||
# Use this setting to set to serve resources from source directory directly (e.g. src/main/webapp).
|
||||
webappDir=/var/java/web
|
||||
webappDir=
|
||||
|
||||
|
||||
# Comma separated list of disabled plugins
|
||||
# Use plugin name - e.g. Hibernate, Spring, ZK, Hotswapper, AnonymousClassPatch, Tomcat, Logback ....
|
||||
disabledPlugins=
|
||||
disabledPlugins=${hotswap.disablePlugins}
|
||||
|
||||
# Watch for changed class files on watchResources path and reload class definition in the running application.
|
||||
#
|
||||
|
61
pom.xml
61
pom.xml
@@ -2,25 +2,29 @@
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.inteligr8</groupId>
|
||||
<artifactId>java-dcevm-hotswap</artifactId>
|
||||
<version>11.0.10-1.4.1</version>
|
||||
<name>Java DCEVM for Rapid Application Development</name>
|
||||
<artifactId>jdk-hotswap</artifactId>
|
||||
<version>2.0.1-jbr-17.0.12</version>
|
||||
<name>Java Hotswap Kit for Rapid Application Development</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<!-- The release version of Ubuntu to use as the base -->
|
||||
<!-- See: https://hub.docker.com/_/ubuntu -->
|
||||
<!-- This has very little impact and may be replaced -->
|
||||
<ubuntu.version>20.04</ubuntu.version>
|
||||
<ubuntu.version>24.10</ubuntu.version>
|
||||
|
||||
<!-- The version of Java DCEVM to use for executing Apache Tomcat -->
|
||||
<!-- See: https://github.com/TravaOpenJDK/trava-jdk-11-dcevm/releases -->
|
||||
<dcevm.version>11.0.10+4</dcevm.version>
|
||||
<dcevm.majorVersion>11</dcevm.majorVersion>
|
||||
<namespace.prefix>${project.artifactId}</namespace.prefix>
|
||||
|
||||
<!-- The version of the Hotswap Agent to use -->
|
||||
<!-- See: https://github.com/HotswapProjects/HotswapAgent/releases -->
|
||||
<hotswap.version>1.4.1</hotswap.version>
|
||||
<hotswap.version>2.0.1</hotswap.version>
|
||||
|
||||
<!-- The version of the JetBrains JDK -->
|
||||
<!-- See: https://github.com/JetBrains/JetBrainsRuntime/releases -->
|
||||
<jbr.version>17.0.12</jbr.version>
|
||||
<jbr.buildNumber>1000.54</jbr.buildNumber>
|
||||
<jbr.basename>jbr_jcef-${jbr.version}-linux-x64-b${jbr.buildNumber}</jbr.basename>
|
||||
<jbr.filename>${jbr.basename}.tar.gz</jbr.filename>
|
||||
|
||||
<!-- The Docker image meta-data for pushing the build -->
|
||||
<image.name>inteligr8/${project.artifactId}</image.name>
|
||||
@@ -29,12 +33,38 @@
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>.</directory>
|
||||
<includes>
|
||||
<include>*.sh</include>
|
||||
<include>*.properties</include>
|
||||
</includes>
|
||||
<filtering>true</filtering>
|
||||
<targetPath>${project.build.directory}</targetPath>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals><goal>resources</goal></goals>
|
||||
<configuration>
|
||||
<encoding>utf-8</encoding>
|
||||
<propertiesEncoding>utf-8</propertiesEncoding>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- This plugin build and pushes the Docker image -->
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>fabric8-maven-plugin</artifactId>
|
||||
<version>4.4.0</version>
|
||||
<groupId>org.eclipse.jkube</groupId>
|
||||
<artifactId>kubernetes-maven-plugin</artifactId>
|
||||
<version>1.18.0</version>
|
||||
<configuration>
|
||||
<images>
|
||||
<image>
|
||||
@@ -42,8 +72,7 @@
|
||||
<registry>${image.registry}</registry>
|
||||
</image>
|
||||
</images>
|
||||
<contextDir>${basedir}</contextDir>
|
||||
<buildStrategy>docker</buildStrategy>
|
||||
<contextDir>${project.build.directory}</contextDir>
|
||||
<verbose>true</verbose>
|
||||
</configuration>
|
||||
<executions>
|
||||
@@ -64,7 +93,7 @@
|
||||
<!-- This plugin prevents the project from deploying to the Maven Repository, as it is pointless -->
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.0.0-M1</version>
|
||||
<version>3.1.3</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
@@ -76,7 +105,7 @@
|
||||
<profile>
|
||||
<id>no-docker</id>
|
||||
<properties>
|
||||
<fabric8.build.jib>true</fabric8.build.jib>
|
||||
<jkube.build.strategy>jib</jkube.build.strategy>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
11
setenv.sh
Normal file
11
setenv.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
JAVA_OPTS="${JAVA_OPTS} -Xms${JAVA_MEMORY_INIT} -Xmx${JAVA_MEMORY_MAX}"
|
||||
|
||||
if [ "${ENABLE_HOTSWAP}" = "true" ]; then
|
||||
JAVA_OPTS="${JAVA_OPTS} -XX:+AllowEnhancedClassRedefinition -XX:HotswapAgent=fatjar"
|
||||
JAVA_OPTS="${JAVA_OPTS} -Dhotswap.disablePlugins=${DISABLE_HOTSWAP_PLUGINS}"
|
||||
fi
|
||||
|
||||
if [ "${ENABLE_JDWP}" = "true" ]; then
|
||||
JAVA_OPTS="${JAVA_OPTS} -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"
|
||||
fi
|
Reference in New Issue
Block a user