My node.js app needs creds and an endpoint to a DB. I deploy the app using cdk and Ec2TaskDefinition. With ECS.ContainerDefinition.addEnvironment(...) I pass env's to a Docker container. Dockerfile has a multistage type where in the last stage I gather all required envs into a string for future usage in NextJS app.
FROM --platform=linux/amd64 node:16-alpine AS deps
#Skiped code
#....
FROM --platform=linux/amd64 node:16-alpine AS runner
ENV DATABASE_URL=postgresql://${DB_USERNAME}:${DB_PASSWORD}@${DB_ENDPOINT}/postgres?schema=public
EXPOSE 8081
CMD ["node_modules/.bin/next", "start", "-p", "8081"]
But in the next app instead of proper formed string I get something like this:
postgresql://:@/postgres?schema=public
All ENV's are empty. But I can see all required envs in Task definition Web interface on Amazon. Seems that I need to transfer them to Docker somehow...