Yunbo
04/19/2022, 7:54 PMDATABASE_URL
not found when used docker.
in my docker-compose.yml
, i'm passing env_file
directive.
version: "3.3"
services:
myapp:
build:
context: .
dockerfile: ./Dockerfile
env_file:
- .env.dev
this doesn't seem to work.
in docker container, it ran npx prisma migrate deploy
and i'm getting DATBASE_URL is missingWil Moore III
04/19/2022, 8:02 PMDockerfile
Yunbo
04/19/2022, 8:03 PMFROM node:16.10-alpine
WORKDIR /usr/src/app
RUN npm install -g npm@8.7.0
COPY ./package.json ./package-lock.json ./
RUN npm install
COPY ./tsconfig.json ./tsconfig.build.json ./nest-cli.json ./.eslintrc.js ./.prettierrc ./start-container.sh ./
COPY ./src/ ./src
COPY ./prisma/ ./prisma
COPY ./test/ ./test
RUN npx prisma migrate deploy
RUN npm run start
Wil Moore III
04/19/2022, 8:04 PMprisma generate
Yunbo
04/19/2022, 8:04 PMYunbo
04/19/2022, 8:05 PMWil Moore III
04/19/2022, 8:05 PMset
say?Yunbo
04/19/2022, 8:06 PMYunbo
04/19/2022, 8:38 PMDATABASE_URL='<postgresql://awsapi:letmeinmed123@localhost:5436/awsapi_development?schema=public>'
HISTFILE='/root/.ash_history'
HOME='/root'
HOSTNAME='bc7fad1016a7'
IFS='
'
LINENO=''
NODE_ENV='development'
NODE_VERSION='16.10.0'
OPTIND='1'
PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
POSTGRES_USER='postgres'
PPID='0'
PS1='\w \$ '
PS2='> '
PS4='+ '
PWD='/usr/src/app'
SHLVL='1'
TERM='xterm'
YARN_VERSION='1.22.5'
Wil Moore III
04/19/2022, 8:43 PMWil Moore III
04/19/2022, 8:44 PMdocker-compose.yml
?Yunbo
04/19/2022, 9:45 PMyorch
04/19/2022, 10:09 PMyorch
04/19/2022, 10:09 PMARGS
to pass env variables in your build stepyorch
04/19/2022, 10:10 PMWil Moore III
04/19/2022, 10:32 PM```DATABASE_URL='postgresql://awsapi:letmeinmed123@localhost:5436/awsapi_development?schema=public'
...
POSTGRES_USER='postgres'```Notice the
POSTGRES_USER
value is postgres
which means you have a mismatch between that and the user set in DATABASE_URL
: awsapi:letmeinmed123
.
You probably need to set a POSTGRES_PASSWORD
as well.Yunbo
04/20/2022, 4:12 PMRUN npx prisma migrate deploy
in Dockerfile
you create entrypoint.sh and from there you can do like
myapp)
npx prisma migrate deploy
npm run start
;;
then it recognizes DATABSE_URL