Dockerizing Gulp Tasks

The main idea is to get a predictable result when assembling in different environments and allow to keep your system clean.

I have created an example repo which based on the boilerplate FastShell framework and wraps Sass, Gulp, and BrowserSync to demonstrate how to use Docker to build the front-end for your project.

Download the required version of the NodeJS installation script from the NodeSource Node.js Binary Distributions. In my example I have used the 10.x version:


The next step is running the ./ script to build the Docker image or you could run the following command:

docker build -t docker-gulp -f Dockerfile .

Then after it builds run the npm run docker:install to install the project dependencies. This command just the alias of the command below:

docker run --name docker-gulp --rm -ti --pid=host -v $(pwd):/opt docker-gulp npm install --no-optional

As the last step run the npm run docker:watch. You should now see your app running on localhost:3000 and if you make changes in the code on your local machine it will automatically reload.

The next goal is to decrease the Docker image size and speed up the deployment using the alternative distro.

Hope this helps to someone else.