Next.js Discord

Discord Forum

Docker deployment architecture

Unanswered
aprilia posted this in #help-forum
Open in Discord
I use docker compose to deploy my api and nextjs app. For next build to complete, I need my api to be deployed already since i am using getServerSideProps (nextjs 14). Since during the build process of docker image, api wont be available, i use the start command for the nextjs docker image as yarn build && yarn start. This way i can make sure build process triggers only after the api is deployed everytime.
The problem now is I need to have node_modules within the docker image for yarn build to work. This creates docker images weighing as much as 5GB.

I think there are 2 approaches here:
- make sure api is deployed already or create a custom pipeline to trigger an instance of my api everytime i try to build the docker image
- try to fetch data in start step and not in build step

I am not sure if the second approach is possible, but seems like a good way. Please advise me on what i should do here
TIA

0 Replies