| title | emoji | colorFrom | colorTo | sdk | pinned | license | app_port |
|---|---|---|---|---|---|---|---|
Next.js Docker Starter | 🐳🤘 | purple | blue | docker | false | agpl-3.0 | 3000 |
This starter can be used to run Next.js using Docker in 🤗 Spaces.
- Install the dependencies:
npm i - Start the local dev-server:
npm run dev - Open the app via localhost:3000
To make sure that everything is working out, you can run your container locally:
- Install Docker on your machine
- Go into the
nextjs-docker-starterfolder - 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
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.
If you want to use all the features for collaborative development on GitHub, but keep your demo on Spaces, then you can set up a GitHub action that will automatically push changes from GitHub into Spaces.
ℹ️ Git-LFS is required for files bigger than 10MB
- Create your repo on GitHub
- Create a Github secret named
HF_TOKENand use an access token from Hugging Face as its value (you must be logged in to do this) - Update the workflow sync_to_hf_spaces.yml
- Configure
HF_USERNAME: Replacefailfastwith the name of your 🤗 user account or your 🤗 organization - Configure
HF_SPACE_NAME: Replacenextjs-docker-starterwith the name of your 🤗 space
- Configure
- Push the code into your repo on GitHub
This should force push changes in the main branch from GitHub into your 🤗 space.
For further information, you can check out the guide on Hugging Face.