When I run an npm run build for prod, it seems to be trying to connect to redis but it can't so it just times out and the build fails after a few minutes. I recently added redis, but I didn't have this issue with my database in the past. Tried looking around online but I can't find anyone else with this issue and I'm not sure what to do about it at this point. Would love some help.
I am running next 14.2.13 with the app directory. My build process is done via docker:
FROM node:22 as base
WORKDIR /app
EXPOSE 3000
ENV PORT 3000
COPY package.json package-lock.json ./
RUN npm install --frozen-lockfile
RUN apt-get update && apt-get install -y imagemagick
COPY . .
RUN if [ -d /app/.next/ ]; then chown -R 1000:1000 /app/.next/; fi
FROM base as prod
RUN npx prisma generate && npm run build
USER 1000
CMD ["npm", "run", "start:migrate:prod"]
FROM base as dev
USER 1000
CMD ["npm", "run", "dev"]
```and my app is run with docker compose:
```yml
services:
app:
# volumes:
# - ./:/app
build:
context: ./
dockerfile: ./Dockerfile
target: prod
container_name: app
user: "1000"
ports:
- "3000:3000"
- "9230:9229"
environment:
- NODE_ENV=production
- DEBUG=engine
env_file:
- ./.env
restart: unless-stopped
db:
image: postgis/postgis:16-3.4
container_name: app-db
restart: always
env_file:
- ./.env
environment:
POSTGRES_DB: default
user: "1000"
volumes:
- ./db:/var/lib/postgresql/data
redis:
image: redis:alpine
container_name: app-redis
restart: always
```And I'm just running `docker compose build`.
Here is what I have for my redis.ts file:
```ts
import { createClient } from 'redis';
export const redis = await createClient({
url: process.env.REDIS_URL,
})
.on('error', (err) => console.error(err))
.connect();