diff --git a/Dockerfile b/Dockerfile index a7a7724ce5..08019070b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,32 +3,37 @@ docker-version 0.4.2 from ubuntu:12.04 maintainer Solomon Hykes # Build dependencies +run echo 'deb http://archive.ubuntu.com/ubuntu precise main universe' > /etc/apt/sources.list +run apt-get update run apt-get install -y -q curl run apt-get install -y -q git +run apt-get install -y -q mercurial # Install Go -run curl -s https://go.googlecode.com/files/go1.1.1.linux-amd64.tar.gz | tar -v -C /usr/local -xz +run curl -s https://go.googlecode.com/files/go1.1.2.linux-amd64.tar.gz | tar -v -C /usr/local -xz env PATH /usr/local/go/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin env GOPATH /go env CGO_ENABLED 0 run cd /tmp && echo 'package main' > t.go && go test -a -i -v +# Ubuntu stuff +run apt-get install -y -q ruby1.9.3 rubygems +run gem install fpm +run apt-get install -y -q reprepro dpkg-sig +# Install s3cmd 1.0.1 (earlier versions don't support env variables in the config) +run apt-get install -y -q python-pip +run pip install s3cmd +run pip install python-magic +run /bin/echo -e '[default]\naccess_key=$AWS_ACCESS_KEY\nsecret_key=$AWS_SECRET_KEY\n' > /.s3cfg # Download dependencies run PKG=github.com/kr/pty REV=27435c699; git clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && git checkout -f $REV run PKG=github.com/gorilla/context/ REV=708054d61e5; git clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && git checkout -f $REV run PKG=github.com/gorilla/mux/ REV=9b36453141c; git clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && git checkout -f $REV run PKG=github.com/dotcloud/tar/ REV=d06045a6d9; git clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && git checkout -f $REV -# Run dependencies -run apt-get install -y iptables -# lxc requires updating ubuntu sources -run echo 'deb http://archive.ubuntu.com/ubuntu precise main universe' > /etc/apt/sources.list -run apt-get update -run apt-get install -y lxc -run apt-get install -y aufs-tools # Docker requires code.google.com/p/go.net/websocket run apt-get install -y -q mercurial -run PKG=code.google.com/p/go.net REV=78ad7f42aa2e; hg clone https://$PKG /go/src/$PKG && cd /go/src/$PKG && hg checkout -r $REV +run PKG=code.google.com/p/go.net/ REV=84a4013f96e0; hg clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && hg checkout $REV # Upload docker source add . /go/src/github.com/dotcloud/docker +run ln -s /go/src/github.com/dotcloud/docker /src # Build the binary -run cd /go/src/github.com/dotcloud/docker/docker && go install -ldflags "-X main.GITCOMMIT '??' -d -w" -env PATH /usr/local/go/bin:/go/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin -cmd ["docker"] +run cd /go/src/github.com/dotcloud/docker && hack/release/make.sh +cmd cd /go/src/github.com/dotcloud/docker && hack/release/release.sh diff --git a/Makefile b/Makefile deleted file mode 100644 index dd365dc30e..0000000000 --- a/Makefile +++ /dev/null @@ -1,95 +0,0 @@ -DOCKER_PACKAGE := github.com/dotcloud/docker -RELEASE_VERSION := $(shell git tag | grep -E "v[0-9\.]+$$" | sort -nr | head -n 1) -SRCRELEASE := docker-$(RELEASE_VERSION) -BINRELEASE := docker-$(RELEASE_VERSION).tgz -BUILD_SRC := build_src -BUILD_PATH := ${BUILD_SRC}/src/${DOCKER_PACKAGE} - -GIT_ROOT := $(shell git rev-parse --show-toplevel) -BUILD_DIR := $(CURDIR)/.gopath - -GOPATH ?= $(BUILD_DIR) -export GOPATH - -GO_OPTIONS ?= -a -ldflags='-w -d' -ifeq ($(VERBOSE), 1) -GO_OPTIONS += -v -endif - -GIT_COMMIT = $(shell git rev-parse --short HEAD) -GIT_STATUS = $(shell test -n "`git status --porcelain`" && echo "+CHANGES") - -BUILD_OPTIONS = -a -ldflags "-X main.GITCOMMIT $(GIT_COMMIT)$(GIT_STATUS) -d -w" - -SRC_DIR := $(GOPATH)/src - -DOCKER_DIR := $(SRC_DIR)/$(DOCKER_PACKAGE) -DOCKER_MAIN := $(DOCKER_DIR)/docker - -DOCKER_BIN_RELATIVE := bin/docker -DOCKER_BIN := $(CURDIR)/$(DOCKER_BIN_RELATIVE) - -.PHONY: all clean test hack release srcrelease $(BINRELEASE) $(SRCRELEASE) $(DOCKER_BIN) $(DOCKER_DIR) - -all: $(DOCKER_BIN) - -$(DOCKER_BIN): $(DOCKER_DIR) - @mkdir -p $(dir $@) - @(cd $(DOCKER_MAIN); CGO_ENABLED=0 go build $(GO_OPTIONS) $(BUILD_OPTIONS) -o $@) - @echo $(DOCKER_BIN_RELATIVE) is created. - -$(DOCKER_DIR): - @mkdir -p $(dir $@) - @if [ -h $@ ]; then rm -f $@; fi; ln -sf $(CURDIR)/ $@ - @(cd $(DOCKER_MAIN); go get -d $(GO_OPTIONS)) - -whichrelease: - echo $(RELEASE_VERSION) - -release: $(BINRELEASE) - s3cmd -P put $(BINRELEASE) s3://get.docker.io/builds/`uname -s`/`uname -m`/docker-$(RELEASE_VERSION).tgz - s3cmd -P put docker-latest.tgz s3://get.docker.io/builds/`uname -s`/`uname -m`/docker-latest.tgz - s3cmd -P put $(SRCRELEASE)/bin/docker s3://get.docker.io/builds/`uname -s`/`uname -m`/docker - echo $(RELEASE_VERSION) > latest ; s3cmd -P put latest s3://get.docker.io/latest ; rm latest - -srcrelease: $(SRCRELEASE) -deps: $(DOCKER_DIR) - -# A clean checkout of $RELEASE_VERSION, with vendored dependencies -$(SRCRELEASE): - rm -fr $(SRCRELEASE) - git clone $(GIT_ROOT) $(SRCRELEASE) - cd $(SRCRELEASE); git checkout -q $(RELEASE_VERSION) - -# A binary release ready to be uploaded to a mirror -$(BINRELEASE): $(SRCRELEASE) - rm -f $(BINRELEASE) - cd $(SRCRELEASE); make; cp -R bin docker-$(RELEASE_VERSION); tar -f ../$(BINRELEASE) -zv -c docker-$(RELEASE_VERSION) - cd $(SRCRELEASE); cp -R bin docker-latest; tar -f ../docker-latest.tgz -zv -c docker-latest -clean: - @rm -rf $(dir $(DOCKER_BIN)) -ifeq ($(GOPATH), $(BUILD_DIR)) - @rm -rf $(BUILD_DIR) -else ifneq ($(DOCKER_DIR), $(realpath $(DOCKER_DIR))) - @rm -f $(DOCKER_DIR) -endif - -test: - # Copy docker source and dependencies for testing - rm -rf ${BUILD_SRC}; mkdir -p ${BUILD_PATH} - tar --exclude=${BUILD_SRC} -cz . | tar -xz -C ${BUILD_PATH} - GOPATH=${CURDIR}/${BUILD_SRC} go get -d - # Do the test - sudo -E GOPATH=${CURDIR}/${BUILD_SRC} CGO_ENABLED=0 go test ${GO_OPTIONS} - -testall: all - @(cd $(DOCKER_DIR); CGO_ENABLED=0 sudo -E go test ./... $(GO_OPTIONS)) - -fmt: - @gofmt -s -l -w . - -hack: - cd $(CURDIR)/hack && vagrant up - -ssh-dev: - cd $(CURDIR)/hack && vagrant ssh diff --git a/VERSION b/VERSION new file mode 100644 index 0000000000..aaa0831b0d --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.5.3-dev diff --git a/commands.go b/commands.go index 8341ba0dbc..c0fee24e12 100644 --- a/commands.go +++ b/commands.go @@ -27,10 +27,9 @@ import ( "unicode" ) -const VERSION = "0.5.3-dev" - var ( GITCOMMIT string + VERSION string ) func (cli *DockerCli) getMethod(name string) (reflect.Method, bool) { diff --git a/contrib/install.sh b/contrib/install.sh index 04340e2acb..3cf7169a07 100755 --- a/contrib/install.sh +++ b/contrib/install.sh @@ -35,10 +35,10 @@ else fi fi -echo "Downloading docker binary and uncompressing into /usr/local/bin..." -curl -s https://get.docker.io/builds/$(uname -s)/$(uname -m)/docker-latest.tgz | -tar -C /usr/local/bin --strip-components=1 -zxf- \ -docker-latest/docker +echo "Downloading docker binary to /usr/local/bin..." +curl -s https://get.docker.io/builds/$(uname -s)/$(uname -m)/docker-latest \ + > /usr/local/bin/docker +chmod +x /usr/local/bin/docker if [ -f /etc/init/dockerd.conf ] then @@ -50,7 +50,7 @@ description "Docker daemon" start on filesystem or runlevel [2345] stop on runlevel [!2345] respawn -exec env LANG="en_US.UTF-8" /usr/local/bin/docker -d +exec /usr/local/bin/docker -d EOF fi diff --git a/docker/docker.go b/docker/docker.go index a48865bfa3..6ac0c9379d 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -16,6 +16,7 @@ import ( var ( GITCOMMIT string + VERSION string ) func main() { @@ -25,6 +26,7 @@ func main() { return } // FIXME: Switch d and D ? (to be more sshd like) + flVersion := flag.Bool("v", false, "Print version information and quit") flDaemon := flag.Bool("d", false, "Daemon mode") flDebug := flag.Bool("D", false, "Debug mode") flAutoRestart := flag.Bool("r", false, "Restart previously running containers") @@ -36,6 +38,10 @@ func main() { flHosts := docker.ListOpts{fmt.Sprintf("unix://%s", docker.DEFAULTUNIXSOCKET)} flag.Var(&flHosts, "H", "tcp://host:port to bind/connect to or unix://path/to/socket to use") flag.Parse() + if *flVersion { + showVersion() + return + } if len(flHosts) > 1 { flHosts = flHosts[1:] //trick to display a nice default value in the usage } @@ -52,6 +58,7 @@ func main() { os.Setenv("DEBUG", "1") } docker.GITCOMMIT = GITCOMMIT + docker.VERSION = VERSION if *flDaemon { if flag.NArg() != 0 { flag.Usage() @@ -74,6 +81,10 @@ func main() { } } +func showVersion() { + fmt.Printf("Docker version %s, build %s\n", VERSION, GITCOMMIT) +} + func createPidFile(pidfile string) error { if pidString, err := ioutil.ReadFile(pidfile); err == nil { pid, err := strconv.Atoi(string(pidString)) diff --git a/hack/RELEASE.md b/hack/RELEASE.md deleted file mode 100644 index 5cf407745a..0000000000 --- a/hack/RELEASE.md +++ /dev/null @@ -1,133 +0,0 @@ -## A maintainer's guide to releasing Docker - -So you're in charge of a docker release? Cool. Here's what to do. - -If your experience deviates from this document, please document the changes to keep it -up-to-date. - - -### 1. Pull from master and create a release branch - - ```bash - $ git checkout master - $ git pull - $ git checkout -b bump_$VERSION - ``` - -### 2. Update CHANGELOG.md - - You can run this command for reference: - - ```bash - LAST_VERSION=$(git tag | grep -E "v[0-9\.]+$" | sort -nr | head -n 1) - git log $LAST_VERSION..HEAD - ``` - - Each change should be formatted as ```BULLET CATEGORY: DESCRIPTION``` - - * BULLET is either ```-```, ```+``` or ```*```, to indicate a bugfix, - new feature or upgrade, respectively. - - * CATEGORY should describe which part of the project is affected. - Valid categories are: - * Builder - * Documentation - * Hack - * Packaging - * Remote API - * Runtime - - * DESCRIPTION: a concise description of the change that is relevant to the end-user, - using the present tense. - Changes should be described in terms of how they affect the user, for example "new feature - X which allows Y", "fixed bug which caused X", "increased performance of Y". - - EXAMPLES: - - ``` - + Builder: 'docker build -t FOO' applies the tag FOO to the newly built container. - * Runtime: improve detection of kernel version - - Remote API: fix a bug in the optional unix socket transport - ``` - -### 3. Change VERSION in commands.go - -### 4. Run all tests - - ```bash - $ make test - ``` - -### 5. Commit and create a pull request - - ```bash - $ git add commands.go CHANGELOG.md - $ git commit -m "Bump version to $VERSION" - $ git push origin bump_$VERSION - ``` - -### 6. Get 2 other maintainers to validate the pull request - -### 7. Merge the pull request and apply tags - - ```bash - $ git checkout master - $ git merge bump_$VERSION - $ git tag -a v$VERSION # Don't forget the v! - $ git tag -f -a latest - $ git push - $ git push --tags - ``` - -### 8. Publish binaries - - To run this you will need access to the release credentials. - Get them from [the infrastructure maintainers](https://github.com/dotcloud/docker/blob/master/hack/infrastructure/MAINTAINERS). - - ```bash - $ RELEASE_IMAGE=image_provided_by_infrastructure_maintainers - $ BUILD=$(docker run -d -e RELEASE_PPA=0 $RELEASE_IMAGE) - ``` - - This will do 2 things: - - * It will build and upload the binaries on http://get.docker.io - * It will *test* the release on our Ubuntu PPA (a PPA is a community repository for ubuntu packages) - - Wait for the build to complete. - - ```bash - $ docker wait $BUILD # This should print 0. If it doesn't, your build failed. - ``` - - Check that the output looks OK. Here's an example of a correct output: - - ```bash - $ docker logs 2>&1 b4e7c8299d73 | grep -e 'Public URL' -e 'Successfully uploaded' - Public URL of the object is: http://get.docker.io.s3.amazonaws.com/builds/Linux/x86_64/docker-v0.4.7.tgz - Public URL of the object is: http://get.docker.io.s3.amazonaws.com/builds/Linux/x86_64/docker-latest.tgz - Successfully uploaded packages. - ``` - - If you don't see 3 lines similar to this, something might be wrong. Check the full logs and try again. - - -### 9. Publish Ubuntu packages - - If everything went well in the previous step, you can finalize the release by submitting the Ubuntu - packages. - - ```bash - $ RELEASE_IMAGE=image_provided_by_infrastructure_maintainers - $ docker run -e RELEASE_PPA=1 $RELEASE_IMAGE - ``` - - If that goes well, Ubuntu Precise package is in its way. It will take anywhere from 0.5 to 30 hours - for the builders to complete their job depending on builder demand at this time. At this point, Quantal - and Raring packages need to be created using the Launchpad interface: - https://launchpad.net/~dotcloud/+archive/lxc-docker/+packages - - Notify [the packager maintainers](https://github.com/dotcloud/docker/blob/master/packaging/MAINTAINERS) - who will ensure PPA is ready. - - Congratulations! You're done diff --git a/hack/dockerbuilder/Dockerfile b/hack/dockerbuilder/Dockerfile deleted file mode 100644 index 496ee45e7a..0000000000 --- a/hack/dockerbuilder/Dockerfile +++ /dev/null @@ -1,36 +0,0 @@ -# DESCRIPTION Build a container capable of producing official binary and -# PPA packages and uploading them to S3 and Launchpad -# VERSION 1.2 -# DOCKER_VERSION 0.4 -# AUTHOR Solomon Hykes -# Daniel Mizyrycki -# BUILD_CMD docker build -t dockerbuilder . -# RUN_CMD docker run -e AWS_ID="$AWS_ID" -e AWS_KEY="$AWS_KEY" -e GPG_KEY="$GPG_KEY" -e PUBLISH_PPA="$PUBLISH_PPA" dockerbuilder -# -# ENV_VARIABLES AWS_ID, AWS_KEY: S3 credentials for uploading Docker binary and tarball -# GPG_KEY: Signing key for docker package -# PUBLISH_PPA: 0 for staging release, 1 for production release -# -from ubuntu:12.04 -maintainer Solomon Hykes -# Workaround the upstart issue -run dpkg-divert --local --rename --add /sbin/initctl -run ln -s /bin/true /sbin/initctl -# Enable universe and gophers PPA -run DEBIAN_FRONTEND=noninteractive apt-get install -y -q python-software-properties -run add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe" -run add-apt-repository -y ppa:dotcloud/docker-golang/ubuntu -run apt-get update -# Packages required to checkout, build and upload docker -run DEBIAN_FRONTEND=noninteractive apt-get install -y -q s3cmd curl -run curl -s -o /go.tar.gz https://go.googlecode.com/files/go1.1.2.linux-amd64.tar.gz -run tar -C /usr/local -xzf /go.tar.gz -run echo "export PATH=/usr/local/go/bin:$PATH" > /.bashrc -run echo "export PATH=/usr/local/go/bin:$PATH" > /.bash_profile -run DEBIAN_FRONTEND=noninteractive apt-get install -y -q git build-essential -# Packages required to build an ubuntu package -run DEBIAN_FRONTEND=noninteractive apt-get install -y -q golang-stable debhelper autotools-dev devscripts -# Copy dockerbuilder files into the container -add . /src -run cp /src/dockerbuilder /usr/local/bin/ && chmod +x /usr/local/bin/dockerbuilder -cmd ["dockerbuilder"] diff --git a/hack/dockerbuilder/MAINTAINERS b/hack/dockerbuilder/MAINTAINERS deleted file mode 100644 index 5dfc881420..0000000000 --- a/hack/dockerbuilder/MAINTAINERS +++ /dev/null @@ -1 +0,0 @@ -Daniel Mizyrycki (@mzdaniel) diff --git a/hack/dockerbuilder/dockerbuilder b/hack/dockerbuilder/dockerbuilder deleted file mode 100644 index 9fa05ce11e..0000000000 --- a/hack/dockerbuilder/dockerbuilder +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -set -x -set -e - -export PATH=/usr/local/go/bin:$PATH - -PACKAGE=github.com/dotcloud/docker - -if [ $# -gt 1 ]; then - echo "Usage: $0 [REVISION]" - exit 1 -fi - -export REVISION=$1 - -if [ -z "$AWS_ID" -o -z "$AWS_KEY" ]; then - echo "Warning: either AWS_ID or AWS_KEY environment variable not set. Won't upload to S3." -else - /bin/echo -e "[default]\naccess_key = $AWS_ID\nsecret_key = $AWS_KEY\n" > /.s3cfg -fi - -if [ -z "$GPG_KEY" ]; then - echo "Warning: environment variable GPG_KEY is not set. Ubuntu package upload will not succeed." - NO_UBUNTU=1 -fi - -rm -fr docker-release -git clone https://github.com/dotcloud/docker docker-release -cd docker-release -if [ -z "$REVISION" ]; then - make release -else - make release RELEASE_VERSION=$REVISION -fi - -# Remove credentials from container -rm -f /.s3cfg - -if [ -z "$NO_UBUNTU" ]; then - export PATH=`echo $PATH | sed 's#/usr/local/go/bin:##g'` - (cd packaging/ubuntu && make ubuntu) -fi diff --git a/hack/release/README.md b/hack/release/README.md new file mode 100644 index 0000000000..f01bb3a60b --- /dev/null +++ b/hack/release/README.md @@ -0,0 +1,106 @@ +## A maintainer's guide to releasing Docker + +So you're in charge of a Docker release? Cool. Here's what to do. + +If your experience deviates from this document, please document the changes +to keep it up-to-date. + + +### 1. Pull from master and create a release branch + +```bash +git checkout master +git pull +git checkout -b bump_$VERSION +``` + +### 2. Update CHANGELOG.md + +You can run this command for reference: + +```bash +LAST_VERSION=$(git tag | grep -E "v[0-9\.]+$" | sort -nr | head -n 1) +git log $LAST_VERSION..HEAD +``` + +Each change should be formatted as ```BULLET CATEGORY: DESCRIPTION``` + +* BULLET is either ```-```, ```+``` or ```*```, to indicate a bugfix, + new feature or upgrade, respectively. + +* CATEGORY should describe which part of the project is affected. + Valid categories are: + * Builder + * Documentation + * Hack + * Packaging + * Remote API + * Runtime + +* DESCRIPTION: a concise description of the change that is relevant to the + end-user, using the present tense. Changes should be described in terms + of how they affect the user, for example "new feature X which allows Y", + "fixed bug which caused X", "increased performance of Y". + +EXAMPLES: + +``` ++ Builder: 'docker build -t FOO' applies the tag FOO to the newly built + container. +* Runtime: improve detection of kernel version +- Remote API: fix a bug in the optional unix socket transport +``` + +### 3. Change the contents of the VERSION file + +### 4. Run all tests + +```bash +go test +``` + +### 5. Commit and create a pull request + +```bash +git add CHANGELOG.md +git commit -m "Bump version to $VERSION" +git push origin bump_$VERSION +``` + +### 6. Get 2 other maintainers to validate the pull request + +### 7. Merge the pull request and apply tags + +```bash +git checkout master +git merge bump_$VERSION +git tag -a v$VERSION # Don't forget the v! +git tag -f -a latest +git push +git push --tags +``` + +### 8. Publish binaries + +To run this you will need access to the release credentials. +Get them from [the infrastructure maintainers]( +https://github.com/dotcloud/docker/blob/master/hack/infrastructure/MAINTAINERS). + +```bash +docker build -t releasedocker . +docker run \ + -e AWS_S3_BUCKET=get-nightly.docker.io \ + -e AWS_ACCESS_KEY=$(cat ~/.aws/access_key) \ + -e AWS_SECRET_KEY=$(cat ~/.aws/secret_key) \ + -e GPG_PASSPHRASE=supersecretsesame \ + releasedocker +``` + +It will build and upload the binaries on the specified bucket (you should +use get-nightly.docker.io for general testing, and once everything is fine, +switch to get.docker.io). + + +### 9. Rejoice! + +Congratulations! You're done. diff --git a/hack/release/make.sh b/hack/release/make.sh new file mode 100755 index 0000000000..a9395832bf --- /dev/null +++ b/hack/release/make.sh @@ -0,0 +1,177 @@ +#!/bin/sh + +# This script builds various binary artifacts from a checkout of the docker +# source code. +# +# Requirements: +# - The current directory should be a checkout of the docker source code +# (http://github.com/dotcloud/docker). Whatever version is checked out +# will be built. +# - The VERSION file, at the root of the repository, should exist, and +# will be used as Docker binary version and package version. +# - The hash of the git commit will also be included in the Docker binary, +# with the suffix -dirty if the repository isn't clean. +# - The script is intented to be run as part of a docker build, as defined +# in the Dockerfile at the root of the source. In other words: +# DO NOT CALL THIS SCRIPT DIRECTLY. +# - The right way to call this script is to invoke "docker build ." from +# your checkout of the Docker repository. +# + +set -e + +# We're a nice, sexy, little shell script, and people might try to run us; +# but really, they shouldn't. We want to be in a container! +RESOLVCONF=$(readlink --canonicalize /etc/resolv.conf) +grep -q "$RESOLVCONF" /proc/mounts || { + echo "# I will only run within a container." + echo "# Try this instead:" + echo "docker build ." + exit 1 +} + +VERSION=$(cat ./VERSION) +PKGVERSION="$VERSION" +GITCOMMIT=$(git rev-parse --short HEAD) +if test -n "$(git status --porcelain)" +then + GITCOMMIT="$GITCOMMIT-dirty" + PKGVERSION="$PKGVERSION-$(date +%Y%m%d%H%M%S)-$GITCOMMIT" +fi + +PACKAGE_ARCHITECTURE="$(dpkg-architecture -qDEB_HOST_ARCH)" +PACKAGE_URL="http://www.docker.io/" +PACKAGE_MAINTAINER="docker@dotcloud.com" +PACKAGE_DESCRIPTION="lxc-docker is a Linux container runtime +Docker complements LXC with a high-level API which operates at the process +level. It runs unix processes with strong guarantees of isolation and +repeatability across servers. +Docker is a great building block for automating distributed systems: +large-scale web deployments, database clusters, continuous deployment systems, +private PaaS, service-oriented architectures, etc." + +UPSTART_SCRIPT='description "Docker daemon" + +start on filesystem or runlevel [2345] +stop on runlevel [!2345] + +respawn + +exec docker -d +' + +# Each "bundle" is a different type of build artefact: static binary, Ubuntu +# package, etc. + +# Build Docker as a static binary file +bundle_binary() { + mkdir -p bundles/$VERSION/binary + go build -o bundles/$VERSION/binary/docker-$VERSION \ + -ldflags "-X main.GITCOMMIT $GITCOMMIT -X main.VERSION $VERSION -d -w" \ + ./docker +} + + +# Build Docker's test suite as a collection of binary files (one per +# sub-package to test) +bundle_test() { + mkdir -p bundles/$VERSION/test + for test_dir in $(find_test_dirs); do + test_binary=$( + cd $test_dir + go test -c -v -ldflags "-X main.GITCOMMIT $GITCOMMIT -X main.VERSION $VERSION -d -w" >&2 + find . -maxdepth 1 -type f -name '*.test' -executable + ) + cp $test_dir/$test_binary bundles/$VERSION/test/ + done +} + +# Build docker as an ubuntu package using FPM and REPREPRO (sue me). +# bundle_binary must be called first. +bundle_ubuntu() { + mkdir -p bundles/$VERSION/ubuntu + + DIR=$(pwd)/bundles/$VERSION/ubuntu/build + + # Generate an upstart config file (ubuntu-specific) + mkdir -p $DIR/etc/init + echo "$UPSTART_SCRIPT" > $DIR/etc/init/docker.conf + + # Copy the binary + mkdir -p $DIR/usr/bin + cp bundles/$VERSION/binary/docker-$VERSION $DIR/usr/bin/docker + + # Generate postinstall/prerm scripts + cat >/tmp/postinstall </tmp/prerm </dev/null || true + # Check access to the bucket. + # s3cmd has no useful exit status, so we cannot check that. + # Instead, we check if it outputs anything on standard output. + # (When there are problems, it uses standard error instead.) + s3cmd info s3://$BUCKET | grep -q . + # Make the bucket accessible through website endpoints. + s3cmd ws-create --ws-index index --ws-error error s3://$BUCKET +} + +# write_to_s3 uploads the contents of standard input to the specified S3 url. +write_to_s3() { + DEST=$1 + F=`mktemp` + cat > $F + s3cmd --acl-public put $F $DEST + rm -f $F +} + +s3_url() { + echo "http://$BUCKET.s3.amazonaws.com" +} + +# Upload the 'ubuntu' bundle to S3: +# 1. A full APT repository is published at $BUCKET/ubuntu/ +# 2. Instructions for using the APT repository are uploaded at $BUCKET/ubuntu/info +release_ubuntu() { + # Make sure that we have our keys + mkdir -p /.gnupg/ + s3cmd sync s3://$BUCKET/ubuntu/.gnupg/ /.gnupg/ || true + gpg --list-keys releasedocker >/dev/null || { + gpg --gen-key --batch < $APTDIR/conf/distributions < bundles/$VERSION/ubuntu/gpg + s3cmd --acl-public put bundles/$VERSION/ubuntu/gpg s3://$BUCKET/gpg + + # Upload repo + s3cmd --acl-public sync $APTDIR/ s3://$BUCKET/ubuntu/ + cat < /etc/apt/sources.list.d/docker.list +# Then import the repository key +curl $(s3_url $BUCKET)/gpg | apt-key add - +# Install docker +apt-get update ; apt-get install -y lxc-docker +EOF + echo "APT repository uploaded. Instructions available at $(s3_url $BUCKET)/ubuntu/info" +} + +# Upload a static binary to S3 +release_binary() { + [ -e bundles/$VERSION ] + S3DIR=s3://$BUCKET/builds/Linux/x86_64 + s3cmd --acl-public put bundles/$VERSION/binary/docker-$VERSION $S3DIR/docker-$VERSION + cat <