Code Monkey home page Code Monkey logo

darkroom's Introduction

darkroom, for developing images

This script builds distribution images for VirtualBox, VMware Fusion, Amazon AWS (AMI), DigitalOcean, and Docker.

Dependencies:

I'm running this on my Mac. Not sure how to configure it on Linux.

Usage

First set these values in your environment:

AWS_ACCESS_KEY
AWS_SECRET_KEY
DIGITALOCEAN_API_KEY
DIGITALOCEAN_CLIENT_ID

Then add the GitHub deployment SSH keys at:

./ssh/id_rsa
./ssh/id_rsa.pub

Now run ./build.sh and go make some tea. Images will be created with corresponding Vagrant boxes in the current directory. If all goes well, you should see something like this at the end.

==> Builds finished. The artifacts of successful builds are:
--> digitalocean: A snapshot was created: 'inboxapp-server 1390117404' in region 'New York 1'
--> digitalocean: 'digitalocean' provider box: inboxapp_digitalocean.box
--> amazon-ebs: AMIs were created:

us-west-2: ami-cc9cfdfc
--> amazon-ebs: 'aws' provider box: inboxapp_aws.box
--> virtualbox-iso: VM files in directory: output-virtualbox-iso
--> virtualbox-iso: 'virtualbox' provider box: inboxapp_virtualbox.box
--> vmware-iso: VM files in directory: output-vmware-iso
--> vmware-iso: 'vmware' provider box: inboxapp_vmware.box
--> docker: Exported Docker file: inboxapp_docker.box.tar

This sets up a few things and then calls packer build packer.json. You can enable debugging output by setting the environment variable PACKER_LOG=1.

Notes on building the Docker image

Because of the dependencies (VMware Fusion specifically), I'm not sure this can run on non-Mac. Here's how I configured Docker to work with Packer.

Docker runs within it's own VirtualBox VM that is configured by the Vagrantfile in docker_vm. This does a few things:

  • Shares the folder /var/folders with the host OS, which is used to transfer scripts.
  • Fowards port 4243 to expose docker network commands.
  • Modifies /etc/init/docker to include -H tcp://0.0.0.0:4243 when starting the docker daemon.

I got the initial idea from here, though it required more changes.

When the build script begins, it sets the DOCKER_HOST environment variable to tcp://127.0.0.1:4243/ and also runs alias docker='docker -H tcp://127.0.0.1:4243/'. This allows Packer to act as-if it's running on the local OS, but actually send commands to the remote instance within the VirtualBox VM. Kind of hacky, but it works.

Future work

  • Tighten up SSH configs for docker provisioner
  • Cleanup/delete Docker VM after building
  • Combine docker image with Dockerfile for startup metadata
  • Auto-upload images to server (and Docker container to public index)
  • Figure out a less hacky way to use a VM with docker. (see dvm project)
  • Fork Packer's docker provisioner and make it not suck so badly
  • Figure out basic Vagrantfile for the various boxes
  • Add Vagrant's public key for easier ssh access. Something like this...
{
  "type": "shell",
  "only": ["virtualbox-iso", "vmware-iso"],
  "inline": [
    "useradd vagrant",
    "echo 'vagrant    ALL = NOPASSWD: ALL' > /etc/sudoers",
    "mkdir -p /home/vagrant/.ssh",
    "wget --no-check-certificate -O authorized_keys 'https://github. /mitchellh/vagrant/raw/master/keys/vagrant.pub'",
    "mv authorized_keys ~/vagrant/.ssh/",
    "chown -R vagrant ~/vagrant/.ssh"
  ]
},

darkroom's People

Contributors

grinich avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

digideskio

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.