metadata
title: Next.js Docker Starter
emoji: 🐳🤘
colorFrom: purple
colorTo: blue
sdk: docker
pinned: false
license: agpl-3.0
app_port: 3000
nextjs-docker-starter
This example can be used to run Next.js using Docker in 🤗 Spaces.
Development
- Install the dependencies:
npm i
- Start the local dev-server:
npm run dev
- Open the app via localhost:3000
Use the Docker container locally
To make sure that everything is working out, you can run your container locally:
- Install Docker on your machine
- Go into the
nextjs-docker-starter
folder - Build your Docker image:
docker build -t nextjs-docker-starter .
. - Run your Docker container:
docker run -p 3000:3000 nextjs-docker-starter
. - Open the app via localhost:3000
Dockerize an existing project
To add support for Docker to an existing project, just copy the Dockerfile
into the root of the project and add the following to the next.config.js
file:
// next.config.js
module.exports = {
// ... rest of the configuration.
output: "standalone",
};
This will build the project as a standalone app inside the Docker image.
Manage your Space via GitHub
If you want to use all the features for collaborative development on GitHub, but keep your demo on Spaces, then you can setup a GitHub action that will automatically push changes from GitHub into Spaces.