Skip to content

Commit 663b1c4

Browse files
authored
Merge pull request #32 from eclipse-ee4j/more-work-to-do
More work to do
2 parents 5b88d17 + 6152212 commit 663b1c4

18 files changed

Lines changed: 329 additions & 268 deletions

File tree

.github/workflows/docker-embedded-publish.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,21 @@ name: Publish Embedded GlassFish Docker Image to GitHub
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
gfVersion:
7+
description: 'The value of the glassfish.version property, used also to build the image.'
8+
required: true
9+
default: '7.1.0'
10+
basicImage:
11+
description: 'The basic docker image'
12+
required: true
13+
default: 'eclipse-temurin:21-jdk'
514

615
env:
716
# Use docker.io for Docker Hub if empty
817
REGISTRY: ghcr.io
918
# github.repository as <account>/<repo>
1019
IMAGE_ID: "ghcr.io/${{ github.repository_owner }}/embedded-glassfish"
11-
IMAGE_VERSION: 7.1.0
1220

1321
jobs:
1422
build:
@@ -24,22 +32,22 @@ jobs:
2432

2533
steps:
2634
- name: Checkout Repository
27-
uses: actions/checkout@v4
35+
uses: actions/checkout@v6
2836

2937
- name: Maven Configure
30-
uses: actions/setup-java@v4
38+
uses: actions/setup-java@v5
3139
with:
32-
java-version: '21'
40+
java-version: '25'
3341
distribution: 'temurin'
3442

3543
- name: Set up Docker Buildx
36-
uses: docker/setup-buildx-action@v3
44+
uses: docker/setup-buildx-action@v5
3745
with:
3846
driver: docker-container
3947
platforms: linux/amd64,linux/arm64
4048

4149
- name: Build
42-
run: mvn clean prepare-package -Dglassfish.version=$IMAGE_VERSION
50+
run: mvn clean prepare-package -Dglassfish.version=${{ github.event.inputs.gfVersion }} -Dgf.docker.baseImage=${{ github.event.inputs.basicImage }}
4351

4452
- name: Log in to registry
4553
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
@@ -54,8 +62,8 @@ jobs:
5462
- name: Build and Deploy
5563
uses: docker/build-push-action@v6
5664
with:
57-
context: images/embedded/${{ env.IMAGE_VERSION }}
65+
context: images/embedded/${{ github.event.inputs.gfVersion }}
5866
platforms: linux/amd64,linux/arm64
5967
push: true
60-
tags: ${{ env.IMAGE_ID }}:${{ env.IMAGE_VERSION }},${{ env.IMAGE_ID }}:latest
68+
tags: ${{ env.IMAGE_ID }}:${{ github.event.inputs.gfVersion }},${{ env.IMAGE_ID }}:latest
6169

.github/workflows/docker-server-publish.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,21 @@ name: Publish GlassFish Server Docker Image to GitHub
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
gfVersion:
7+
description: 'The value of the glassfish.version property, used also to build the image.'
8+
required: true
9+
default: '7.1.0'
10+
basicImage:
11+
description: 'The basic docker image'
12+
required: true
13+
default: 'eclipse-temurin:21-jdk'
514

615
env:
716
# Use docker.io for Docker Hub if empty
817
REGISTRY: ghcr.io
918
# github.repository as <account>/<repo>
1019
IMAGE_ID: "ghcr.io/${{ github.repository_owner }}/glassfish"
11-
IMAGE_VERSION: 7.1.0
1220

1321
jobs:
1422
build:
@@ -24,22 +32,22 @@ jobs:
2432

2533
steps:
2634
- name: Checkout Repository
27-
uses: actions/checkout@v4
35+
uses: actions/checkout@v6
2836

2937
- name: Maven Configure
30-
uses: actions/setup-java@v4
38+
uses: actions/setup-java@v5
3139
with:
32-
java-version: '21'
40+
java-version: '25'
3341
distribution: 'temurin'
3442

3543
- name: Set up Docker Buildx
36-
uses: docker/setup-buildx-action@v3
44+
uses: docker/setup-buildx-action@v5
3745
with:
3846
driver: docker-container
3947
platforms: linux/amd64,linux/arm64
4048

4149
- name: Build
42-
run: mvn clean prepare-package -Dglassfish.version=$IMAGE_VERSION
50+
run: mvn clean prepare-package -Dglassfish.version=${{ github.event.inputs.gfVersion }} -Dgf.docker.baseImage=${{ github.event.inputs.basicImage }}
4351

4452
- name: Log in to registry
4553
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
@@ -54,8 +62,8 @@ jobs:
5462
- name: Build and Deploy
5563
uses: docker/build-push-action@v6
5664
with:
57-
context: images/server/${{ env.IMAGE_VERSION }}
65+
context: images/server/${{ github.event.inputs.gfVersion }}
5866
platforms: linux/amd64,linux/arm64
5967
push: true
60-
tags: ${{ env.IMAGE_ID }}:${{ env.IMAGE_VERSION }},${{ env.IMAGE_ID }}:latest
68+
tags: ${{ env.IMAGE_ID }}:${{ github.event.inputs.gfVersion }},${{ env.IMAGE_ID }}:latest
6169

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Eclipse Glassfish Full Profile Docker Image
1+
# Eclipse Glassfish Docker Images
22

33
## Frequently Asked Questions
44

images/server/7.1.0/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ RUN true \
7171
&& asadmin set-log-attributes org.glassfish.main.jul.handler.GlassFishLogHandler.enabled=false \
7272
&& asadmin set-log-attributes org.glassfish.main.jul.handler.SimpleLogHandler.level=FINEST \
7373
&& asadmin enable-secure-admin \
74+
&& sleep 1 \
7475
&& asadmin stop-domain --kill \
7576
&& rm -f ${PATH_GF_SERVER_LOG} ${PATH_GF_PASSWORD_FILE_FOR_CHANGE} \
7677
&& chown -R glassfish:glassfish "${PATH_GF_HOME}" \

images/server/7.1.0/docker-entrypoint.sh

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,49 @@
22
set -e
33

44
change_passwords () {
5-
local PWD_FILE=/tmp/passwordfile
6-
local COMMAND=
7-
rm -rf $PWD_FILE
8-
9-
if [ "${AS_ADMIN_PASSWORD}" != "" ] && [ "${AS_ADMIN_PASSWORD}" != "admin" ]; then
10-
echo -e "AS_ADMIN_PASSWORD=admin\nAS_ADMIN_NEWPASSWORD=${AS_ADMIN_PASSWORD}" >> $PWD_FILE
11-
COMMAND="change-admin-password"
12-
echo "AS_ADMIN_PASSWORD=${AS_ADMIN_PASSWORD}" > "${AS_PASSWORD_FILE}"
13-
fi
14-
15-
if [ "${AS_ADMIN_MASTERPASSWORD}" != "" ] && [ "${AS_ADMIN_MASTERPASSWORD}" != "changeit" ]; then
16-
echo -e "AS_ADMIN_MASTERPASSWORD=changeit\nAS_ADMIN_NEWMASTERPASSWORD=${AS_ADMIN_MASTERPASSWORD}" >> ${PWD_FILE}
17-
COMMAND="${COMMAND}\nchange-master-password --savemasterpassword=true"
18-
fi
19-
20-
if [ "${COMMAND}" != "" ]; then
21-
echo -e "${COMMAND}" | asadmin --interactive=false --passwordfile=${PWD_FILE}
22-
fi
23-
24-
rm -rf ${PWD_FILE}
25-
history -c
5+
local PATH_GF_PASSWORD_FILE_FOR_CHANGE=/tmp/passwordfile
6+
local COMMAND=""
7+
rm -f "${PATH_GF_PASSWORD_FILE_FOR_CHANGE}"
8+
9+
if [ "${AS_ADMIN_PASSWORD}" != "" ] && [ "${AS_ADMIN_PASSWORD}" != "admin" ]; then
10+
echo -e "AS_ADMIN_PASSWORD=admin" > "${PATH_GF_PASSWORD_FILE_FOR_CHANGE}"
11+
echo -e "AS_ADMIN_NEWPASSWORD=${AS_ADMIN_PASSWORD}" >> "${PATH_GF_PASSWORD_FILE_FOR_CHANGE}"
12+
COMMAND="change-admin-password"
13+
fi
14+
15+
if [ "${AS_ADMIN_MASTERPASSWORD}" != "" ] && [ "${AS_ADMIN_MASTERPASSWORD}" != "changeit" ]; then
16+
echo -e "AS_ADMIN_MASTERPASSWORD=changeit" >> ${PATH_GF_PASSWORD_FILE_FOR_CHANGE}
17+
echo -e "AS_ADMIN_NEWMASTERPASSWORD=${AS_ADMIN_MASTERPASSWORD}" >> ${PATH_GF_PASSWORD_FILE_FOR_CHANGE}
18+
COMMAND+="\nchange-master-password --savemasterpassword=true"
19+
fi
20+
21+
if [ "${COMMAND}" != "" ]; then
22+
echo -e "${COMMAND}" | asadmin --interactive=false --passwordfile=${PATH_GF_PASSWORD_FILE_FOR_CHANGE}
23+
echo "AS_ADMIN_PASSWORD=${AS_ADMIN_PASSWORD}" > "${AS_PASSWORD_FILE}"
24+
fi
25+
26+
rm -f ${PATH_GF_PASSWORD_FILE_FOR_CHANGE}
27+
unset AS_ADMIN_PASSWORD;
28+
unset AS_ADMIN_MASTERPASSWORD;
29+
history -c
30+
}
31+
32+
on_exit () {
33+
EXIT_CODE=$?
34+
set +e;
35+
ps -lAf;
36+
asadmin stop-domain --force --kill;
37+
exit $EXIT_CODE;
2638
}
2739

2840
change_passwords
2941

3042
if [ -f custom/init.sh ]; then
31-
/bin/bash custom/init.sh
43+
/bin/bash custom/init.sh
3244
fi
3345

3446
if [ -f custom/init.asadmin ]; then
35-
asadmin --interactive=false multimode -f custom/init.asadmin
47+
asadmin --interactive=false multimode -f custom/init.asadmin
3648
fi
3749

3850

@@ -43,25 +55,17 @@ fi
4355
CONTAINER_ALREADY_STARTED="CONTAINER_ALREADY_STARTED_PLACEHOLDER"
4456
if [ ! -f "$CONTAINER_ALREADY_STARTED" ]
4557
then
46-
touch "$CONTAINER_ALREADY_STARTED" &&
47-
rm -rf glassfish/domains/domain1/autodeploy/.autodeploystatus || true
58+
touch "$CONTAINER_ALREADY_STARTED" && rm -rf glassfish/domains/domain1/autodeploy/.autodeploystatus
4859
fi
4960

5061
if [ "${AS_TRACE}" == true ]; then
51-
env|sort
62+
env | sort
5263
fi
5364

5465
if [ "$1" == 'startserv' ]; then
55-
exec "$@"
66+
exec "$@"
5667
fi
5768

58-
on_exit () {
59-
EXIT_CODE=$?
60-
set +e;
61-
ps -lAf;
62-
asadmin stop-domain --force --kill;
63-
exit $EXIT_CODE;
64-
}
6569
trap on_exit EXIT
6670

6771
"$@" & wait

images/server/7.1.0/docs/content.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
Run GlassFish with the following command:
1414

1515
```
16-
docker run -p 8080:8080 -p 4848:4848 @docker.glassfish.repository@
16+
docker run -p 8080:8080 -p 4848:4848 glassfish
1717
```
1818

1919
Or with a command for a specific tag (GlassFish version):
2020

2121
```
22-
docker run -p 8080:8080 -p 4848:4848 @docker.glassfish.image@
22+
docker run -p 8080:8080 -p 4848:4848 glassfish:7.1.0
2323
```
2424

2525
Open the following URLs in the browser:
@@ -52,13 +52,13 @@ Follow these steps:
5252
3. Run the following command to start GlassFish in Docker with your application, where `/deployments` is path to the directory created in step 1, and /deploy is the directory in the container where GlassFish expects applications:
5353

5454
```
55-
docker run -p 8080:8080 -p 4848:4848 -v /deployments:/deploy @docker.glassfish.repository@
55+
docker run -p 8080:8080 -p 4848:4848 -v /deployments:/deploy glassfish
5656
```
5757

5858
Alternatively, you can mount a specific WAR file directly:
5959

6060
```
61-
docker run -p 8080:8080 -p 4848:4848 -v /deployment/application.war:/deploy/application.war @docker.glassfish.repository@
61+
docker run -p 8080:8080 -p 4848:4848 -v /deployment/application.war:/deploy/application.war glassfish
6262
```
6363

6464
**Note**: GlassFish Server deploys applications using the WAR filename as the context path (e.g., `application.war` becomes accessible at `/application/`).
@@ -74,15 +74,15 @@ The context root (`application`) is derived from the name of the application fil
7474
You can modify the start command of the Docker container to `startserv --debug` to enable debug mode. You should also map the debug port 9009.
7575

7676
```
77-
docker run -p 9009:9009 -p 8080:8080 -p 4848:4848 @docker.glassfish.repository@ startserv --debug
77+
docker run -p 9009:9009 -p 8080:8080 -p 4848:4848 glassfish startserv --debug
7878
```
7979

8080
Then connect your debugger to the port 9009 on `localhost`.
8181

8282
If you need suspend GlassFish startup until you connect the debugger, use the `--suspend` argument instead:
8383

8484
```
85-
docker run -p 9009:9009 -p 8080:8080 -p 4848:4848 @docker.glassfish.repository@ startserv --suspend
85+
docker run -p 9009:9009 -p 8080:8080 -p 4848:4848 glassfish startserv --suspend
8686
```
8787

8888
## Environment variables
@@ -117,7 +117,7 @@ However, always consider to executing any asadmin configuration commands during
117117

118118
Just create a file `${PATH_GF_HOME}/custom/init.asadmin` (`/opt/glassfish7/custom/init.asadmin`), the commands will be executed before GlassFish server starts.
119119

120-
Within the `init.asadmin` file, you can specify any asadmin command. Most of the commands require that the server is running, so you'll need to start the server first, run the configuration commands, and then stop the server.
120+
Within the `init.asadmin` file, you can specify any asadmin command. Most of the commands require that the server is running, so you'll need to start the server first, run the configuration commands, and then stop the server.
121121

122122
For example, to start GlassFish, increase the maximum amount of threads, and then stop it, the `init.asadmin` file can contain:
123123

@@ -130,7 +130,7 @@ stop-domain
130130
You can provide the file by mounting its directory to the `/opt/glassfish7/custom` directory in the container when running the container:
131131

132132
```
133-
docker run -v ./custom:/opt/glassfish7/custom -p 8080:8080 -ti @docker.glassfish.repository@
133+
docker run -v ./custom:/opt/glassfish7/custom -p 8080:8080 -ti glassfish
134134
```
135135

136136
### Execute a `bash` script before server startup
@@ -156,7 +156,7 @@ stop-domain" | asadmin --interactive=false
156156
You can provide the script by mounting its directory to the `/opt/glassfish7/custom` directory in the container when running the container:
157157

158158
```
159-
docker run -v ./custom:/opt/glassfish7/custom -p 8080:8080 -ti @docker.glassfish.repository@
159+
docker run -v ./custom:/opt/glassfish7/custom -p 8080:8080 -ti glassfish
160160
```
161161

162162
### Execute `asadmin` commands during Docker image build
@@ -168,7 +168,7 @@ To do it, simply add `RUN instructions that run `asadmin` script with the usual
168168
File `Dockerfile`:
169169

170170
```
171-
FROM @docker.glassfish.repository@
171+
FROM glassfish
172172
173173
RUN printf "start-domain \n \
174174
set configs.config.server-config.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size=1000 \n \
@@ -188,7 +188,7 @@ stop-domain
188188
File `Dockerfile`:
189189

190190
```
191-
FROM @docker.glassfish.repository@
191+
FROM glassfish
192192
193193
COPY commands.asadmin commands.asadmin
194194
@@ -202,7 +202,7 @@ Let's try something more complicated.
202202
* To modify startup arguments for GlassFish, just add `startserv` to the command line and then add any arguments supported by the `asadmin start-domain` command. The `startserv` script is an alias to the `asadmin start-domain` command but starts GlassFish in a more efficient way that is more suitable in Docker container. For example, to start in debug mode with a custom domain, run:
203203

204204
```bash
205-
docker run @docker.glassfish.repository@ startserv --debug mydomain
205+
docker run glassfish startserv --debug mydomain
206206
```
207207

208208
* Environment variable `AS_TRACE=true` enables tracing of the GlassFish startup. It is useful when the server doesn't start without any useful logs.
@@ -212,13 +212,13 @@ docker run @docker.glassfish.repository@ startserv --debug mydomain
212212
* `docker run` with `-d` starts the container as a daemon, so the shell doesn't print logs and finishes. Docker then returns the container id which you can use for further commands.
213213

214214
```bash
215-
docker run -d @docker.glassfish.repository@
215+
docker run -d glassfish
216216
```
217217

218218
Example of running a Docker container in background, view the logs, and then stop it (with debug enabled, trace logging, and user `1000` convenient for Kubernetes ):
219219

220220
```bash
221-
docker run -d -e AS_TRACE=true --user 1000 @docker.glassfish.repository@ startserv --debug=true
221+
docker run -d -e AS_TRACE=true --user 1000 glassfish startserv --debug=true
222222
5a11f2fe1a9dd1569974de913a181847aa22165b5015ab20b271b08a27426e72
223223

224224
docker logs 5a11f2fe1a9dd1569974de913a181847aa22165b5015ab20b271b08a27426e72
@@ -242,7 +242,7 @@ If you want to run more complicated tests, the good path is to
242242
public class WelcomePageITest {
243243

244244
@Container
245-
private final GenericContainer server = new GenericContainer<>("@docker.glassfish.image@").withExposedPorts(8080);
245+
private final GenericContainer server = new GenericContainer<>("glassfish:7.1.0").withExposedPorts(8080);
246246

247247
@Test
248248
void getRoot() throws Exception {

0 commit comments

Comments
 (0)