Programming language and version: Nodejs, Node v 17.8.0, npm v 8.5.5
Link to your project on Github/Gitlab: Private
Your issue
I am following the steps in this thread, and still unable to access env variables during build time.
So during build of my docker image, I have added a command that performs DB migrations. This command expects the env vars for DB to be available. I have
Set the corresponding env & secrets vars from Qovery UI
Updated the dockerfile, build
It fails
I also have another build var NODE_AUTH_TOKEN which is being correctly used, since it is used for npm ci and that step goes through, so I might be missing something here.
Dockerfile content (if any)
FROM node:17
ARG NODE_AUTH_TOKEN
ARG DB_HOST
ENV DB_HOST $DB_HOST
ARG DB_PORT
ENV DB_PORT $DB_PORT
ARG DB_USERNAME
ENV DB_USERNAME $DB_USERNAME
ARG DB_PASSWORD
ENV DB_PASSWORD $DB_PASSWORD
ARG DB_NAME
ENV DB_NAME $DB_NAME
WORKDIR /btpk
# Install app dependencies
COPY package*.json ./
COPY .npmrc ./
RUN npm ci
# Bundle app source
COPY . .
EXPOSE 8080
RUN npm run build
ENV NODE_ENV=production
RUN npm run migrate
CMD ["npm", "run", "start:prod"]
The error I get is attached below. I can reproduce this error when I change the DB connection params. So its evident that for some reason the env variables are not being passed correctly to the build command.
Hi @r4881t , I think you did it right. The only error I see is your alias DB_HOST targeting the QOVERY_POSTGRESQL_ZA7DD2F46_HOST instead of QOVERY_POSTGRESQL_ZA7DD2F46_HOST_INTERNAL.
The difference between both is QOVERY_POSTGRESQL_ZA7DD2F46_HOST use the external network to connect to your database. So your database must be public (not recommended). Where QOVERY_POSTGRESQL_ZA7DD2F46_HOST use the internal network (it’s recommended).
If:
You change your alias to target QOVERY_POSTGRESQL_ZA7DD2F46_HOST_INTERNAL