Giter Club home page Giter Club logo

node-docker-build's Introduction

functions to build and deploy to a docker swarm, based on configuration

Prerequisites

  • latest docker installed (deamon is running and docker-compose does work)
  • latest nodejs/npm installed
  • git client installed
  • ssh access (optional over jump host) to deployment target, docker manager host

Configuration example: domain-config module (config.js)

'use strict'

module.exports = {
	baseImage:'node:10.15.1-alpine'
	compositions:['test'], //compostions of subdomains e.g. test.example.com
	target:{ //optional, target system (deploy)
		host:{host:'manager.example.com', key:'/home/admin/.ssh/id_rsa', user:'admin'},
		jump:{host:'connect.example.com', key:'~/.ssh/id_rsa', user:'admin'},
		home:'/home/admin',
		stackName: 'example',
		sudo:false //optional, prepend "sudo", if required for docker commands
	},
	configs:{ //optional, will be transfered to create docker config (deploy)
		'verdaccio-conf-v2':'verdaccio/conf/config.yaml'
	},
	detach: true //optional, if false std-out/-err is piped to current shell,
	push: true //optional, if false no docker-compose push will be executed,
	update: false //optional, if true "npm update" is used, else "npm install",
	forcePull: false //optional, if true --pull flag is set for docker build,
	buildKit: false //optional, if true docker build kit is enabled for build,
	retryOptions: {retries:1, minTimeout:30000} //retry options for updatePackages
}

Examples

  1. In context of an CI/CD server: Build, push and deploy some images on a dev system composition (dev.example.com) Execution is done in background (spawn a script). If there is already running one, it will be killed. Output is piped to file within defined "logPath".
import {buildDeploy} from '@pubcore/node-docker-build'

buildDeploy({
	repo:'[email protected]:your-scope/compositions.git',
	domain:'dev.example.com',
	logPath:'~/'
})

In context of local compositions package, on developers machine: Build and push some images of a domain. Execution runns in foreground (detach=false), stdout to console

const {build} = require('@pubcore/node-docker-build')
build({
	configModule: resolve(__dirname, 'domains', 'host.docker.internal' , 'config'),
	detach: false,
})

node-docker-build's People

Contributors

jacklrs avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.