Browse code

Moved release scripts to hack/release and updated instructions.

Jérôme Petazzoni authored on 2013/08/17 08:05:16
Showing 7 changed files
... ...
@@ -35,5 +35,5 @@ run	PKG=code.google.com/p/go.net/ REV=84a4013f96e0;  hg  clone http://$PKG /go/s
35 35
 add	.       /go/src/github.com/dotcloud/docker
36 36
 run	ln -s	/go/src/github.com/dotcloud/docker /src
37 37
 # Build the binary
38
-run	cd /go/src/github.com/dotcloud/docker && ./make.sh
39
-cmd	cd /go/src/github.com/dotcloud/docker && ./release.sh
38
+run	cd /go/src/github.com/dotcloud/docker && hack/release/make.sh
39
+cmd	cd /go/src/github.com/dotcloud/docker && hack/release/release.sh
40 40
deleted file mode 100644
... ...
@@ -1,133 +0,0 @@
1
-## A maintainer's guide to releasing Docker
2
-
3
-So you're in charge of a docker release? Cool. Here's what to do.
4
-
5
-If your experience deviates from this document, please document the changes to keep it
6
-up-to-date.
7
-
8
-
9
-### 1. Pull from master and create a release branch
10
-
11
-	```bash
12
-	$ git checkout master
13
-	$ git pull
14
-	$ git checkout -b bump_$VERSION
15
-	```
16
-
17
-### 2. Update CHANGELOG.md
18
-
19
-	You can run this command for reference:
20
-
21
-	```bash
22
-	LAST_VERSION=$(git tag | grep -E "v[0-9\.]+$" | sort -nr | head -n 1)
23
-	git log $LAST_VERSION..HEAD
24
-	```
25
-
26
-	Each change should be formatted as ```BULLET CATEGORY: DESCRIPTION```
27
-
28
-	* BULLET is either ```-```, ```+``` or ```*```, to indicate a bugfix,
29
-	new feature or upgrade, respectively.
30
-
31
-	* CATEGORY should describe which part of the project is affected.
32
-	Valid categories are:
33
-		* Builder
34
-		* Documentation
35
-		* Hack
36
-		* Packaging
37
-		* Remote API
38
-		* Runtime
39
-
40
-	* DESCRIPTION: a concise description of the change that is relevant to the end-user,
41
-	using the present tense.
42
-	Changes should be described in terms of how they affect the user, for example "new feature
43
-	X which allows Y", "fixed bug which caused X", "increased performance of Y".
44
-
45
-	EXAMPLES:
46
-
47
-		```
48
-		 + Builder: 'docker build -t FOO' applies the tag FOO to the newly built container.
49
-		 * Runtime: improve detection of kernel version
50
-		 - Remote API: fix a bug in the optional unix socket transport
51
-		 ```
52
-
53
-### 3. Change the contents of the VERSION file
54
-
55
-### 4. Run all tests
56
-
57
-	```bash
58
-	$ make test
59
-	```
60
-
61
-### 5. Commit and create a pull request
62
-
63
-	```bash
64
-	$ git add commands.go CHANGELOG.md
65
-	$ git commit -m "Bump version to $VERSION"
66
-	$ git push origin bump_$VERSION
67
-	```
68
-
69
-### 6. Get 2 other maintainers to validate the pull request
70
-
71
-### 7. Merge the pull request and apply tags
72
-
73
-	```bash
74
-	$ git checkout master
75
-	$ git merge bump_$VERSION
76
-	$ git tag -a v$VERSION # Don't forget the v!
77
-	$ git tag -f -a latest
78
-	$ git push
79
-	$ git push --tags
80
-	```
81
-
82
-### 8. Publish binaries
83
-
84
-	To run this you will need access to the release credentials.
85
-	Get them from [the infrastructure maintainers](https://github.com/dotcloud/docker/blob/master/hack/infrastructure/MAINTAINERS).
86
-
87
-	```bash
88
-	$ RELEASE_IMAGE=image_provided_by_infrastructure_maintainers
89
-	$ BUILD=$(docker run -d -e RELEASE_PPA=0 $RELEASE_IMAGE)
90
-	```
91
-
92
-	This will do 2 things:
93
-	
94
-	* It will build and upload the binaries on http://get.docker.io
95
-	* It will *test* the release on our Ubuntu PPA (a PPA is a community repository for ubuntu packages)
96
-
97
-	Wait for the build to complete.
98
-
99
-	```bash
100
-	$ docker wait $BUILD # This should print 0. If it doesn't, your build failed.
101
-	```
102
-
103
-	Check that the output looks OK. Here's an example of a correct output:
104
-
105
-	```bash
106
-	$ docker logs 2>&1 b4e7c8299d73 | grep -e 'Public URL' -e 'Successfully uploaded'
107
-	Public URL of the object is: http://get.docker.io.s3.amazonaws.com/builds/Linux/x86_64/docker-v0.4.7.tgz
108
-	Public URL of the object is: http://get.docker.io.s3.amazonaws.com/builds/Linux/x86_64/docker-latest.tgz
109
-	Successfully uploaded packages.
110
-	```
111
-
112
-	If you don't see 3 lines similar to this, something might be wrong. Check the full logs and try again.
113
-	
114
-
115
-### 9. Publish Ubuntu packages
116
-
117
-	If everything went well in the previous step, you can finalize the release by submitting the Ubuntu
118
-	packages.
119
-
120
-	```bash
121
-	$ RELEASE_IMAGE=image_provided_by_infrastructure_maintainers
122
-	$ docker run -e RELEASE_PPA=1 $RELEASE_IMAGE
123
-	```
124
-
125
-	If that goes well, Ubuntu Precise package is in its way. It will take anywhere from 0.5 to 30 hours
126
-	for the builders to complete their job depending on builder demand at this time. At this point, Quantal
127
-	and Raring packages need to be created using the Launchpad interface:
128
-	  https://launchpad.net/~dotcloud/+archive/lxc-docker/+packages
129
-
130
-	Notify [the packager maintainers](https://github.com/dotcloud/docker/blob/master/packaging/MAINTAINERS)
131
-	who will ensure PPA is ready.
132
-
133
-	Congratulations! You're done
134 1
new file mode 100644
... ...
@@ -0,0 +1,106 @@
0
+## A maintainer's guide to releasing Docker
1
+
2
+So you're in charge of a Docker release? Cool. Here's what to do.
3
+
4
+If your experience deviates from this document, please document the changes
5
+to keep it up-to-date.
6
+
7
+
8
+### 1. Pull from master and create a release branch
9
+
10
+```bash
11
+git checkout master
12
+git pull
13
+git checkout -b bump_$VERSION
14
+```
15
+
16
+### 2. Update CHANGELOG.md
17
+
18
+You can run this command for reference:
19
+
20
+```bash
21
+LAST_VERSION=$(git tag | grep -E "v[0-9\.]+$" | sort -nr | head -n 1)
22
+git log $LAST_VERSION..HEAD
23
+```
24
+
25
+Each change should be formatted as ```BULLET CATEGORY: DESCRIPTION```
26
+
27
+* BULLET is either ```-```, ```+``` or ```*```, to indicate a bugfix,
28
+  new feature or upgrade, respectively.
29
+
30
+* CATEGORY should describe which part of the project is affected.
31
+  Valid categories are:
32
+  * Builder
33
+  * Documentation
34
+  * Hack
35
+  * Packaging
36
+  * Remote API
37
+  * Runtime
38
+
39
+* DESCRIPTION: a concise description of the change that is relevant to the 
40
+  end-user, using the present tense. Changes should be described in terms 
41
+  of how they affect the user, for example "new feature X which allows Y", 
42
+  "fixed bug which caused X", "increased performance of Y".
43
+
44
+EXAMPLES:
45
+
46
+```
47
++ Builder: 'docker build -t FOO' applies the tag FOO to the newly built
48
+  container.
49
+* Runtime: improve detection of kernel version
50
+- Remote API: fix a bug in the optional unix socket transport
51
+```
52
+
53
+### 3. Change the contents of the VERSION file
54
+
55
+### 4. Run all tests
56
+
57
+```bash
58
+go test
59
+```
60
+
61
+### 5. Commit and create a pull request
62
+
63
+```bash
64
+git add CHANGELOG.md
65
+git commit -m "Bump version to $VERSION"
66
+git push origin bump_$VERSION
67
+```
68
+
69
+### 6. Get 2 other maintainers to validate the pull request
70
+
71
+### 7. Merge the pull request and apply tags
72
+
73
+```bash
74
+git checkout master
75
+git merge bump_$VERSION
76
+git tag -a v$VERSION # Don't forget the v!
77
+git tag -f -a latest
78
+git push
79
+git push --tags
80
+```
81
+
82
+### 8. Publish binaries
83
+
84
+To run this you will need access to the release credentials.
85
+Get them from [the infrastructure maintainers](
86
+https://github.com/dotcloud/docker/blob/master/hack/infrastructure/MAINTAINERS).
87
+
88
+```bash
89
+docker build -t releasedocker .
90
+docker run  \
91
+	-e AWS_S3_BUCKET=get-nightly.docker.io \
92
+	-e AWS_ACCESS_KEY=$(cat ~/.aws/access_key) \
93
+	-e AWS_SECRET_KEY=$(cat ~/.aws/secret_key) \
94
+	-e GPG_PASSPHRASE=supersecretsesame \
95
+	releasedocker
96
+```
97
+
98
+It will build and upload the binaries on the specified bucket (you should
99
+use get-nightly.docker.io for general testing, and once everything is fine,
100
+switch to get.docker.io).
101
+
102
+
103
+### 9. Rejoice!
104
+
105
+Congratulations! You're done.
0 106
new file mode 100755
... ...
@@ -0,0 +1,178 @@
0
+#!/bin/sh
1
+
2
+# This script builds various binary artifacts from a checkout of the docker
3
+# source code.
4
+#
5
+# Requirements:
6
+# - The current directory should be a checkout of the docker source code
7
+#   (http://github.com/dotcloud/docker). Whatever version is checked out
8
+#   will be built.
9
+# - The VERSION file, at the root of the repository, should exist, and
10
+#   will be used as Docker binary version and package version.
11
+# - The hash of the git commit will also be included in the Docker binary,
12
+#   with the suffix -dirty if the repository isn't clean.
13
+# - The script is intented to be run as part of a docker build, as defined
14
+#   in the Dockerfile at the root of the source. In other words:
15
+#   DO NOT CALL THIS SCRIPT DIRECTLY.
16
+# - The right way to call this script is to invoke "docker build ." from
17
+#   your checkout of the Docker repository.
18
+# 
19
+
20
+set -e
21
+set -x
22
+
23
+# We're a nice, sexy, little shell script, and people might try to run us;
24
+# but really, they shouldn't. We want to be in a container!
25
+RESOLVCONF=$(readlink --canonicalize /etc/resolv.conf)
26
+grep -q "$RESOLVCONF" /proc/mounts || {
27
+	echo "# I will only run within a container."
28
+	echo "# Try this instead:"
29
+	echo "docker build ."
30
+	exit 1
31
+}
32
+
33
+VERSION=$(cat ./VERSION)
34
+PKGVERSION="$VERSION"
35
+GITCOMMIT=$(git rev-parse --short HEAD)
36
+if test -n "$(git status --porcelain)"
37
+then
38
+	GITCOMMIT="$GITCOMMIT-dirty"
39
+	PKGVERSION="$PKGVERSION-$(date +%Y%m%d%H%M%S)-$GITCOMMIT"
40
+fi
41
+
42
+PACKAGE_ARCHITECTURE="$(dpkg-architecture -qDEB_HOST_ARCH)"
43
+PACKAGE_URL="http://www.docker.io/"
44
+PACKAGE_MAINTAINER="docker@dotcloud.com"
45
+PACKAGE_DESCRIPTION="lxc-docker is a Linux container runtime
46
+Docker complements LXC with a high-level API which operates at the process
47
+level. It runs unix processes with strong guarantees of isolation and
48
+repeatability across servers.
49
+Docker is a great building block for automating distributed systems:
50
+large-scale web deployments, database clusters, continuous deployment systems,
51
+private PaaS, service-oriented architectures, etc."
52
+
53
+UPSTART_SCRIPT='description     "Docker daemon"
54
+
55
+start on filesystem or runlevel [2345]
56
+stop on runlevel [!2345]
57
+
58
+respawn
59
+
60
+exec docker -d
61
+'
62
+
63
+# Each "bundle" is a different type of build artefact: static binary, Ubuntu
64
+# package, etc.
65
+
66
+# Build Docker as a static binary file
67
+bundle_binary() {
68
+	mkdir -p bundles/$VERSION/binary
69
+	go build -o bundles/$VERSION/binary/docker-$VERSION \
70
+		-ldflags "-X main.GITCOMMIT $GITCOMMIT -X main.VERSION $VERSION -d -w" \
71
+		./docker
72
+}
73
+
74
+
75
+# Build Docker's test suite as a collection of binary files (one per
76
+# sub-package to test)
77
+bundle_test() {
78
+	mkdir -p bundles/$VERSION/test
79
+	for test_dir in $(find_test_dirs); do
80
+		test_binary=$(
81
+			cd $test_dir
82
+			go test -c -v -ldflags "-X main.GITCOMMIT $GITCOMMIT -X main.VERSION $VERSION -d -w" >&2
83
+			find . -maxdepth 1 -type f -name '*.test' -executable
84
+		)
85
+		cp $test_dir/$test_binary bundles/$VERSION/test/
86
+	done
87
+}
88
+
89
+# Build docker as an ubuntu package using FPM and REPREPRO (sue me).
90
+# bundle_binary must be called first.
91
+bundle_ubuntu() {
92
+	mkdir -p bundles/$VERSION/ubuntu
93
+
94
+	DIR=$(pwd)/bundles/$VERSION/ubuntu/build
95
+
96
+	# Generate an upstart config file (ubuntu-specific)
97
+	mkdir -p $DIR/etc/init
98
+	echo "$UPSTART_SCRIPT" > $DIR/etc/init/docker.conf
99
+
100
+	# Copy the binary
101
+	mkdir -p $DIR/usr/bin
102
+	cp bundles/$VERSION/binary/docker-$VERSION $DIR/usr/bin/docker
103
+
104
+	# Generate postinstall/prerm scripts
105
+	cat >/tmp/postinstall <<EOF
106
+#!/bin/sh
107
+/sbin/stop docker || true
108
+/sbin/start docker
109
+EOF
110
+	cat >/tmp/prerm <<EOF
111
+#!/bin/sh
112
+/sbin/stop docker || true
113
+EOF
114
+	chmod +x /tmp/postinstall /tmp/prerm
115
+
116
+	(
117
+		cd bundles/$VERSION/ubuntu
118
+		fpm -s dir -C $DIR \
119
+		    --name lxc-docker-$VERSION --version $PKGVERSION \
120
+		    --after-install /tmp/postinstall \
121
+		    --before-remove /tmp/prerm \
122
+		    --architecture "$PACKAGE_ARCHITECTURE" \
123
+		    --prefix / \
124
+		    --depends lxc --depends aufs-tools \
125
+		    --description "$PACKAGE_DESCRIPTION" \
126
+		    --maintainer "$PACKAGE_MAINTAINER" \
127
+		    --conflicts lxc-docker-virtual-package \
128
+		    --provides lxc-docker \
129
+		    --provides lxc-docker-virtual-package \
130
+		    --replaces lxc-docker \
131
+		    --replaces lxc-docker-virtual-package \
132
+		    --url "$PACKAGE_URL" \
133
+		    --vendor "$PACKAGE_VENDOR" \
134
+		    -t deb .
135
+		mkdir empty
136
+		fpm -s dir -C empty \
137
+		    --name lxc-docker --version $PKGVERSION \
138
+		    --architecture "$PACKAGE_ARCHITECTURE" \
139
+		    --depends lxc-docker-$VERSION \
140
+		    --description "$PACKAGE_DESCRIPTION" \
141
+		    --maintainer "$PACKAGE_MAINTAINER" \
142
+		    --url "$PACKAGE_URL" \
143
+		    --vendor "$PACKAGE_VENDOR" \
144
+		    -t deb .
145
+	)
146
+}
147
+
148
+
149
+# This helper function walks the current directory looking for directories
150
+# holding Go test files, and prints their paths on standard output, one per
151
+# line.
152
+find_test_dirs() {
153
+	find . -name '*_test.go' | 
154
+		{ while read f; do dirname $f; done; } | 
155
+		sort -u
156
+}
157
+
158
+
159
+main() {
160
+	bundle_binary
161
+	bundle_ubuntu
162
+	#bundle_test
163
+	cat <<EOF
164
+###############################################################################
165
+Now run the resulting image, making sure that you set AWS_S3_BUCKET,
166
+AWS_ACCESS_KEY, and AWS_SECRET_KEY environment variables:
167
+
168
+docker run -e AWS_S3_BUCKET=get-staging.docker.io \\
169
+              AWS_ACCESS_KEY=AKI1234... \\
170
+              AWS_SECRET_KEY=sEs3mE... \\
171
+              GPG_PASSPHRASE=sesame... \\
172
+              image_id_or_name
173
+###############################################################################
174
+EOF
175
+}
176
+
177
+main
0 178
new file mode 100755
... ...
@@ -0,0 +1,176 @@
0
+#!/bin/sh
1
+
2
+# This script looks for bundles built by make.sh, and releases them on a
3
+# public S3 bucket.
4
+#
5
+# Bundles should be available for the VERSION string passed as argument.
6
+#
7
+# The correct way to call this script is inside a container built by the
8
+# official Dockerfile at the root of the Docker source code. The Dockerfile,
9
+# make.sh and release.sh should all be from the same source code revision.
10
+
11
+set -x
12
+set -e
13
+
14
+# Print a usage message and exit.
15
+usage() {
16
+	cat <<EOF
17
+To run, I need:
18
+- to be in a container generated by the Dockerfile at the top of the Docker
19
+  repository;
20
+- to be provided with the name of an S3 bucket, in environment variable
21
+  AWS_S3_BUCKET;
22
+- to be provided with AWS credentials for this S3 bucket, in environment
23
+  variables AWS_ACCESS_KEY and AWS_SECRET_KEY;
24
+- the passphrase to unlock the GPG key which will sign the deb packages
25
+  (passed as environment variable GPG_PASSPHRASE);
26
+- a generous amount of good will and nice manners.
27
+The canonical way to run me is to run the image produced by the Dockerfile: e.g.:"
28
+
29
+docker run -e AWS_S3_BUCKET=get-staging.docker.io \\
30
+              AWS_ACCESS_KEY=AKI1234... \\
31
+              AWS_SECRET_KEY=sEs4mE... \\
32
+              GPG_PASSPHRASE=m0resEs4mE... \\
33
+              f0058411
34
+EOF
35
+	exit 1
36
+}
37
+
38
+[ "$AWS_S3_BUCKET" ] || usage
39
+[ "$AWS_ACCESS_KEY" ] || usage
40
+[ "$AWS_SECRET_KEY" ] || usage
41
+[ "$GPG_PASSPHRASE" ] || usage
42
+[ -d /go/src/github.com/dotcloud/docker/ ] || usage
43
+cd /go/src/github.com/dotcloud/docker/ 
44
+
45
+VERSION=$(cat VERSION)
46
+BUCKET=$AWS_S3_BUCKET
47
+
48
+setup_s3() {
49
+	# Try creating the bucket. Ignore errors (it might already exist).
50
+	s3cmd mb s3://$BUCKET 2>/dev/null || true
51
+	# Check access to the bucket.
52
+	# s3cmd has no useful exit status, so we cannot check that.
53
+	# Instead, we check if it outputs anything on standard output.
54
+	# (When there are problems, it uses standard error instead.)
55
+	s3cmd info s3://$BUCKET | grep -q .
56
+	# Make the bucket accessible through website endpoints.
57
+	s3cmd ws-create --ws-index index --ws-error error s3://$BUCKET
58
+}
59
+
60
+# write_to_s3 uploads the contents of standard input to the specified S3 url.
61
+write_to_s3() {
62
+	DEST=$1
63
+	F=`mktemp`
64
+	cat > $F
65
+	s3cmd --acl-public put $F $DEST
66
+	rm -f $F
67
+}
68
+
69
+s3_url() {
70
+	echo "http://$BUCKET.s3.amazonaws.com"
71
+}
72
+
73
+# Upload the 'ubuntu' bundle to S3:
74
+# 1. A full APT repository is published at $BUCKET/ubuntu/
75
+# 2. Instructions for using the APT repository are uploaded at $BUCKET/ubuntu/info
76
+release_ubuntu() {
77
+	# Make sure that we have our keys
78
+	mkdir -p /.gnupg/
79
+	s3cmd sync s3://$BUCKET/ubuntu/.gnupg/ /.gnupg/ || true
80
+	gpg --list-keys releasedocker >/dev/null || {
81
+		gpg --gen-key --batch <<EOF   
82
+Key-Type: RSA
83
+Key-Length: 2048
84
+Passphrase: $GPG_PASSPHRASE
85
+Name-Real: Docker Release Tool
86
+Name-Email: docker@dotcloud.com
87
+Name-Comment: releasedocker
88
+Expire-Date: 0
89
+%commit
90
+EOF
91
+	}
92
+
93
+	# Sign our packages
94
+	dpkg-sig -g "--passphrase $GPG_PASSPHRASE" -k releasedocker \
95
+		 --sign builder bundles/$VERSION/ubuntu/*.deb
96
+
97
+	# Setup the APT repo
98
+	APTDIR=bundles/$VERSION/ubuntu/apt
99
+	mkdir -p $APTDIR/conf $APTDIR/db
100
+	s3cmd sync s3://$BUCKET/ubuntu/db/ $APTDIR/db/ || true
101
+	cat > $APTDIR/conf/distributions <<EOF
102
+Codename: docker
103
+Components: main
104
+Architectures: amd64 i386
105
+EOF
106
+
107
+	# Add the DEB package to the APT repo
108
+	DEBFILE=bundles/$VERSION/ubuntu/lxc-docker*.deb
109
+	reprepro -b $APTDIR includedeb docker $DEBFILE
110
+
111
+	# Sign
112
+	for F in $(find $APTDIR -name Release)
113
+	do
114
+		gpg -u releasedocker --passphrase $GPG_PASSPHRASE \
115
+			--armor --sign --detach-sign \
116
+			--output $F.gpg $F
117
+	done
118
+
119
+	# Upload keys
120
+	s3cmd sync /.gnupg/ s3://$BUCKET/ubuntu/.gnupg/
121
+	gpg --armor --export releasedocker > bundles/$VERSION/ubuntu/gpg
122
+	s3cmd --acl-public put bundles/$VERSION/ubuntu/gpg s3://$BUCKET/gpg
123
+
124
+	# Upload repo
125
+	s3cmd --acl-public sync $APTDIR/ s3://$BUCKET/ubuntu/
126
+	cat <<EOF | write_to_s3 s3://$BUCKET/ubuntu/info
127
+# Add the repository to your APT sources
128
+echo deb $(s3_url $BUCKET)/ubuntu docker main > /etc/apt/sources.list.d/docker.list
129
+# Then import the repository key
130
+curl $(s3_url $BUCKET)/gpg | apt-key add -
131
+# Install docker
132
+apt-get update ; apt-get install -y lxc-docker
133
+EOF
134
+	echo "APT repository uploaded. Instructions available at $(s3_url $BUCKET)/ubuntu/info"
135
+}
136
+
137
+# Upload a static binary to S3
138
+release_binary() {
139
+	[ -e bundles/$VERSION ]
140
+	S3DIR=s3://$BUCKET/builds/Linux/x86_64
141
+	s3cmd --acl-public put bundles/$VERSION/binary/docker-$VERSION $S3DIR/docker-$VERSION
142
+	cat <<EOF | write_to_s3 s3://$BUCKET/builds/info
143
+# To install, run the following command as root:
144
+curl -O http://$BUCKET.s3.amazonaws.com/builds/Linux/x86_64/docker-$VERSION && chmod +x docker-$VERSION && sudo mv docker-$VERSION /usr/local/bin/docker
145
+# Then start docker in daemon mode:
146
+sudo /usr/local/bin/docker -d
147
+EOF
148
+	if [ -z "$NOLATEST" ]; then
149
+		echo "Copying docker-$VERSION to docker-latest"
150
+		s3cmd --acl-public cp $S3DIR/docker-$VERSION $S3DIR/docker-latest
151
+		echo "Advertising $VERSION on $BUCKET as most recent version"
152
+		echo $VERSION | write_to_s3 s3://$BUCKET/latest
153
+	fi
154
+}
155
+
156
+# Upload the index script
157
+release_index() {
158
+	(
159
+	if [ "$BUCKET" != "get.docker.io" ]
160
+	then
161
+		sed s,https://get.docker.io/,http://$BUCKET.s3.amazonaws.com/, contrib/install.sh
162
+	else
163
+		cat contrib/install.sh
164
+	fi
165
+	) | write_to_s3 s3://$BUCKET/index
166
+}
167
+
168
+main() {
169
+	setup_s3
170
+	release_binary
171
+	release_ubuntu
172
+	release_index
173
+}
174
+
175
+main
0 176
deleted file mode 100755
... ...
@@ -1,178 +0,0 @@
1
-#!/bin/sh
2
-
3
-# This script builds various binary artifacts from a checkout of the docker
4
-# source code.
5
-#
6
-# Requirements:
7
-# - The current directory should be a checkout of the docker source code
8
-#   (http://github.com/dotcloud/docker). Whatever version is checked out
9
-#   will be built.
10
-# - The VERSION file, at the root of the repository, should exist, and
11
-#   will be used as Docker binary version and package version.
12
-# - The hash of the git commit will also be included in the Docker binary,
13
-#   with the suffix -dirty if the repository isn't clean.
14
-# - The script is intented to be run as part of a docker build, as defined
15
-#   in the Dockerfile at the root of the source. In other words:
16
-#   DO NOT CALL THIS SCRIPT DIRECTLY.
17
-# - The right way to call this script is to invoke "docker build ." from
18
-#   your checkout of the Docker repository.
19
-# 
20
-
21
-set -e
22
-set -x
23
-
24
-# We're a nice, sexy, little shell script, and people might try to run us;
25
-# but really, they shouldn't. We want to be in a container!
26
-RESOLVCONF=$(readlink --canonicalize /etc/resolv.conf)
27
-grep -q "$RESOLVCONF" /proc/mounts || {
28
-	echo "# I will only run within a container."
29
-	echo "# Try this instead:"
30
-	echo "docker build ."
31
-	exit 1
32
-}
33
-
34
-VERSION=$(cat ./VERSION)
35
-PKGVERSION="$VERSION"
36
-GITCOMMIT=$(git rev-parse --short HEAD)
37
-if test -n "$(git status --porcelain)"
38
-then
39
-	GITCOMMIT="$GITCOMMIT-dirty"
40
-	PKGVERSION="$PKGVERSION-$(date +%Y%m%d%H%M%S)-$GITCOMMIT"
41
-fi
42
-
43
-PACKAGE_ARCHITECTURE="$(dpkg-architecture -qDEB_HOST_ARCH)"
44
-PACKAGE_URL="http://www.docker.io/"
45
-PACKAGE_MAINTAINER="docker@dotcloud.com"
46
-PACKAGE_DESCRIPTION="lxc-docker is a Linux container runtime
47
-Docker complements LXC with a high-level API which operates at the process
48
-level. It runs unix processes with strong guarantees of isolation and
49
-repeatability across servers.
50
-Docker is a great building block for automating distributed systems:
51
-large-scale web deployments, database clusters, continuous deployment systems,
52
-private PaaS, service-oriented architectures, etc."
53
-
54
-UPSTART_SCRIPT='description     "Docker daemon"
55
-
56
-start on filesystem or runlevel [2345]
57
-stop on runlevel [!2345]
58
-
59
-respawn
60
-
61
-exec docker -d
62
-'
63
-
64
-# Each "bundle" is a different type of build artefact: static binary, Ubuntu
65
-# package, etc.
66
-
67
-# Build Docker as a static binary file
68
-bundle_binary() {
69
-	mkdir -p bundles/$VERSION/binary
70
-	go build -o bundles/$VERSION/binary/docker-$VERSION \
71
-		-ldflags "-X main.GITCOMMIT $GITCOMMIT -X main.VERSION $VERSION -d -w" \
72
-		./docker
73
-}
74
-
75
-
76
-# Build Docker's test suite as a collection of binary files (one per
77
-# sub-package to test)
78
-bundle_test() {
79
-	mkdir -p bundles/$VERSION/test
80
-	for test_dir in $(find_test_dirs); do
81
-		test_binary=$(
82
-			cd $test_dir
83
-			go test -c -v -ldflags "-X main.GITCOMMIT $GITCOMMIT -X main.VERSION $VERSION -d -w" >&2
84
-			find . -maxdepth 1 -type f -name '*.test' -executable
85
-		)
86
-		cp $test_dir/$test_binary bundles/$VERSION/test/
87
-	done
88
-}
89
-
90
-# Build docker as an ubuntu package using FPM and REPREPRO (sue me).
91
-# bundle_binary must be called first.
92
-bundle_ubuntu() {
93
-	mkdir -p bundles/$VERSION/ubuntu
94
-
95
-	DIR=$(pwd)/bundles/$VERSION/ubuntu/build
96
-
97
-	# Generate an upstart config file (ubuntu-specific)
98
-	mkdir -p $DIR/etc/init
99
-	echo "$UPSTART_SCRIPT" > $DIR/etc/init/docker.conf
100
-
101
-	# Copy the binary
102
-	mkdir -p $DIR/usr/bin
103
-	cp bundles/$VERSION/binary/docker-$VERSION $DIR/usr/bin/docker
104
-
105
-	# Generate postinstall/prerm scripts
106
-	cat >/tmp/postinstall <<EOF
107
-#!/bin/sh
108
-/sbin/stop docker || true
109
-/sbin/start docker
110
-EOF
111
-	cat >/tmp/prerm <<EOF
112
-#!/bin/sh
113
-/sbin/stop docker || true
114
-EOF
115
-	chmod +x /tmp/postinstall /tmp/prerm
116
-
117
-	(
118
-		cd bundles/$VERSION/ubuntu
119
-		fpm -s dir -C $DIR \
120
-		    --name lxc-docker-$VERSION --version $PKGVERSION \
121
-		    --after-install /tmp/postinstall \
122
-		    --before-remove /tmp/prerm \
123
-		    --architecture "$PACKAGE_ARCHITECTURE" \
124
-		    --prefix / \
125
-		    --depends lxc --depends aufs-tools \
126
-		    --description "$PACKAGE_DESCRIPTION" \
127
-		    --maintainer "$PACKAGE_MAINTAINER" \
128
-		    --conflicts lxc-docker-virtual-package \
129
-		    --provides lxc-docker \
130
-		    --provides lxc-docker-virtual-package \
131
-		    --replaces lxc-docker \
132
-		    --replaces lxc-docker-virtual-package \
133
-		    --url "$PACKAGE_URL" \
134
-		    --vendor "$PACKAGE_VENDOR" \
135
-		    -t deb .
136
-		mkdir empty
137
-		fpm -s dir -C empty \
138
-		    --name lxc-docker --version $PKGVERSION \
139
-		    --architecture "$PACKAGE_ARCHITECTURE" \
140
-		    --depends lxc-docker-$VERSION \
141
-		    --description "$PACKAGE_DESCRIPTION" \
142
-		    --maintainer "$PACKAGE_MAINTAINER" \
143
-		    --url "$PACKAGE_URL" \
144
-		    --vendor "$PACKAGE_VENDOR" \
145
-		    -t deb .
146
-	)
147
-}
148
-
149
-
150
-# This helper function walks the current directory looking for directories
151
-# holding Go test files, and prints their paths on standard output, one per
152
-# line.
153
-find_test_dirs() {
154
-	find . -name '*_test.go' | 
155
-		{ while read f; do dirname $f; done; } | 
156
-		sort -u
157
-}
158
-
159
-
160
-main() {
161
-	bundle_binary
162
-	bundle_ubuntu
163
-	#bundle_test
164
-	cat <<EOF
165
-###############################################################################
166
-Now run the resulting image, making sure that you set AWS_S3_BUCKET,
167
-AWS_ACCESS_KEY, and AWS_SECRET_KEY environment variables:
168
-
169
-docker run -e AWS_S3_BUCKET=get-staging.docker.io \\
170
-              AWS_ACCESS_KEY=AKI1234... \\
171
-              AWS_SECRET_KEY=sEs3mE... \\
172
-              GPG_PASSPHRASE=sesame... \\
173
-              image_id_or_name
174
-###############################################################################
175
-EOF
176
-}
177
-
178
-main
179 1
deleted file mode 100755
... ...
@@ -1,176 +0,0 @@
1
-#!/bin/sh
2
-
3
-# This script looks for bundles built by make.sh, and releases them on a
4
-# public S3 bucket.
5
-#
6
-# Bundles should be available for the VERSION string passed as argument.
7
-#
8
-# The correct way to call this script is inside a container built by the
9
-# official Dockerfile at the root of the Docker source code. The Dockerfile,
10
-# make.sh and release.sh should all be from the same source code revision.
11
-
12
-set -x
13
-set -e
14
-
15
-# Print a usage message and exit.
16
-usage() {
17
-	cat <<EOF
18
-To run, I need:
19
-- to be in a container generated by the Dockerfile at the top of the Docker
20
-  repository;
21
-- to be provided with the name of an S3 bucket, in environment variable
22
-  AWS_S3_BUCKET;
23
-- to be provided with AWS credentials for this S3 bucket, in environment
24
-  variables AWS_ACCESS_KEY and AWS_SECRET_KEY;
25
-- the passphrase to unlock the GPG key which will sign the deb packages
26
-  (passed as environment variable GPG_PASSPHRASE);
27
-- a generous amount of good will and nice manners.
28
-The canonical way to run me is to run the image produced by the Dockerfile: e.g.:"
29
-
30
-docker run -e AWS_S3_BUCKET=get-staging.docker.io \\
31
-              AWS_ACCESS_KEY=AKI1234... \\
32
-              AWS_SECRET_KEY=sEs4mE... \\
33
-              GPG_PASSPHRASE=m0resEs4mE... \\
34
-              f0058411
35
-EOF
36
-	exit 1
37
-}
38
-
39
-[ "$AWS_S3_BUCKET" ] || usage
40
-[ "$AWS_ACCESS_KEY" ] || usage
41
-[ "$AWS_SECRET_KEY" ] || usage
42
-[ "$GPG_PASSPHRASE" ] || usage
43
-[ -d /go/src/github.com/dotcloud/docker/ ] || usage
44
-cd /go/src/github.com/dotcloud/docker/ 
45
-
46
-VERSION=$(cat VERSION)
47
-BUCKET=$AWS_S3_BUCKET
48
-
49
-setup_s3() {
50
-	# Try creating the bucket. Ignore errors (it might already exist).
51
-	s3cmd mb s3://$BUCKET 2>/dev/null || true
52
-	# Check access to the bucket.
53
-	# s3cmd has no useful exit status, so we cannot check that.
54
-	# Instead, we check if it outputs anything on standard output.
55
-	# (When there are problems, it uses standard error instead.)
56
-	s3cmd info s3://$BUCKET | grep -q .
57
-	# Make the bucket accessible through website endpoints.
58
-	s3cmd ws-create --ws-index index --ws-error error s3://$BUCKET
59
-}
60
-
61
-# write_to_s3 uploads the contents of standard input to the specified S3 url.
62
-write_to_s3() {
63
-	DEST=$1
64
-	F=`mktemp`
65
-	cat > $F
66
-	s3cmd --acl-public put $F $DEST
67
-	rm -f $F
68
-}
69
-
70
-s3_url() {
71
-	echo "http://$BUCKET.s3.amazonaws.com"
72
-}
73
-
74
-# Upload the 'ubuntu' bundle to S3:
75
-# 1. A full APT repository is published at $BUCKET/ubuntu/
76
-# 2. Instructions for using the APT repository are uploaded at $BUCKET/ubuntu/info
77
-release_ubuntu() {
78
-	# Make sure that we have our keys
79
-	mkdir -p /.gnupg/
80
-	s3cmd sync s3://$BUCKET/ubuntu/.gnupg/ /.gnupg/ || true
81
-	gpg --list-keys releasedocker >/dev/null || {
82
-		gpg --gen-key --batch <<EOF   
83
-Key-Type: RSA
84
-Key-Length: 2048
85
-Passphrase: $GPG_PASSPHRASE
86
-Name-Real: Docker Release Tool
87
-Name-Email: docker@dotcloud.com
88
-Name-Comment: releasedocker
89
-Expire-Date: 0
90
-%commit
91
-EOF
92
-	}
93
-
94
-	# Sign our packages
95
-	dpkg-sig -g "--passphrase $GPG_PASSPHRASE" -k releasedocker \
96
-		 --sign builder bundles/$VERSION/ubuntu/*.deb
97
-
98
-	# Setup the APT repo
99
-	APTDIR=bundles/$VERSION/ubuntu/apt
100
-	mkdir -p $APTDIR/conf $APTDIR/db
101
-	s3cmd sync s3://$BUCKET/ubuntu/db/ $APTDIR/db/ || true
102
-	cat > $APTDIR/conf/distributions <<EOF
103
-Codename: docker
104
-Components: main
105
-Architectures: amd64 i386
106
-EOF
107
-
108
-	# Add the DEB package to the APT repo
109
-	DEBFILE=bundles/$VERSION/ubuntu/lxc-docker*.deb
110
-	reprepro -b $APTDIR includedeb docker $DEBFILE
111
-
112
-	# Sign
113
-	for F in $(find $APTDIR -name Release)
114
-	do
115
-		gpg -u releasedocker --passphrase $GPG_PASSPHRASE \
116
-			--armor --sign --detach-sign \
117
-			--output $F.gpg $F
118
-	done
119
-
120
-	# Upload keys
121
-	s3cmd sync /.gnupg/ s3://$BUCKET/ubuntu/.gnupg/
122
-	gpg --armor --export releasedocker > bundles/$VERSION/ubuntu/gpg
123
-	s3cmd --acl-public put bundles/$VERSION/ubuntu/gpg s3://$BUCKET/gpg
124
-
125
-	# Upload repo
126
-	s3cmd --acl-public sync $APTDIR/ s3://$BUCKET/ubuntu/
127
-	cat <<EOF | write_to_s3 s3://$BUCKET/ubuntu/info
128
-# Add the repository to your APT sources
129
-echo deb $(s3_url $BUCKET)/ubuntu docker main > /etc/apt/sources.list.d/docker.list
130
-# Then import the repository key
131
-curl $(s3_url $BUCKET)/gpg | apt-key add -
132
-# Install docker
133
-apt-get update ; apt-get install -y lxc-docker
134
-EOF
135
-	echo "APT repository uploaded. Instructions available at $(s3_url $BUCKET)/ubuntu/info"
136
-}
137
-
138
-# Upload a static binary to S3
139
-release_binary() {
140
-	[ -e bundles/$VERSION ]
141
-	S3DIR=s3://$BUCKET/builds/Linux/x86_64
142
-	s3cmd --acl-public put bundles/$VERSION/binary/docker-$VERSION $S3DIR/docker-$VERSION
143
-	cat <<EOF | write_to_s3 s3://$BUCKET/builds/info
144
-# To install, run the following command as root:
145
-curl -O http://$BUCKET.s3.amazonaws.com/builds/Linux/x86_64/docker-$VERSION && chmod +x docker-$VERSION && sudo mv docker-$VERSION /usr/local/bin/docker
146
-# Then start docker in daemon mode:
147
-sudo /usr/local/bin/docker -d
148
-EOF
149
-	if [ -z "$NOLATEST" ]; then
150
-		echo "Copying docker-$VERSION to docker-latest"
151
-		s3cmd --acl-public cp $S3DIR/docker-$VERSION $S3DIR/docker-latest
152
-		echo "Advertising $VERSION on $BUCKET as most recent version"
153
-		echo $VERSION | write_to_s3 s3://$BUCKET/latest
154
-	fi
155
-}
156
-
157
-# Upload the index script
158
-release_index() {
159
-	(
160
-	if [ "$BUCKET" != "get.docker.io" ]
161
-	then
162
-		sed s,https://get.docker.io/,http://$BUCKET.s3.amazonaws.com/, contrib/install.sh
163
-	else
164
-		cat contrib/install.sh
165
-	fi
166
-	) | write_to_s3 s3://$BUCKET/index
167
-}
168
-
169
-main() {
170
-	setup_s3
171
-	release_binary
172
-	release_ubuntu
173
-	release_index
174
-}
175
-
176
-main