The command I’m using to start the server in my Dockerfile is CMD ["npm", "run", "start"] and in my package.json’s script section I have "start": "cross-env NODE_ENV=production remix-serve build". I think this should be enough to set it to “production”, right?
I also have ENV NODE_ENV=production in my Dockerfile. Also, I have the following in my fly.toml file:
NODE_ENV = "production"
Finally, I have created a secret with fly secrets set NODE_ENV=production.
But still when I console.log(process.env.NODE_ENV) it returns development.
Does anyone know how to help me with that? Thanks!
I have no problem with setting this at build time, though. I just need to know how to do it. Shouldn’t the things I have on the Dockerfile or the fly.toml file make it set to production in build time? Or am I missing something here?
My understanding is that the [env] part of the fly.toml and the fly secrets are both used at runtime. Of course the [env] would be used for any not-secret env values that don’t need to be stored encrypted.
The Dockerfile would be where I think the build-time variables need to be set. Before any build command is run. You have ARG for build-time only ones, or ENV for ones used during the build and the resulting image.
It’s possible that NODE_ENV is being treated differently by Remix as that has its own meaning, unlike CUSTOM_NAME.
Another thing to check: that NODE_ENV is being set before the build command is run in the Dockerfile e.g here in one of their demo stacks it’s near the first thing.
i’m just trying to switch from heroku, so i use the heroku buildpack heroku/pack:20 flyctl set for me, but i can not get rid of the message during build [Warning: Skip pruning because NODE_ENV is not 'production'.] (and the HUGE image size) - i’ve set NODE_ENV in fly.toml && with flyctl secrets set. what should I do?