Can we determine if the service was run in devMode?

I have an application that uses create-react-app. For production we build a docker image where we use the node docker image to build the static files and then we use the nginx image to host the static files at runtime.

Now I want to support devMode and it’s not ideal to sync the static files to the nginx image. I would prefer to use the build.targetImage to target the node image and then I can use npm start to run the app in dev mode.

Is there some way I can determine that the module is run in devMode in the template?

Hi @Ionshard, welcome to the Forum!

It is possible to detect if a command is run in devMode. We expose some attributes under the command.params variable which can be accessed through the template strings.

Here’s an example of how that could look like in your scenario:

kind: Module
type: container
name: my-module

build:
  [...]
  targetImage: "${command.params.dev && command.params.dev contains 'my-module' ? 'my-dev-image : 'my-prod-image'}"
[...]

I hope this helps, please let me know if that works or if you have any other questions.

Emanuele :sunflower:

1 Like