Skip to content

These are some scripts that I've built up while using DockerCloud. Others may find them helpful.

Notifications You must be signed in to change notification settings

TorchlightSoftware/docker-cloud-build

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DockerCloud Build Scripts

These are some scripts that I've built up while using DockerCloud. Others may find them helpful.

Usage

./scripts/build # will build the Dockerfile in the current directory named by name/version from package.json
./scripts/start # will start the image with the current name/version from package.json
./scripts/run-local # this runs your project without creating a container
./scripts/push # the image is prefixed with your current Dockerhub project - this will deploy it to hub.docker.com
./scripts/restart # restart the image
./scripts/stop # stop the image
./scripts/manual # will start the image with a bash terminal

Installation

  1. You'll need docker installed locally (of course).
  2. Add the following to your .profile, .bash_rc, or other shell config:
alias docker-cloud="docker run -it -e DOCKERCLOUD_USER=username -e DOCKERCLOUD_PASS=password --rm dockercloud/cli"

Per Project Environment Variables

Create a tmp/ENV file with the following format:

PORT=4200
NODE_ENV=development

This will be used in scripts/start and scripts/run-local.

Install

You should have the gcloud cli already installed, authenticated, and pointed at a project. gcloud will be called by these scripts to determine naming and to run the deploy.

The scripts use the version number from package.json in your home directory. So run NPM init to get one.

npm init

You can clone the scripts:

git clone https://github.com/TorchlightSoftware/docker-cloud-build.git scripts

Or add them as a submodule to your project:

git submodule add https://github.com/TorchlightSoftware/docker-cloud-build.git scripts

You'll probably end up making project specific changes to the start and manual scripts. I don't have a good solution for that. These scripts should probably be turned into some kind of build tool with a config file. This is just a quick and dirty implementation that works for me.

Feel free to throw out a pull request or issue if you can think of a better way.

Load Environment for Tests

Here is a suggestion for how to load the ENV file into a test environment for Node.js/mocha.

Put this in test/mocha.opts:

-r test/helpers/loadEnv.js

Put this in test/helpers/loadEnv.js:

const fs = require('fs')
const {join} = require('path')
const env = fs.readFileSync(join(__dirname, '../../tmp/ENV'), 'utf8')

console.log(env)

env.split('\n')
  .map((a) => a.split('='))
  .map(([name, value]) => (name && value) ? process.env[name] = value : null)

// override with test env settings
process.env.NODE_ENV = 'test'
process.env.PORT = 3010

About

These are some scripts that I've built up while using DockerCloud. Others may find them helpful.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages