Skip to content

Instantly share code, notes, and snippets.

@apnerve
Last active September 15, 2023 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apnerve/8c1e9192c74c32448d1325a137ad6ecf to your computer and use it in GitHub Desktop.
Save apnerve/8c1e9192c74c32448d1325a137ad6ecf to your computer and use it in GitHub Desktop.

Simpler NextJS development environment

Most of my NextJS projects have the same config and settings. Only thing that changes across is the app folder. So, making a base nextjs docker image made sense for me

Create a file called page.js which exports a React component

export default function Home() {
  return (
    <main className="min-h-screen p-4">
      <h1>Home</h1>
    </main>
  )
}

Now run

docker run -v `pwd`:/app/app -p 3000:3000 apnerve/nextjs npm run dev

This will run the NextJS development server accessible at http://localhost:3000

You could also create an alias

alias z="docker run -v `pwd`:/app/app -p 3000:3000 apnerve/nextjs npm run"

and then use z dev (other commands also work but won't be of much use at the moment)

@apnerve
Copy link
Author

apnerve commented Sep 15, 2023

The docker image is nothing but a plain create-next-app setup without the app folder. It supports TailwindCSS out of the box which is what I use in every project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment