I have a dockerfile where I have web build and api build and I need a web build arg which needs to be overwritten later at the runtime. When I do as below then it does override as I see new value passed at the runtime in the printenv but when the url is called it still shows the old build value. Here is the Dockerfile:
# base
# ------------------------------------------------
FROM node:18-bookworm-slim as base
USER node
WORKDIR /home/node/app
RUN yarn install
# api build
# ------------------------------------------------
FROM base as api_build
RUN yarn prisma generate
# web build
# ------------------------------------------------
FROM base as web_build
# Add web environment variables here as args
ARG ENV1=val1
RUN yarn build web --no-prerender
# serve api
# ------------------------------------------------
FROM node:18-bookworm-slim as serve
#Add runtime envs here
ENV ENV1=${ENV1}
ENV NODE_ENV=production
USER node
WORKDIR /home/node/app
RUN yarn install
RUN yarn add api-server web-server
EXPOSE 8910
CMD ["sh", "-c", "node_modules/.bin/rw-server api & node_modules/.bin/rw-server web"]
I run following command to run the image after bulding
docker run -e ENV1=“val2” -dt -p 8910:8910 imagename
WHen I do docker exec and check the printenv then I can see the updated value but when I run the webapp and the ENV1 value is the redirect url the it uses the val1 from the build argument rather then the val2 from the environment variable
The redwood.toml has following code as well
[web]
title = "EFileEasy"
port = 8910
includeEnvironmentVariables = ['ENV1']
Also I was nota able to run the docker when I had this in the CMD
CMD [ “node_modules/.bin/rw-server”, “–load-env-files”, “&&”, “node_modules/.bin/rw-web-server” ]
as I was getting error that --load-env-file is not valid arugument so not sure if that is causing some error to load the env variables as well.