next-docker-multiple-environment Tailwind Templates

Next Docker Multiple Environment

This is an example of a multi-environment docker compose setup for Next.js, postgres, typescript and tailwind.

Next.js multiple environment docker compose example

This is a simple project as an example of a multi-environment docker compose setup for Next.js and the following:

  • Typescript
  • Tailwind
  • Postgres db container
  • Dev & Production environments

How to use it?

Build the docker image

docker-compose build

Development

npm run dev:up

This will mount your application directory and run next dev in the container for a containerised development environment.

Production

npm run prod:up

This run next build && next start in the container for a containerised production environment.

Docker compose

The docker-compose.dev.yml contains overrides to the docker-compose.yml to allow you to run the application in a development environment. The scripts defined in package.json will illustrate how this is utilised.

For example you could start the development environment using docker-compose directly:

#Optionally add the -d option if you wish to run in detached mode.
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up

Notes

This application is based on create-next-app --example with-typescript. If you wish to you can simply copy the docker-compose.dev.yml docker-compose.yml and Dockerfile files to another project to setup the same environment (perhaps with tweaks for your directory structure).

Top categories

Loading Svelte Themes