Skip to content

Commit

Permalink
Prepare 7.0.18. Support for GlassFish Embedded
Browse files Browse the repository at this point in the history
Created autodeploy directory for GF Embedded for convenience. 
More documentation for GF Embedded.

Dockerfile to be updated by the 7.0.18 hash after 7.0.18 is released.
  • Loading branch information
OndroMih committed Oct 2, 2024
1 parent 0893602 commit 9b8539c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions 7.0.18/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ RUN true \
&& rm -f ${PATH_GF_SERVER_LOG} ${PATH_GF_PASSWORD_FILE_FOR_CHANGE} \
&& chown -R glassfish:glassfish "${PATH_GF_HOME}" \
&& chmod +x /usr/local/bin/docker-entrypoint.sh \
&& mkdir ${PATH_GF_HOME}/autodeploy \
&& echo "Installation was successful."

USER glassfish
Expand Down
49 changes: 49 additions & 0 deletions 7.0.18/docs/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,55 @@ docker logs 5a11f2fe1a9dd1569974de913a181847aa22165b5015ab20b271b08a27426e72
docker stop 5a11f2fe1a9dd1569974de913a181847aa22165b5015ab20b271b08a27426e72
```

## Running GlassFish Embedded

### Run an application

To deploy an application with GlassFish Embedded, copy the application into the Docker image or mount the directory that contains it, and then pass the path to it as an argument. For example, if the application myapp.war is copied to the default `/opt/glassfish7` directory:

```
docker run -p 8080:8080 glassfish/7.0.18 runembedded myapp.war
```

You can also just copy applications into the /opt/glassfish7/autodeploy directory or mount a directory with applications to it. All applications in that directory will be automatically deployed. For example, if you have applications on a local directory `/deployments`:

```
docker run -p 8080:8080 -v /deployments:/opt/glassfish7/autodeploy glassfish/7.0.18 runembedded
```


### Configure GlassFish Embedded

You can configure GlassFish Embedded by command line aguments after the command runembedded, or by a configuration file. Several options are supported, for example set a different HTTP port or disable HTTP listener, set path to a custom domain configuration, run asadmin commands at startup, deploy applications.

You can also just create a configuration file called `glassfish.properties` in the default directory `/opt/glassfish7`, with all the options, including commands to execute and applications to deploy. Or specify path to a different configuration file with the `--properties` option.

To display usage instructions, run:

```
docker run -it -p 8080:8080 glassfish/7.0.18 runembedded
```

This Docker image also supports adding custom Java VM arguments, with the JVM_OPTS environments variable. FOr example, you can specify `-XX:MaxRAMPercentage=75` to set maximum heap size to 75% of RAM:

```
docker run -it -e JVM_OPTS=="-XX:MaxRAMPercentage=75" -p 8080:8080 glassfish/7.0.18 runembedded
```


### Debug with GlassFish Embedded

To enable debugging, you can either add a custom debugging instruction for the JVM with the `JVM_OPTS` variable, or you can set one of the following environment variables to `true`:

* `DEBUG` - enables remove debugger on port 9009, doesn't suspend the server
* `SUSPEND` - suspends the server right at the startup and continues when a debugger connects on port 9009

Example:

```
docker run -e SUSPEND=true -p 8080:8080 glassfish/7.0.18 runembedded
```

## TestContainers

This is probably the simplest possible test with [GlassFish](https://glassfish.org/) and [TestContainers](https://www.testcontainers.org/). It automatically starts the GlassFish Docker Container and then stops it after the test. The test here is quite trivial - downloads the welcome page and verifies if it contains expected phrases.
Expand Down

0 comments on commit 9b8539c

Please sign in to comment.