Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions .github/workflows/docker-embedded-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ name: Publish Embedded GlassFish Docker Image to GitHub

on:
workflow_dispatch:
inputs:
gfVersion:
description: 'The value of the glassfish.version property, used also to build the image.'
required: true
default: '7.1.0'
basicImage:
description: 'The basic docker image'
required: true
default: 'eclipse-temurin:21-jdk'

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

jobs:
build:
Expand All @@ -24,22 +32,22 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Maven Configure
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
java-version: '21'
java-version: '25'
distribution: 'temurin'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v5
with:
driver: docker-container
platforms: linux/amd64,linux/arm64

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

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

24 changes: 16 additions & 8 deletions .github/workflows/docker-server-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ name: Publish GlassFish Server Docker Image to GitHub

on:
workflow_dispatch:
inputs:
gfVersion:
description: 'The value of the glassfish.version property, used also to build the image.'
required: true
default: '7.1.0'
basicImage:
description: 'The basic docker image'
required: true
default: 'eclipse-temurin:21-jdk'

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_ID: "ghcr.io/${{ github.repository_owner }}/glassfish"
IMAGE_VERSION: 7.1.0

jobs:
build:
Expand All @@ -24,22 +32,22 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Maven Configure
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
java-version: '21'
java-version: '25'
distribution: 'temurin'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v5
with:
driver: docker-container
platforms: linux/amd64,linux/arm64

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

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

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Eclipse Glassfish Full Profile Docker Image
# Eclipse Glassfish Docker Images

## Frequently Asked Questions

Expand Down
1 change: 1 addition & 0 deletions images/server/7.1.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ RUN true \
&& asadmin set-log-attributes org.glassfish.main.jul.handler.GlassFishLogHandler.enabled=false \
&& asadmin set-log-attributes org.glassfish.main.jul.handler.SimpleLogHandler.level=FINEST \
&& asadmin enable-secure-admin \
&& sleep 1 \
&& asadmin stop-domain --kill \
&& rm -f ${PATH_GF_SERVER_LOG} ${PATH_GF_PASSWORD_FILE_FOR_CHANGE} \
&& chown -R glassfish:glassfish "${PATH_GF_HOME}" \
Expand Down
72 changes: 38 additions & 34 deletions images/server/7.1.0/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,49 @@
set -e

change_passwords () {
local PWD_FILE=/tmp/passwordfile
local COMMAND=
rm -rf $PWD_FILE

if [ "${AS_ADMIN_PASSWORD}" != "" ] && [ "${AS_ADMIN_PASSWORD}" != "admin" ]; then
echo -e "AS_ADMIN_PASSWORD=admin\nAS_ADMIN_NEWPASSWORD=${AS_ADMIN_PASSWORD}" >> $PWD_FILE
COMMAND="change-admin-password"
echo "AS_ADMIN_PASSWORD=${AS_ADMIN_PASSWORD}" > "${AS_PASSWORD_FILE}"
fi

if [ "${AS_ADMIN_MASTERPASSWORD}" != "" ] && [ "${AS_ADMIN_MASTERPASSWORD}" != "changeit" ]; then
echo -e "AS_ADMIN_MASTERPASSWORD=changeit\nAS_ADMIN_NEWMASTERPASSWORD=${AS_ADMIN_MASTERPASSWORD}" >> ${PWD_FILE}
COMMAND="${COMMAND}\nchange-master-password --savemasterpassword=true"
fi

if [ "${COMMAND}" != "" ]; then
echo -e "${COMMAND}" | asadmin --interactive=false --passwordfile=${PWD_FILE}
fi

rm -rf ${PWD_FILE}
history -c
local PATH_GF_PASSWORD_FILE_FOR_CHANGE=/tmp/passwordfile
local COMMAND=""
rm -f "${PATH_GF_PASSWORD_FILE_FOR_CHANGE}"

if [ "${AS_ADMIN_PASSWORD}" != "" ] && [ "${AS_ADMIN_PASSWORD}" != "admin" ]; then
echo -e "AS_ADMIN_PASSWORD=admin" > "${PATH_GF_PASSWORD_FILE_FOR_CHANGE}"
echo -e "AS_ADMIN_NEWPASSWORD=${AS_ADMIN_PASSWORD}" >> "${PATH_GF_PASSWORD_FILE_FOR_CHANGE}"
COMMAND="change-admin-password"
fi

if [ "${AS_ADMIN_MASTERPASSWORD}" != "" ] && [ "${AS_ADMIN_MASTERPASSWORD}" != "changeit" ]; then
echo -e "AS_ADMIN_MASTERPASSWORD=changeit" >> ${PATH_GF_PASSWORD_FILE_FOR_CHANGE}
echo -e "AS_ADMIN_NEWMASTERPASSWORD=${AS_ADMIN_MASTERPASSWORD}" >> ${PATH_GF_PASSWORD_FILE_FOR_CHANGE}
COMMAND+="\nchange-master-password --savemasterpassword=true"
fi

if [ "${COMMAND}" != "" ]; then
echo -e "${COMMAND}" | asadmin --interactive=false --passwordfile=${PATH_GF_PASSWORD_FILE_FOR_CHANGE}
echo "AS_ADMIN_PASSWORD=${AS_ADMIN_PASSWORD}" > "${AS_PASSWORD_FILE}"
fi

rm -f ${PATH_GF_PASSWORD_FILE_FOR_CHANGE}
unset AS_ADMIN_PASSWORD;
unset AS_ADMIN_MASTERPASSWORD;
history -c
}

on_exit () {
EXIT_CODE=$?
set +e;
ps -lAf;
asadmin stop-domain --force --kill;
exit $EXIT_CODE;
}

change_passwords

if [ -f custom/init.sh ]; then
/bin/bash custom/init.sh
/bin/bash custom/init.sh
fi

if [ -f custom/init.asadmin ]; then
asadmin --interactive=false multimode -f custom/init.asadmin
asadmin --interactive=false multimode -f custom/init.asadmin
fi


Expand All @@ -43,25 +55,17 @@ fi
CONTAINER_ALREADY_STARTED="CONTAINER_ALREADY_STARTED_PLACEHOLDER"
if [ ! -f "$CONTAINER_ALREADY_STARTED" ]
then
touch "$CONTAINER_ALREADY_STARTED" &&
rm -rf glassfish/domains/domain1/autodeploy/.autodeploystatus || true
touch "$CONTAINER_ALREADY_STARTED" && rm -rf glassfish/domains/domain1/autodeploy/.autodeploystatus
fi

if [ "${AS_TRACE}" == true ]; then
env|sort
env | sort
fi

if [ "$1" == 'startserv' ]; then
exec "$@"
exec "$@"
fi

on_exit () {
EXIT_CODE=$?
set +e;
ps -lAf;
asadmin stop-domain --force --kill;
exit $EXIT_CODE;
}
trap on_exit EXIT

"$@" & wait
30 changes: 15 additions & 15 deletions images/server/7.1.0/docs/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
Run GlassFish with the following command:

```
docker run -p 8080:8080 -p 4848:4848 @docker.glassfish.repository@
docker run -p 8080:8080 -p 4848:4848 glassfish
```

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

```
docker run -p 8080:8080 -p 4848:4848 @docker.glassfish.image@
docker run -p 8080:8080 -p 4848:4848 glassfish:7.1.0
```

Open the following URLs in the browser:
Expand Down Expand Up @@ -52,13 +52,13 @@ Follow these steps:
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:

```
docker run -p 8080:8080 -p 4848:4848 -v /deployments:/deploy @docker.glassfish.repository@
docker run -p 8080:8080 -p 4848:4848 -v /deployments:/deploy glassfish
```

Alternatively, you can mount a specific WAR file directly:

```
docker run -p 8080:8080 -p 4848:4848 -v /deployment/application.war:/deploy/application.war @docker.glassfish.repository@
docker run -p 8080:8080 -p 4848:4848 -v /deployment/application.war:/deploy/application.war glassfish
```

**Note**: GlassFish Server deploys applications using the WAR filename as the context path (e.g., `application.war` becomes accessible at `/application/`).
Expand All @@ -74,15 +74,15 @@ The context root (`application`) is derived from the name of the application fil
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.

```
docker run -p 9009:9009 -p 8080:8080 -p 4848:4848 @docker.glassfish.repository@ startserv --debug
docker run -p 9009:9009 -p 8080:8080 -p 4848:4848 glassfish startserv --debug
```

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

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

```
docker run -p 9009:9009 -p 8080:8080 -p 4848:4848 @docker.glassfish.repository@ startserv --suspend
docker run -p 9009:9009 -p 8080:8080 -p 4848:4848 glassfish startserv --suspend
```

## Environment variables
Expand Down Expand Up @@ -117,7 +117,7 @@ However, always consider to executing any asadmin configuration commands during

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

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.
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.

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

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

```
docker run -v ./custom:/opt/glassfish7/custom -p 8080:8080 -ti @docker.glassfish.repository@
docker run -v ./custom:/opt/glassfish7/custom -p 8080:8080 -ti glassfish
```

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

```
docker run -v ./custom:/opt/glassfish7/custom -p 8080:8080 -ti @docker.glassfish.repository@
docker run -v ./custom:/opt/glassfish7/custom -p 8080:8080 -ti glassfish
```

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

```
FROM @docker.glassfish.repository@
FROM glassfish

RUN printf "start-domain \n \
set configs.config.server-config.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size=1000 \n \
Expand All @@ -188,7 +188,7 @@ stop-domain
File `Dockerfile`:

```
FROM @docker.glassfish.repository@
FROM glassfish

COPY commands.asadmin commands.asadmin

Expand All @@ -202,7 +202,7 @@ Let's try something more complicated.
* 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:

```bash
docker run @docker.glassfish.repository@ startserv --debug mydomain
docker run glassfish startserv --debug mydomain
```

* Environment variable `AS_TRACE=true` enables tracing of the GlassFish startup. It is useful when the server doesn't start without any useful logs.
Expand All @@ -212,13 +212,13 @@ docker run @docker.glassfish.repository@ startserv --debug mydomain
* `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.

```bash
docker run -d @docker.glassfish.repository@
docker run -d glassfish
```

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 ):

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

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

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

@Test
void getRoot() throws Exception {
Expand Down
Loading