Is there a way to get the docker-commandbox image ...
# docker-commandbox
c
Is there a way to get the docker-commandbox image to look for a custom server.json not located in the webroot when starting up? I tried
BOX_SERVER_SERVERCONFIGFILE
as an ENV but it seems to be ignored. I prefer to keep all my app files and config above the webroot.
p
Do you have CFCONFIG being installed on that commandbox instance? Otherwise I believe it would be ignored
c
There is a cfconfig file which is defined in the server.json, but the problem is getting the server to use the server.json on startup. With a non-docker instance I can get it to work fine.
p
What profile name does your server.json file contain; by default it looks for Production
Otherwise you need to define it in your docker setup via
BOX_SERVER_PROFILE
if it isnt Production
c
My server.json doesn't specify a profile. But as I say the problem is getting Commandbox to use my server.json which is above the webroot. Not sure the profile has anything to do with that, (or does it?)
p
You are asking this in the DOCKER-commandbox channel; so is this related to how the DOCKER IMAGE of commandbox is not utilizing your environment file?
c
Yes I'm talking about the docker-commandbox image. But my issue is getting it to use a
server.json
which is above the webroot, i.e.
APP_DIR
p
Is the
BOX_SERVER_SERVERCONFIGFILE
in your Docker file or within your Server.json file?
c
In the Docker file. But that ENV is not actually documented, I just thought it might work from looking at the
build/run.sh
script.
p
@jclausen can probably answer you better on that then
j
Did you pull the most recent version of the image?
Because that was actually fixed in the latest version: https://github.com/Ortus-Solutions/docker-commandbox/issues/71
I tested the ability set that environment variable.
All
BOX_
environment variables would pass through to CommandBox
b
@cfsimplicity
c
@jclausen Thanks (and sorry for the delayed reply, I'm in the UK). I'm not using a tagged version of the image so I assume it's the latest. I'm also continually re-building my image. This my dockerfile:
Copy code
FROM ortussolutions/commandbox

ENV BOX_SERVER_SERVERCONFIGFILE myCustomServer.json
But when I run it the logs show:
Copy code
Looking for server JSON file by convention: /app//server.json
webroot defaulted to location of server's JSON file: /app/
start server in - /app/
server name - app
server config file - /app//server.json
j
OK. I just did a few tests, and it looks like there is still an issue with that custom
serverConfigFile
environment variable not getting picked up. I can see it pulling environment variables from that custom file in one phase of the startup but then it falls back, somehow. I’ll push up a patch for the image today to resolve that.
Update: This does not appear to be an issue with the container itself, but something with CommandBox. When I start a server in debug mode and that environment variable set and pointing to a different file, it appears to use a default file name.
Copy code
√ | Starting Server
   |------------------------------
   | start server in - /Users/jonclausen/tmp/server-json-test/
   | server name - server-json-test
   | server config file - /Users/jonclausen/tmp/server-json-test//server.json
When I stop the server or forget it, the environment variable appears to get picked up and I see this output:
Copy code
√ | Overriding server.json values from env vars
   |----------------------------------------------------------
   | Overridding [SERVERCONFIGFILE] with box environment variable [BOX_SERVER_SERVERCONFIGFILE]
   |----------------------------------------------------------
I am going to submit a ticket for @bdw429s to look at on this. I know this environment variable was working previously, so this may be a regression introduced later on in the beta phase of 5.8
I have created COMMANDBOX-1575 to track this issue.
👍 1
c
Thanks Jon. Brad, if you are still on holiday.... get to back to it right now! This isn't urgent simple smile
@jclausen As a temporary workaround I changed the name of my file to
server.json
and it does then get read by commandbox.
Copy code
Looking for server JSON file by convention: /app//server.json
webroot pulled from server's JSON: /app/web/
start server in - /app/web/
server config file - /app//server.json
As you can see, and for the reasons I mentioned before, I'm setting the webroot to be one level below in
/app/web/
However, I'm getting the following error which prevents the server starting:
Copy code
[INFO] 2023-03-17T16:05:02Z - Starting server using generated script: /usr/local/bin/startup.sh
mv: cannot stat '/app/server-start.sh': No such file or directory
I've seen elsewhere that this error can be caused by using a pre-warmed image where the server.json has been already baked in, but that's clearly not the case here. My dockerfile is pulling the non-tagged base image and as you can see my server.json is being correctly read.
j
@cfsimplicity if you are not on CommandBox 5.8, that will not work when the app is in single server mode. https://ortussolutions.atlassian.net/browse/COMMANDBOX-1544
c
I'm using the latest image which I assume is 5.8? Also I can start the server just fine outside of docker.
j
Let me do a test on this.
c
Thanks Jon.
j
OK. I can replicate the issue. I’m testing out a fix and then I will push up a patch release in the next couple of hours.
👍 1
@cfsimplicity Apologies. I got sidetracked for a bit, but the new image version is published and available, which should solve the error.
1
c
Thanks, Jon, that seems to work well.
n
@jclausen is this ticket resolved with the new image version you published ? https://ortussolutions.atlassian.net/browse/COMMANDBOX-1575 Thank you
j
@Nick Kurucz No. Unfortunately there’s currently no way to adjust that from the environment. Currently you still have to change the server file name to match the convention - or adjust the CommandBox config convention for the server file name globally during your build process.