I recently dockerized my Next.js application. Everything works so far but every time I docker compose up, I receive these weird warnings about variables that I never used and are nowhere to be found:
docker-compose up
WARN[0000] The "Hh" variable is not set. Defaulting to a blank string.
WARN[0000] The "xG" variable is not set. Defaulting to a blank string.
WARN[0000] The "Hh" variable is not set. Defaulting to a blank string.
WARN[0000] The "xG" variable is not set. Defaulting to a blank string.
[+] Running 3/2
✔ Network hey-shop_default Created 0.0s
✔ Container hey-shop-postgres-1 Created 0.1s
✔ Container hey-shop-web-1 Created 0.0s
Attaching to postgres-1, web-1
This is my docker-compose.yml:
services:
postgres:
image: postgres
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "sh -c 'pg_isready -U postgres -d postgres'"]
interval: 10s
timeout: 3s
retries: 3
web:
build:
context: .
args:
- VERCEL_TOKEN=${VERCEL_TOKEN}
volumes:
- .:/app
ports:
- 3000:3000
- 5555:5555
depends_on:
- postgres
volumes:
postgres-data:
My Dockerfile:
FROM node:20
WORKDIR /app
COPY package.json ./
RUN npm install
RUN npm install --global vercel@latest
COPY . .
ARG VERCEL_TOKEN
RUN vercel env pull .env --environment=Development --token=$VERCEL_TOKEN
RUN DISABLE_ERD=true npx prisma generate --schema ./prisma/schema.prisma
ENV POSTGRES_DATABASE=postgres
ENV POSTGRES_USER=postgres
ENV POSTGRES_PASSWORD=postgres
ENV POSTGRES_HOST=postgres
ENV POSTGRES_URL=postgres://postgres:postgres@postgres:5432/postgres?connect_timeout=300&schema=public
ENV POSTGRES_PRISMA_URL=postgres://postgres:postgres@postgres:5432/postgres?connect_timeout=300&schema=public
ENV POSTGRES_URL_NON_POOLING=postgres://postgres:postgres@postgres:5432/postgres?connect_timeout=300&schema=public
ENV POSTGRES_PORT=5432
EXPOSE 3000
CMD ["npm", "run", "dev"]
This is my .dockerignore:
node_modules
.next
.swc
.env
I work on an Apple M chip and dockerize using Ubuntu 20
I tried completely purging the containers and rebuilding but this appears every time. I don't know if this is something that will give me trouble down the road or if I can ignore it. Either way it seems like something doesn't work as it should.
Thanks to Hans and AymDev, this oversight from me was quickly resolved.
I had in fact a secret set in .env that contained the mentioned "variables":
JWT_SECRET="[...]$Hh[...]$xG[...]"
As I pull the secrets using my Dockerfile, I could remove the entire .env and the warnings disappeared.