Browse code

release.sh: publish a full release of docker to a S3 bucket, including static binary and a full APT repository with install instructions

Solomon Hykes authored on 2013/08/07 13:16:13
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,81 @@
0
+#!/bin/sh
1
+
2
+# This script looks for bundles built by make.sh, and releases them on a public S3 bucket.
3
+#
4
+# Bundles should be available for the VERSION string passed as argument.
5
+#
6
+# The correct way to call this script is inside a container built by the official Dockerfile
7
+# at the root of the docker source code. The Dockerfile, make.sh and release.sh should all
8
+# be from the same source code revision.
9
+
10
+set -x
11
+set -e
12
+
13
+# Print a usage message and exit.
14
+usage() {
15
+	echo "Usage: $0 VERSION BUCKET"
16
+	echo "For example: $0 0.5.1-dev sandbox.get.docker.io"
17
+	exit 1
18
+}
19
+
20
+VERSION=$1
21
+BUCKET=$2
22
+[ -z "$VERSION" ] && usage
23
+[ -z "$BUCKET" ] && usage
24
+
25
+setup_s3() {
26
+	# Try creating the bucket. Ignore errors (it might already exist).
27
+	s3cmd --acl-public mb $BUCKET 2>/dev/null || true
28
+}
29
+
30
+# write_to_s3 uploads the contents of standard input to the specified S3 url.
31
+write_to_s3() {
32
+	DEST=$1
33
+	F=`mktemp`
34
+	cat > $F
35
+	s3cmd --acl-public put $F $DEST
36
+	rm -f $F
37
+}
38
+
39
+s3_url() {
40
+	echo "http://$BUCKET.s3.amazonaws.com"
41
+}
42
+
43
+# Upload the 'ubuntu' bundle to S3:
44
+# 1. A full APT repository is published at $BUCKET/ubuntu/
45
+# 2. Instructions for using the APT repository are uploaded at $BUCKET/ubuntu/info
46
+release_ubuntu() {
47
+	s3cmd --acl-public --verbose --delete-removed --follow-symlinks sync bundles/$VERSION/ubuntu/apt/ s3://$BUCKET/ubuntu/
48
+	cat <<EOF | write_to_s3 s3://$BUCKET/ubuntu/info
49
+# Add the following to /etc/apt/sources.list
50
+deb `s3_url $BUCKET`/ubuntu docker main
51
+EOF
52
+	echo "APT repository uploaded to http:. Instructions available at `s3_url $BUCKET`/ubuntu/info"
53
+}
54
+
55
+# Upload a static binary to S3
56
+release_binary() {
57
+	[ -e bundles/$VERSION ]
58
+	S3DIR=s3://$BUCKET/builds/Linux/x86_64
59
+	s3cmd --acl-public put bundles/$VERSION/binary/docker-$VERSION $S3DIR/docker-$VERSION
60
+	cat <<EOF | write_to_s3 s3://$BUCKET/builds/info
61
+# To install, run the following command as root:
62
+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
63
+# Then start docker in daemon mode:
64
+sudo /usr/local/bin/docker -d
65
+EOF
66
+	if [ -z "$NOLATEST" ]; then
67
+		echo "Copying docker-$VERSION to docker-latest"
68
+		s3cmd --acl-public cp $S3DIR/docker-$VERSION $S3DIR/docker-latest
69
+		echo "Advertising $VERSION on $BUCKET as most recent version"
70
+		echo $VERSION | write_to_s3 s3://$BUCKET/latest
71
+	fi
72
+}
73
+
74
+main() {
75
+	setup_s3
76
+	release_binary
77
+	release_ubuntu
78
+}
79
+
80
+main