Nextjs Application with Docker
nextjs project setup (bash & npm):
npx create-next-app@latest <project_name>#initialize the projectnpm installnpm run dev
nextjs docs: https://nextjs.org/docs/app/getting-started/installation
#create 3 files named Dockerfile .dockerignore docker-compose.yml
-
touch Dockerfile .dockerignore docker-compose.yml -
docker compose build -
docker compose up -
docker tag
<source-image>:<source-tag><dockerhub-username><target-image>:<target-tag>- example:
docker tag dn_img1/dockerized-nextjs:latest navish123/dockerized-nextjs:latest
- example:
-
docker push <dockerhub-username><target-image>:<target-tag>- example:
docker push navish123/dockerized-nextjs:latest
- example:
-
docker run -p 3000:3000 navish123/dockerized-nextjs:latest#use the image by following the format
docker run -p port_no:port_no <dockerhub-username><target-image>:<target-tag>
share w your peers to see the progress w Livecycle
Github repository link:nextjs-dockerized github repo link
Medium link: https://medium.com/@itsuki.enjoy/dockerize-a-next-js-app-4b03021e084d
Livecycle link: livecycle link