This project template shows how to use Docker containers to encapsulate all development dependencies for a Node.js app.
Out of the box, you'll be able to use this template to develop a Next.js/React app and deploy it on ZEIT Now.
-
Install Docker CE.
-
Copy
.env.example
file and rename it to.env
. Open the.env
file in your editor and provide values for all environment variables listed in the file. -
Open a terminal window, navigate to the project folder and type:
./up
You will be dropped into the shell inside the Docker container.
-
To start Next.js and other development tools, e.g., ESLint, type in the container shell prompt:
yarn run watch
-
In case you need additional container shells (running tests for example), type
./attach
in another terminal window or tab on your host machine. -
When you're ready to deploy, type:
yarn run deploy
-
To stop the project containers, open a terminal window on your host machine, navigate to the project folder and type:
./down
This project uses Yarn package manager by default. Please use Yarn CLI commands within the container to manage dependencies.
Amend the ./web/docker-environment.sh
script if you would like to use npm or other
package manager.
To improve performance in Docker for Mac and in Windows WSL, the node_modules
folder in this project is symlinked to a folder inside a Docker volume. The
node_modules
folder contents are available within the container only.