Senior Engineer

Blog

Easy Node.js Docker Environment using Nodedock.io

Nowadays, with the growing complexity of web languages ecosystem, the complexity of setting up development environment grew up dramatically as well.

Docker takes away a lot of difficulties, but it far away from being frictionless itself. Out there, on the market, there’s a lot of tools coming to help to solve this problem, one of them is Nodedock.

Nodedock is a platform based on Laradock, the primary goal of which was simplifying Docker setup for Laravel.

Nodedock is a full Node.js development environment for Docker. It includes pre-packaged Docker Images, all pre-configured to provide a stable solid Node.js development environment.

Starting with Nodedock: Installation & Configuration

Starting with Nodedock is super simple, all you need to add to your existing Node.js project is to add it as a git submodule.

git submodule add https://github.com/nodedock/nodedock.git

As a second step, we need to create an environment configuration file for Nodedock. This would be as simple as running another command:

cp nodedock/env-example nodedock/.env

Out of all variables within .env, these three are the most interesting ones:

NODEDOCK_SERVICES=nginx node workspace
NODEDOCK_LOG_AFTER_START=node
NODE_NPM_START_SCRIPT=start

NODEDOCK_SERVICES sets a list of services to start by default when ./start.shcommand is used. For the full list, you can check nodedock root directory. Per example, you might want to add mysql or mongo here.

NODEDOCK_LOG_AFTER_START sets the containers to tail logs from after ./start.sh command. This will allow you to see startup errors immediately. This is recommended to be set to node.

NODE_NPM_START_SCRIPT defines which npm/yarn command to run to start the application. Being set to start, it will run npm run start command after container is built.

You can also set environment variables from the command line, variables set from command line will override those set in .env

Running Nodedock

To run Nodedock, simply type the command ./nodedock/start.sh in a terminal:

You should see node container log reporting either success or failure starting container up.

That’s it, happy shipping!

Documentation & Getting Help

Majority of the documentation is available at https://nodedock.io/ (adapted from Laradock documentation). If you need to ask a question which is not covered by documentation, feel free to open GitHub issue https://github.com/nodedock/nodedock/issues.

Credits

90% of this project’s code is based on Laradock. Kudos to Laradock’s fantastic core team and all the contributors!

If you like Nodedock, make sure to spread the work! :)