Next.js Primsma conflict with Docker
Unanswered
Gecco posted this in #help-forum
GeccoOP
Hi there, I'm having an issue with building my Next.js image since in order to pre-render my server side components it needs to connect to my SQL database that has not yet been started. Is there a way to have Postgres start and be running before my Next.js image is built? Thanks
6 Replies
Serengeti
Create docker-compose and add depends_on to nextjs service
GeccoOP
I tried that
here is my docker-compose.yaml file
version: "3.8"
services:
website:
build: .
container_name: portfolio
env_file:
- .env
ports:
- 6333:3000
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
postgres:
image: postgres
restart: always
container_name: portfolio-postgres
volumes:
- db:/var/lib/postgresql/data
env_file:
- .env
volumes:
db:Serengeti
Maybe add healthcheck
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5@Serengeti docker
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5
GeccoOP
sadly not, I can't have website build before postgres has started and depends_on is only applied once both images are built. Same for healthcheck