File size: 1,629 Bytes
5dfa78d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
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](https://nextjs.org/) using [Docker](https://huggingface.co/docs/hub/spaces-sdks-docker) in πŸ€— [Spaces](https://huggingface.co/spaces).

## Development

1. Install the dependencies: `npm i`
2. Start the local dev-server: `npm run dev`
3. Open the app via [localhost:3000](http://localhost:3000)

## Use the Docker container locally

To make sure that everything is working out, you can run your container locally:

1. [Install Docker](https://docs.docker.com/get-docker/) on your machine
2. Go into the `nextjs-docker-starter` folder
3. Build your Docker image: `docker build -t nextjs-docker-starter .`.
4. Run your Docker container: `docker run -p 3000:3000 nextjs-docker-starter`.
5. Open the app via [localhost:3000](http://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:

```js
// 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.

https://huggingface.co/docs/hub/spaces-github-actions