<@U06V253M4> When using CommandBox in a docker con...
# box-products
p
@bdw429s When using CommandBox in a docker container. Is there anyway to pass in which server.json file to use? I have several in my root directory server.json, server-lucee5.json, server-cf2016.json, server-cf2018.json, you get the picture. I'd like to be able to define which one of these to use so I could launch three different containers each running a different engine. I've figured out how to do this with CFConfig by defining the BOX_SERVER_CFCONFIGFILE environment variable in my docker-compose.yml file. Was hoping there was a simple way to set the server name or the server.json file via the environment variables as well.
b
@Peter Amiri This is a general Docker question or specific to the
ortussolutions/commandbox
docker iamge
p
well, let me rephrase it. Is there a way to set the server.json file to use via an environment variable?
b
My original question still stands
As my answer really depends on it
s
i think brad meant to say โ€œis thisโ€ instead of โ€œthis isโ€
p
Thanks Scott, I'm reading the docker readme to see if I can figure it out and perhaps contribute to that repo if that environment facility isn't there. But yes, this was a specific
ortussolutions/commandbox
questions.
b
Yes, I meant to say "is this"
Sorry for the typo
p
so this is in regards to the
ortussolutions/commandbox
docker image
b
@Peter Amiri So in CommandBox in general, this is very easy to do
Copy code
server start serverConfigFile=myfile.json

# this will look for `server-foo.json` by default
server start name="foo"
however the Ortus docker image completely controls the start command and does not currenlty provide you with any mechanism to supply either a
serverConfigFile
or a
name
argument which sort of limits your options. CommandBox itself has no env vars to control this either. Perhaps this is an addition we could make to the Ortus image @jclausen?
If you're wanting to get very clever, you can probably make it work with this trick... (untested ๐Ÿ˜‰ )
In your entry point set the following config setting
Copy code
config set "command.defaults.server start.serverConfigFile"=server-foo.json
That will default the CLI
serverConfigFile
param for any
server start
commands that are run which effectively lets you "slip" it in when the docker image starts the server/
Just swap the config setting out for whatever JSON file you're wanting to use.
j
Actually the server config file is not one of the variables we pass in to the start command: https://github.com/Ortus-Solutions/docker-commandbox/blob/master/build/util/start-server.sh#L20 You should be able supply that variable via the environment
BOX_SERVER_serverConfigFile=my-server.json
โ˜๏ธ is that the correct variable @bdw429s ?
b
No, chicken/egg.
The
box_server_xxx
vars default values INSIDE the server.json
So you can't use it to specify the server.json!
I already looked in that shell script and thought through the env vars ๐Ÿ™‚
j
Ah. OK. I thought that might get picked up within the server command
b
So outside of the docker images modifying the server-start.sh script, the command defaults would be the only way I know of to sneak in an override
j
Then the best bet is going to be to rename the
server-xxx.json
file by overriding the
CMD
of the image.
b
That would also work ๐Ÿ™‚
But it's not clearly as clever ๐Ÿคฃ
But really at the end of the day, he'll have to run SOMETHING in a custom entry point -- whether it's modifying the command default or renaming the file. There's not really any avoiding that
p
LOL, I thought of the rename or copying of the server-xxx.json to server.json. I guess I'm not that cleaver. Now to figure out where this should be done. My docker-compose.yml calls out a Adobe2016.Dockerfile. I'd imagine I need to get that copy to work in the dockerfile.
okay, that worked. I was able to copy my server-xxx.json file into server.json before the docker image started. Thanks guys, now onto the next bit to get the MySQL 8.0 drivers to load into the Adobe 2016 image. I was thinking of using
libDirs
in the server.json file for that so that is why I had to figure out how to load a custom server.json.
๐Ÿ‘๐Ÿพ 1
j
The MySQL drivers are in all of the Ortus images.
๐Ÿ‘๐Ÿพ 1
p
@jclausen only the 5.6 driver is installed in the adobe@2016.0.15+318650 engine. So I'm trying to get the mysql-connector-java-8.0.29.jar to load up into that server.
well, I just moved up to 2016.0.16+320445 and it has the 8.0 driver so all is good.
๐Ÿ‘ 1