Skip to content

Commit e93c822

Browse files
committed
Documentation for Embedded GlassFish
Deploy to /deploy directory for both Embedded and Server.
1 parent 11321aa commit e93c822

13 files changed

Lines changed: 485 additions & 7 deletions

File tree

images/embedded/7.1.0/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ RUN true \
4141
&& env | sort \
4242
&& chown -R glassfish:glassfish "${PATH_GF_HOME}" \
4343
&& mkdir ${PATH_GF_HOME}/autodeploy \
44+
&& ln -s ${PATH_GF_HOME}/autodeploy /deploy \
4445
&& echo "Installation was successful."
4546

4647
USER glassfish

images/server/7.1.0/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ RUN true \
7474
&& asadmin stop-domain --kill \
7575
&& rm -f ${PATH_GF_SERVER_LOG} ${PATH_GF_PASSWORD_FILE_FOR_CHANGE} \
7676
&& chown -R glassfish:glassfish "${PATH_GF_HOME}" \
77-
&& mkdir ${PATH_GF_HOME}/autodeploy \
77+
&& ln -s "${PATH_GF_HOME}/glassfish/domains/domain1/autodeploy" /deploy \
7878
&& echo "Installation was successful."
7979

8080
COPY --chmod=755 docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh

images/server/7.1.0/docs/content.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Eclipse GlassFish Docker images
22

3-
[Eclipse GlassFish](https://glassfish.org) is a Jakarta EE compatible implementation sponsored by the Eclipse Foundation.
3+
[Eclipse GlassFish](https://glassfish.org) is a Jakarta EE compatible implementation.
44

55
%%LOGO%%
66

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
</goals>
206206
<phase>prepare-package</phase>
207207
<configuration>
208-
<outputDirectory>${server.images.dir}/${docker.glassfish.tag}</outputDirectory>
208+
<outputDirectory>${server.images.dir}/${server.docker.glassfish.tag}</outputDirectory>
209209
<resources>
210210
<resource>
211211
<directory>${server.resources.dir}</directory>

src/main/resources/images/embedded/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ RUN true \
4141
&& env | sort \
4242
&& chown -R glassfish:glassfish "${PATH_GF_HOME}" \
4343
&& mkdir ${PATH_GF_HOME}/autodeploy \
44+
&& ln -s ${PATH_GF_HOME}/autodeploy /deploy \
4445
&& echo "Installation was successful."
4546

4647
USER glassfish
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Embedded Eclipse GlassFish is a Jakarta EE runtime based on GlassFish server, embeddable and executable as a JAR.
2+
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
# Eclipse GlassFish Embedded Docker Image
2+
3+
[Eclipse GlassFish](https://glassfish.org) is a Jakarta EE compatible implementation. This is the **Embedded** version that runs as a single JAR file without requiring a full server installation.
4+
5+
%%LOGO%%
6+
7+
**Source code repository of the Docker image:** https://github.com/eclipse-ee4j/glassfish.docker
8+
9+
## Quick start
10+
11+
### Start GlassFish Embedded
12+
13+
Run GlassFish Embedded with the following command:
14+
15+
```
16+
docker run -p 8080:8080 @docker.glassfish.embedded.repository@
17+
```
18+
19+
Or with a command for a specific tag (GlassFish version):
20+
21+
```
22+
docker run -p 8080:8080 @docker.glassfish.embedded.image@
23+
```
24+
25+
Open the following URL in the browser to access the HTTP port:
26+
27+
* http://localhost:8080
28+
29+
**Note:** GlassFish Embedded does not include the Administration Console. Use the full GlassFish Server image if you need administrative capabilities.
30+
31+
### Stop GlassFish Embedded
32+
33+
Stop GlassFish Embedded with the following command:
34+
35+
```
36+
docker stop CONTAINER_ID
37+
```
38+
39+
CONTAINER_ID can be found from the output of the following command:
40+
41+
```
42+
docker ps
43+
```
44+
45+
## Run an application with GlassFish Embedded in Docker
46+
47+
You can run an application located in your filesystem with GlassFish Embedded in a Docker container.
48+
49+
Follow these steps:
50+
51+
1. Create an empty directory on your filesystem, e.g. `/deployments`
52+
2. Copy the application package to this directory - so that it's for example on the path `/deployments/application.war`
53+
3. Run the following command to start GlassFish Embedded in Docker with your application, where /deployments is the directory created in step 1 and /deploy is the directory inside the container where Embedded GlassFish expects applications:
54+
55+
```
56+
docker run -p 8080:8080 -v /deployments:/deploy @docker.glassfish.embedded.repository@
57+
```
58+
59+
Then you can open the application in the browser with:
60+
61+
* http://localhost:8080
62+
63+
If there's a single application, if will be available under the roo (`/`) context root. If there are multiple applications, each will be available under a context root derived from the name of the application file (e.g. `application.war` would be deployed under the `/application` context root).
64+
65+
## Debug GlassFish Embedded inside a Docker container
66+
67+
You can enable debug mode by specifying JVM debug arguments in the standard `JAVA_TOOL_OPTIONS` environment variable and expose the debug port. For example:
68+
69+
```
70+
docker run -p 9009:9009 -p 8080:8080 -e 'JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:9009' @docker.glassfish.embedded.repository@
71+
```
72+
73+
Then connect your debugger to port 9009 on `localhost`.
74+
75+
If you need to suspend GlassFish startup until you connect the debugger, change `suspend=n` to `suspend=y`:
76+
77+
```
78+
docker run -p 9009:9009 -p 8080:8080 -e 'JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:9009' @docker.glassfish.embedded.repository@
79+
```
80+
81+
## Environment variables
82+
83+
The following environment variables are available:
84+
85+
* `PATH_GF_HOME` - directory that contains Embedded GlassFish JAR and is used as the default working directory (`/opt/glassfish`)
86+
* `PATH_GF_JAR` - path to the Embedded GlassFish JAR file
87+
* `GLASSFISH_VERSION` - version of GlassFish
88+
89+
## Additional configuration
90+
91+
### Custom JVM arguments
92+
93+
You can pass custom JVM arguments by setting them in the standard `JAVA_TOOL_OPTIONS` variable
94+
95+
```
96+
docker run -p 8080:8080 -e 'JAVA_TOOL_OPTIONS=-Xmx512m -Dmy.property=value' @docker.glassfish.embedded.repository@
97+
```
98+
99+
### Custom application deployment
100+
101+
Applications placed in the `/deploy` directory will be automatically deployed at startup:
102+
103+
```
104+
docker run -p 8080:8080 -v /path/to/apps:/deploy @docker.glassfish.embedded.repository@
105+
```
106+
107+
Paths to applications in different locations can be passed on command line, e.g.:
108+
109+
```
110+
docker run -p 8080:8080 @docker.glassfish.embedded.repository@ /mydeployments/myapp.war
111+
```
112+
113+
NOTE: If you point to a path on the command line, the path must exist inside the container. If it's not there, mount a local directory, e.g. using the `-v` option.
114+
115+
### Using with custom Dockerfile
116+
117+
You can create a custom Docker image based on GlassFish Embedded:
118+
119+
```dockerfile
120+
FROM @docker.glassfish.embedded.repository@
121+
122+
# Copy your application
123+
COPY myapp.war /deploy/
124+
125+
# Set custom JVM options
126+
ENV JAVA_TOOL_OPTIONS=-Xmx512m
127+
```
128+
129+
## Examples of advanced usage
130+
131+
### Running with specific JVM settings
132+
133+
```bash
134+
docker run -p 8080:8080 -e JAVA_TOOL_OPTIONS='-Xmx1g -XX:+UseG1GC' @docker.glassfish.embedded.repository@
135+
```
136+
137+
### Running in background with logs
138+
139+
```bash
140+
docker run -d -p 8080:8080 @docker.glassfish.embedded.repository@
141+
CONTAINER_ID=$(docker ps -q --filter ancestor=@docker.glassfish.embedded.repository@)
142+
docker logs -f $CONTAINER_ID
143+
```
144+
145+
### Running with custom user (useful for Kubernetes)
146+
147+
```bash
148+
docker run --user 1000 -p 8080:8080 @docker.glassfish.embedded.repository@
149+
```
150+
151+
## TestContainers
152+
153+
This is a simple test example using [Embedded GlassFish ](https://glassfish.org/) and [TestContainers](https://www.testcontainers.org/):
154+
155+
```java
156+
@Testcontainers
157+
public class EmbeddedGlassFishITest {
158+
159+
@Container
160+
private final GenericContainer server = new GenericContainer<>("@docker.glassfish.embedded.image@")
161+
.withExposedPorts(8080);
162+
163+
@Test
164+
void testServerStartup() throws Exception {
165+
URL url = new URL("http://localhost:" + server.getMappedPort(8080) + "/");
166+
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
167+
try {
168+
connection.setRequestMethod("GET");
169+
assertEquals(200, connection.getResponseCode());
170+
} finally {
171+
connection.disconnect();
172+
}
173+
}
174+
}
175+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/eclipse-ee4j/glassfish.docker

0 commit comments

Comments
 (0)