seandaniels
01/16/2023, 7:31 PMserver.json
file when starting the server? Looking at the repo, it seems to me like server.json
is hard-coded in run.sh
(line 90). My repo has two separate server.json files to support launching in two different modes (front end vs. admin). I have two separate DockerFiles to create containers in the different modes. I've tried various things in the DockerFiles but none of them seem to work:
COPY server-frontend.json /app/server.json
RUN box config set server.singleServerMode=false
RUN box server set serverConfigFile=server-frontend.json
ENV BOX_SERVER_SERVERCONFIGFILE="server-frontend.json"
Patrick
01/17/2023, 3:13 AMseandaniels
01/17/2023, 3:33 PMserver-[mode].json
file.Patrick
01/17/2023, 3:37 PMseandaniels
01/17/2023, 3:39 PMseandaniels
01/17/2023, 3:39 PMPatrick
01/17/2023, 3:42 PMPatrick
01/17/2023, 3:43 PMserver set serverconfigFile=blah.json
should do the trink unless you also have to configure the start blah.json
command hmmPatrick
01/17/2023, 3:44 PMseandaniels
01/17/2023, 3:44 PM<https://github.com/Ortus-Solutions/docker-commandbox/tree/development/build|build>/<https://github.com/Ortus-Solutions/docker-commandbox/tree/development/build/util|util>/start-server.sh
which adds the argument to box server start
to specify the correct file?seandaniels
01/17/2023, 3:45 PMserver set serverconfigFile=blah.json
doesn't seem to do anything. box server start
just uses defaults and doesn't pick up anything from blah.json
seandaniels
01/17/2023, 3:47 PMserver set serverconfigFile=blah.json
then run box server start and... doesn't use it. I have to say box server start blah.json
explicitly.Patrick
01/17/2023, 3:50 PMseandaniels
01/17/2023, 3:51 PMseandaniels
01/17/2023, 3:53 PMCOPY ./server-frontend.json ${APP_DIR}/server.json
But no dice. Maybe I have my path syntax wrong? If I ls
in the container terminal, server.json is not there... so I'm not doing something rightjclausen
01/17/2023, 3:57 PMCOPY
is from the host machine to the image. The order in which you copy matters, because a subsequent copy of a directory can overwrite the previous one.jclausen
01/17/2023, 3:58 PMRUN mv ./server-frontend.json ./server.json
jclausen
01/17/2023, 3:59 PMjclausen
01/17/2023, 4:00 PMserver.json
file at all.seandaniels
01/17/2023, 4:02 PMjclausen
01/17/2023, 4:02 PMseandaniels
01/17/2023, 4:03 PMENV BOX_SERVER_SERVERCONFIGFILE=server-frontend.json
in the Dockerfile that would be perfectjclausen
01/17/2023, 4:04 PMseandaniels
01/17/2023, 4:04 PMjclausen
01/17/2023, 4:08 PMCMD
of the container to handle an environment variable:
CMD mv $APP_DIR/server-${APPLICATION_MODE:-backend}.json $APP_DIR/server.json && $BUILD_DIR/run.sh
jclausen
01/17/2023, 4:09 PMprofile
is set to production
any server-*.json
files would not be browsable.seandaniels
01/17/2023, 4:10 PMENV APPLICATION_MODE=frontend
earlier in the Dockerfile?jclausen
01/17/2023, 4:10 PMjclausen
01/17/2023, 4:10 PMseandaniels
01/17/2023, 4:10 PMjclausen
01/17/2023, 4:10 PMseandaniels
01/17/2023, 4:12 PMjclausen
01/17/2023, 4:12 PMblockSensitivePaths
doesn’t handle custom server-*.json
names: https://commandbox.ortusbooks.com/embedded-server/configuring-your-server/server-rules/baked-in-rules#block-sensitive-pathsPatrick
01/17/2023, 4:14 PMseandaniels
01/17/2023, 4:14 PMRUN ${BUILD_DIR}/util/warmup-server.sh
jclausen
01/17/2023, 4:14 PMCMD
is the command that is run when the container starts.jclausen
01/17/2023, 4:15 PMRUN
commands in your Dockerfile.jclausen
01/17/2023, 4:15 PMjclausen
01/17/2023, 4:15 PMRUN
commands are executions you would perform in the Dockerfile as you craft the image.seandaniels
01/17/2023, 4:16 PMjclausen
01/17/2023, 4:16 PMseandaniels
01/17/2023, 4:17 PMjclausen
01/17/2023, 4:17 PMseandaniels
01/17/2023, 4:17 PMjclausen
01/17/2023, 4:17 PMseandaniels
01/17/2023, 4:41 PMdocker-compose.yml
file and mounting my app directory into both containers. So when they both launch simultaneously, stuff in the app root gets rewritten / moved / etc causing some race condition issues. If I launch each container separately everything works correctly. I just end up with an extra server.json
in my root based on whichever the last launch was. And I had to change mv
to cp
seandaniels
01/17/2023, 4:42 PMjclausen
01/17/2023, 5:03 PMjclausen
01/17/2023, 5:03 PMbdw429s
03/19/2023, 1:34 AMRUN box server set serverConfigFile=server-frontend.json
ENV BOX_SERVER_SERVERCONFIGFILE="server-frontend.json"
☝️ Neither of those do anything. The first one sets a key in server.json
that isn't valid or used. The second sets an env var which overrides the same non-existent key in your server.json
.
The valid things you can set in a server.json
are listed here:
https://commandbox.ortusbooks.com/embedded-server/server.json
and you'll notice serverConfigFile
isn't one of them. That is a param to the server start
command, but it's not a value in your server.json and for obvious reasons. You can't have the server.json file tell CommandBox where to find itself! That's a catch-22!