Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preferred way to use environment variable for configuring domain.xml #24

Open
rlfnb opened this issue Jan 28, 2025 · 3 comments
Open

preferred way to use environment variable for configuring domain.xml #24

rlfnb opened this issue Jan 28, 2025 · 3 comments

Comments

@rlfnb
Copy link

rlfnb commented Jan 28, 2025

Im pretty happy to have a place where official glassfish docker images being published. However I was surprised to find no idea how to add environment properties for replacing domain.xml values. So basically, I cannot use the image without heavy lifting to make it work as a container with any kind of database for example. Maybe you can give me hint how to solve it in an intended way?

@OndroMih
Copy link
Contributor

Hi, at the current state, GlassFish Docker just runs the GlassFish server, with minimal customization. Since GlassFish doesn’t support configuration using environment variables, what you describe is not possible.

The next version of the Docker image will improve this a bit, it will be possible to configure the server with asadmin commands in a file: #22

This still doesn’t allow configuration using environment variables, but you can mount a directory with an asadmin script that configures a database connection pool or anything else.

@rlfnb
Copy link
Author

rlfnb commented Jan 29, 2025

Thank you for your your quick reply. maybe the preboot / postboot file introduced in payara maybe a good start for backporting into this image? This mechanism would allow already the customization of the glassfish domain?
Final step is to resolve ${ENV=...} properties?

@OndroMih
Copy link
Contributor

OndroMih commented Jan 29, 2025

We don't want backport features from Payara to GlassFish if we can find a better solution. But we at OmniFish are working on something similar, which would allow using references to environment variables in domain.xml, and even amend configuration using environment variables without variable references in domain.xml, and thus without any change in the Docker image. Basically exposing all config options as environment variables. We don't know when it will be ready. If you use GlassFish on a commercial project, we can offer you our services and deliver these improvements ASAP for you, and much more. You can contact us at https://omnifish.ee/contact-us/.

Meanwhile, we released the Docker image for 7.0.21, which allows running asadmin commands or a bash script from file before GlassFish is started. Here's the documentation: Execute asadmin commands before server startup. There's still a catch, GlassFish needs to be started, then commands executed, the GlassFish needs to be stopped, and then it will be started again as the main Docker process. There's a way to avoid it to speed up the container start, but it's not straightforward - from a bash script, start another bash script in background, which would wait until GlassFish is started and then would run the commands against the running server. This would not need a restart of GlassFish, as GlassFish would already be the main process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants