
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
gulp-docker-compose
Advanced tools
Hey there ;) The binding between gulp and docker compose lies ahead.
Just make sure you have installed docker, docker-compose and node, and the current user is in the docker group in order to be able to run docker commands without sudo.
const gulp = require('gulp');
const clean = require('gulp-clean');
const babel = require('gulp-babel');
const path = require('path');
const plumber = require('gulp-plumber');
const vfs = require('vinyl-fs');
const GulpDockerCompose = require('gulp-docker-compose').GulpDockerCompose;
const srcFolder = `${__dirname}/src/`;
const dstFolder = `${__dirname}/build/`;
// clean the previous build
gulp.task('clean', function() {
return gulp.src(dstFolder, {read: false})
.pipe(clean({force: true}));
});
// compile js
gulp.task('build', ['clean'], function() {
// vfs follows symlinks
return vfs.src(srcFolder+'/**/*.js')
.pipe(plumber())
.pipe(babel({
presets: [
["env", {
"targets": {
"node": "4"
},
"modules": "commonjs",
}],
]
}))
.pipe(vfs.dest(dstFolder));
});
var gulpDocker = new GulpDockerCompose(gulp, {
serviceName: 'app',
tasks: {
run: {
name: 'run',
dependences: ['build'],
},
restart: {
name: 'restart',
dependences: ['build'],
},
watchYML: {
name: 'watch-yml',
},
},
extraArgs: {
upOnRun: '--scale app=3',
upOnYMLChange: '--scale app=3',
},
exposeCLICommands: true,
exposeStdOut: false,
exposeStdErr: true,
projectFolder: __dirname,
});
gulp.task('watch', function() {
gulp.watch([srcFolder+'/**/*'], ['build', 'restart']);
});
gulp.task('default', ['build', 'watch', 'watch-yml', 'run']);
GulpDockerCompose takes 2 arguments:
gulp - the reference to gulp object to work withoptions - an object of various options described belowserviceName (optional) - the name of the service to build (typically, the one in docker-compose.yml which has build directive)tasks (optional) - the list of tasks to create, an object with two keys: run - stands for run compose task, and restart - for restarthangOnInt (optional, default: true) - when the Ctrl+C combo is pressed on gulp watch, it stops docker compose. If the option is set to false, it will not override process.on('SIGINT') handler, but in this case, the docker compose (started as a daemon) will not be terminated. You may call gulpDocker.stopDockerCompose() manually in this case.exposeCLICommands (optional, default: false) - being set to true, allows applied docker-compose cli commands to be displayedexposeStdOut (optional, default: false) - expose stdout of cli commandexposeStdErr (optional, default: true) - expose stderr of cli commandprojectFolder (optional) - sets project current folder. Should be set and correct in order to use 'watchYML' taskBoth tasks have the same format: an object with the following keys:
name - the name of the task (an alias #SERVICE_NAME# is available and will get replaced with the value of serviceName)dependences - the list of tasks which should be executed before gulp enters this taskIf no tasks block specified, they can be created with makeRunTask() and makeRestartTask() respectively like the following:
gulpDocker.makeRunTask('run:#SERVICE_NAME#', ['build']);
gulpDocker.makeRestartTask('restart:#SERVICE_NAME#', ['build']);
version: '3'
services:
app:
build: .
depends_on:
- "db"
ports:
- "3101:3012"
environment:
- DB_URL=mongodb://db:27017/mydatabase
- PORT=3012
- ROOT_URL=http://localhost
db:
image: "mongo"
ports:
- "3110:27017"
Note that the corresponding Dockerfile should be present inside the same folder in order to build the service.
In fact, the module only launches the following docker-compose commands:
On run and restart tasks:
docker-compose up -d --build
On docker-compose.yml file changed:
docker-compose up -d --remove-orphans
On Ctrl+C:
docker-compose stop
MIT
Enjoy ;)
FAQs
Gulp <-> Docker Compose binding
We found that gulp-docker-compose demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.