Skip to content

Build Docker image using rosco artifacts

Matt Duftler edited this page Jul 21, 2015 · 9 revisions

These instructions will walk you step-by-step through:

  • Git cloning the spinnaker/rosco artifacts
  • Capturing GCE account credentials (this is required to bake GCE images)
  • Building the spinnaker/rosco image from Dockerfile
  • Tagging the spinnaker/rosco image
  • Pushing the spinnaker/rosco image
  • Validating the packer template contained in the spinnaker/rosco image
Prerequisites:
Important: All of the following commands are to be executed on a machine that has the Docker daemon installed.
Set some environment variables to save us some typing:
export DOCKER_IMAGE_NAME=spinnaker/rosco
export DOCKER_REGISTRY=localhost:5000
Git clone spinnaker/rosco:
git clone https://github.com/spinnaker/rosco.git

or

git clone git@github.com:spinnaker/rosco.git
Note: This next step is needed if you will be baking GCE images, but can be skipped otherwise.
Create rosco/account.json file containing json key retrieved from Google Cloud Console->${Your Project}->APIs & auth->Credentials->Create new Client ID->Service account:
vi rosco/docker/account.json
Note: This next step is needed if you will be baking Docker images, but can be skipped otherwise.
Edit Dockerfile to allow launched containers to (insecurely) push to target docker registry. This should be the address of the docker registry you intend as the push target of baked docker images. Search for and replace the REPLACE_THIS_WITH_DOCKER_REGISTRY_HOST value:
vi rosco/docker/Dockerfile
Build spinnaker/rosco image from Dockerfile:
cd rosco/docker
sudo docker build -t $DOCKER_IMAGE_NAME .
Tag spinnaker/rosco image so it can be pushed to local registry:
sudo docker tag $DOCKER_IMAGE_NAME $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME
Push spinnaker/rosco image to local registry:
sudo docker push $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME
Run shell in container launched from newly-captured image:
sudo docker run -i -t $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME bash
Validate template with AWS-specific parameters:
packer validate \
    -var 'aws_access_key=FOO' \
    -var 'aws_secret_key=BAR' \
    -var 'aws_region=us-east-1' \
    -var 'aws_ssh_username=ubuntu' \
    -var 'aws_instance_type=t2.micro' \
    -var 'aws_source_ami=ami-9eaa1cf6' \
    -var 'aws_target_ami=some-packed-image' \
    -var 'deb_repo=http://dl.bintray.com/spinnaker/ospackages ./' \
    -var 'packages=redis-server' \
    aws-ebs.json
Validate template with GCE-specific parameters:
packer validate \
    -var 'gce_project_id=some-gcp-project' \
    -var 'gce_zone=us-central1-f' \
    -var 'gce_source_image=ubuntu-1404-trusty-v20141212' \
    -var 'gce_target_image=some-packed-image' \
    -var 'deb_repo=http://dl.bintray.com/spinnaker/ospackages' \
    -var 'packages=redis-server' \
    gce.json
Validate template with Docker-specific parameters:
packer validate \
    -var 'docker_source_image=ubuntu:precise' \
    -var 'docker_target_image=some-packed-image' \
    -var 'docker_target_repository=some-registry:5000' \
    -var 'deb_repo=http://dl.bintray.com/spinnaker/ospackages ./' \
    -var 'packages=redis-server' \
    docker.json
Exit out of container:
exit
Clone this wiki locally