Skip to content

Commit

Permalink
Merge pull request #6 from OmniFish-EE/ondromih-startserv
Browse files Browse the repository at this point in the history
Use the startserv script as CMD by default
  • Loading branch information
OndroMih authored Aug 21, 2023
2 parents e0cdd75 + b185a92 commit a0ed280
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 9 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<includes>
<include>Dockerfile</include>
<include>dockerlibfile-fragment.txt</include>
<include>README.md</include>
</includes>
<filtering>true</filtering>
</resource>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ RUN true \
USER glassfish
WORKDIR ${PATH_GF_HOME}
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["asadmin", "start-domain", "--verbose"]
CMD ["startserv"]
60 changes: 60 additions & 0 deletions src/main/resources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Eclipse GlassFish Docker images (by OmniFish)

**Source code repository:** https://github.com/OmniFish-EE/docker-library-glassfish

## Quick start

### Start GlassFish

Run GlassFish with the following command:

```
docker run -p 8080:8080 -p 4848:4848 omnifish/glassfish
```

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

```
docker run -p 8080:8080 -p 4848:4848 omnifish/glassfish:@glassfish.version@
```

Open the following URLs in the browser:

* **Welcome screen:** http://localhost:8080
* **Administration Console:** https://localhost:4848 - log in using `admin`/`admin` (User name/Password)

### Stop GlassFish

Stop GlassFish with the following command:

```
docker stop CONTAINER_ID
```

CONTAINER_ID can be found from the output of the following command:

```
docker ps
```

## Run an application with GlassFish in Docker

You can run an application located in your filesystem with GlassFIsh in a Docker container.

Follow these steps:

1. Create an empty directory on your filesystem, e.g. `/deployment`
2. Copy the application package to this directory - so that it's for example on the path `/deployment/application.war`
3. Run the following command to start GlassFish in Docker with your application, where `/deployments` is path to the directory created in step 1:

```
docker run -p 8080:8080 -p 4848:4848 -v /deployments:/opt/glassfish7/glassfish/domains/domain1/autodeploy omnifish/glassfish:latest
```

Then you can open the application in the browser with:

* http://localhost:9080/application

The context root (`application`) is derived from the name of the application file (e.g. `application.war` would deployed under the `application` context root). If your application file has a different name, please adjust the contest root in the URL accordingly.

---
20 changes: 12 additions & 8 deletions src/main/resources/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
#!/bin/bash
set -e;

if [ "$1" != 'asadmin' ]; then
if [ "$1" != 'asadmin' -a "$1" != 'startserv' ]; then
exec "$@"
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
fi

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

on_exit () {
EXIT_CODE=$?
set +e;
Expand All @@ -14,11 +25,4 @@ on_exit () {
}
trap on_exit EXIT

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
fi

env|sort && "$@" & wait

0 comments on commit a0ed280

Please sign in to comment.