* Hack: make the build tool more dev-friendly and packager-friendly
Solomon Hykes authored on 2013/09/14 12:19:37... | ... |
@@ -1,5 +1,29 @@ |
1 | 1 |
# This file describes the standard way to build Docker, using docker |
2 |
-docker-version 0.4.2 |
|
2 |
+# |
|
3 |
+# Usage: |
|
4 |
+# |
|
5 |
+# # Assemble the full dev environment. This is slow the first time. |
|
6 |
+# docker build -t docker . |
|
7 |
+# # Apparmor messes with privileged mode: disable it |
|
8 |
+# /etc/init.d/apparmor stop ; /etc/init.d/apparmor teardown |
|
9 |
+# |
|
10 |
+# # Mount your source in an interactive container for quick testing: |
|
11 |
+# docker run -v `pwd`:/go/src/github.com/dotcloud/docker -privileged -lxc-conf=lxc.aa_profile=unconfined -i -t docker bash |
|
12 |
+# |
|
13 |
+# |
|
14 |
+# # Run the test suite: |
|
15 |
+# docker run -privileged -lxc-conf=lxc.aa_profile=unconfined docker go test -v |
|
16 |
+# |
|
17 |
+# # Publish a release: |
|
18 |
+# docker run -privileged -lxc-conf=lxc.aa_profile=unconfined \ |
|
19 |
+# -e AWS_S3_BUCKET=baz \ |
|
20 |
+# -e AWS_ACCESS_KEY=foo \ |
|
21 |
+# -e AWS_SECRET_KEY=bar \ |
|
22 |
+# -e GPG_PASSPHRASE=gloubiboulga \ |
|
23 |
+# -lxc-conf=lxc.aa_profile=unconfined -privileged docker hack/release.sh |
|
24 |
+# |
|
25 |
+ |
|
26 |
+docker-version 0.6.1 |
|
3 | 27 |
from ubuntu:12.04 |
4 | 28 |
maintainer Solomon Hykes <solomon@dotcloud.com> |
5 | 29 |
# Build dependencies |
... | ... |
@@ -11,7 +35,7 @@ run apt-get install -y -q mercurial |
11 | 11 |
# Install Go |
12 | 12 |
run curl -s https://go.googlecode.com/files/go1.1.2.linux-amd64.tar.gz | tar -v -C /usr/local -xz |
13 | 13 |
env PATH /usr/local/go/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin |
14 |
-env GOPATH /go |
|
14 |
+env GOPATH /go:/go/src/github.com/dotcloud/docker/vendor |
|
15 | 15 |
env CGO_ENABLED 0 |
16 | 16 |
run cd /tmp && echo 'package main' > t.go && go test -a -i -v |
17 | 17 |
# Ubuntu stuff |
... | ... |
@@ -23,15 +47,12 @@ run apt-get install -y -q python-pip |
23 | 23 |
run pip install s3cmd |
24 | 24 |
run pip install python-magic |
25 | 25 |
run /bin/echo -e '[default]\naccess_key=$AWS_ACCESS_KEY\nsecret_key=$AWS_SECRET_KEY\n' > /.s3cfg |
26 |
-# Download dependencies |
|
27 |
-run PKG=github.com/kr/pty REV=27435c699; git clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && git checkout -f $REV |
|
28 |
-run PKG=github.com/gorilla/context/ REV=708054d61e5; git clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && git checkout -f $REV |
|
29 |
-run PKG=github.com/gorilla/mux/ REV=9b36453141c; git clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && git checkout -f $REV |
|
30 |
-run PKG=github.com/dotcloud/tar/ REV=e5ea6bb21a3294; git clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && git checkout -f $REV |
|
31 |
-run PKG=code.google.com/p/go.net/ REV=84a4013f96e0; hg clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && hg checkout $REV |
|
26 |
+# Runtime dependencies |
|
27 |
+run apt-get install -y -q iptables |
|
28 |
+run apt-get install -y -q lxc |
|
29 |
+volume /var/lib/docker |
|
30 |
+workdir /go/src/github.com/dotcloud/docker |
|
31 |
+# Wrap all commands in the "docker-in-docker" script to allow nested containers |
|
32 |
+entrypoint ["hack/dind"] |
|
32 | 33 |
# Upload docker source |
33 | 34 |
add . /go/src/github.com/dotcloud/docker |
34 |
-run ln -s /go/src/github.com/dotcloud/docker /src |
|
35 |
-# Build the binary |
|
36 |
-run cd /go/src/github.com/dotcloud/docker && hack/release/make.sh |
|
37 |
-cmd cd /go/src/github.com/dotcloud/docker && hack/release/release.sh |
38 | 35 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,137 @@ |
0 |
+Dear packager. |
|
1 |
+ |
|
2 |
+If you are looking to make docker available on your favorite software distribution, |
|
3 |
+this document is for you. It summarizes the requirements for building and running |
|
4 |
+docker. |
|
5 |
+ |
|
6 |
+## Getting started |
|
7 |
+ |
|
8 |
+We really want to help you package Docker successfully. Before anything, a good first step |
|
9 |
+is to introduce yourself on the [docker-dev mailing list](https://groups.google.com/forum/?fromgroups#!forum/docker-dev) |
|
10 |
+, explain what you''re trying to achieve, and tell us how we can help. Don''t worry, we don''t bite! |
|
11 |
+There might even be someone already working on packaging for the same distro! |
|
12 |
+ |
|
13 |
+You can also join the IRC channel - #docker and #docker-dev on Freenode are both active and friendly. |
|
14 |
+ |
|
15 |
+## Package name |
|
16 |
+ |
|
17 |
+If possible, your package should be called "docker". If that name is already taken, a second |
|
18 |
+choice is "lxc-docker". |
|
19 |
+ |
|
20 |
+## Official build vs distro build |
|
21 |
+ |
|
22 |
+The Docker project maintains its own build and release toolchain. It is pretty neat and entirely |
|
23 |
+based on Docker (surprise!). This toolchain is the canonical way to build Docker, and the only |
|
24 |
+method supported by the development team. We encourage you to give it a try, and if the circumstances |
|
25 |
+allow you to use it, we recommend that you do. |
|
26 |
+ |
|
27 |
+You might not be able to use the official build toolchain - usually because your distribution has a |
|
28 |
+toolchain and packaging policy of its own. We get it! Your house, your rules. The rest of this document |
|
29 |
+should give you the information you need to package Docker your way, without denaturing it in |
|
30 |
+the process. |
|
31 |
+ |
|
32 |
+## System build dependencies |
|
33 |
+ |
|
34 |
+To build docker, you will need the following system dependencies |
|
35 |
+ |
|
36 |
+* An amd64 machine |
|
37 |
+* A recent version of git and mercurial |
|
38 |
+* Go version 1.1.2 |
|
39 |
+* A clean checkout of the source must be added to a valid Go [workspace](http://golang.org/doc/code.html#Workspaces) |
|
40 |
+under the path *src/github.com/dotcloud/docker*. See |
|
41 |
+ |
|
42 |
+ |
|
43 |
+## Go dependencies |
|
44 |
+ |
|
45 |
+All Go dependencies are vendored under ./vendor. They are used by the official build, |
|
46 |
+so the source of truth for the current version is whatever is in ./vendor. |
|
47 |
+ |
|
48 |
+To use the vendored dependencies, simply make sure the path to ./vendor is included in $GOPATH. |
|
49 |
+ |
|
50 |
+If you would rather package these dependencies yourself, take a look at ./hack/vendor.sh for an |
|
51 |
+easy-to-parse list of the exact version for each. |
|
52 |
+ |
|
53 |
+NOTE: if you''re not able to package the exact version (to the exact commit) of a given dependency, |
|
54 |
+please get in touch so we can remediate! Who knows what discrepancies can be caused by even the |
|
55 |
+slightest deviation. We promise to do our best to make everybody happy. |
|
56 |
+ |
|
57 |
+ |
|
58 |
+## Disabling CGO |
|
59 |
+ |
|
60 |
+Make sure to disable CGO on your system, and then recompile the standard library on the build |
|
61 |
+machine: |
|
62 |
+ |
|
63 |
+```bash |
|
64 |
+export CGO_ENABLED=0 |
|
65 |
+cd /tmp && echo 'package main' > t.go && go test -a -i -v |
|
66 |
+``` |
|
67 |
+ |
|
68 |
+## Building Docker |
|
69 |
+ |
|
70 |
+To build the docker binary, run the following command with the source checkout as the |
|
71 |
+working directory: |
|
72 |
+ |
|
73 |
+``` |
|
74 |
+./hack/make.sh binary |
|
75 |
+``` |
|
76 |
+ |
|
77 |
+This will create a static binary under *./bundles/$VERSION/binary/docker-$VERSION*, where |
|
78 |
+*$VERSION* is the contents of the file *./VERSION*. |
|
79 |
+ |
|
80 |
+You are encouraged to use ./hack/make.sh without modification. If you must absolutely write |
|
81 |
+your own script (are you really, really sure you need to? make.sh is really not that complicated), |
|
82 |
+then please take care the respect the following: |
|
83 |
+ |
|
84 |
+* In *./hack/make.sh*: $LDFLAGS, $VERSION and $GITCOMMIT |
|
85 |
+* In *./hack/make/binary*: the exact build command to run |
|
86 |
+ |
|
87 |
+You may be tempted to tweak these settings. In particular, being a rigorous maintainer, you may want |
|
88 |
+to disable static linking. Please don''t! Docker *needs* to be statically linked to function properly. |
|
89 |
+You would do the users of your distro a disservice and "void the docker warranty" by changing the flags. |
|
90 |
+ |
|
91 |
+A good comparison is Busybox: all distros package it as a statically linked binary, because it just |
|
92 |
+makes sense. Docker is the same way. |
|
93 |
+ |
|
94 |
+## Testing Docker |
|
95 |
+ |
|
96 |
+Before releasing your binary, make sure to run the tests! Run the following command with the source |
|
97 |
+checkout as the working directory: |
|
98 |
+ |
|
99 |
+```bash |
|
100 |
+./hack/make.sh test |
|
101 |
+``` |
|
102 |
+ |
|
103 |
+The test suite includes both live integration tests and unit tests, so you will need all runtime |
|
104 |
+dependencies to be installed (see below). |
|
105 |
+ |
|
106 |
+The test suite will also download a small test container, so you will need internet connectivity. |
|
107 |
+ |
|
108 |
+ |
|
109 |
+## Runtime dependencies |
|
110 |
+ |
|
111 |
+To run properly, docker needs the following software to be installed at runtime: |
|
112 |
+ |
|
113 |
+* GNU Tar version 1.26 or later |
|
114 |
+* iproute2 version 3.5 or later (build after 2012-05-21), and specifically the "ip" utility. |
|
115 |
+* iptables version 1.4 or later |
|
116 |
+* The lxc utility scripts (http://lxc.sourceforge.net) version 0.8 or later. |
|
117 |
+* Git version 1.7 or later |
|
118 |
+ |
|
119 |
+## Kernel dependencies |
|
120 |
+ |
|
121 |
+Docker in daemon mode has specific kernel requirements. For details, see |
|
122 |
+http://docs.docker.io/en/latest/installation/kernel/ |
|
123 |
+ |
|
124 |
+Note that Docker also has a client mode, which can run on virtually any linux kernel (it even builds |
|
125 |
+on OSX!). |
|
126 |
+ |
|
127 |
+## Init script |
|
128 |
+ |
|
129 |
+Docker expects to run as a daemon at machine startup. Your package will need to include a script |
|
130 |
+for your distro''s process supervisor of choice. |
|
131 |
+ |
|
132 |
+Docker should be run as root, with the following arguments: |
|
133 |
+ |
|
134 |
+``` |
|
135 |
+docker -d |
|
136 |
+``` |
0 | 137 |
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,59 @@ |
0 |
+#!/bin/bash |
|
1 |
+ |
|
2 |
+# DinD: a wrapper script which allows docker to be run inside a docker container. |
|
3 |
+# Original version by Jerome Petazzoni <jerome@dotcloud.com> |
|
4 |
+# See the blog post: http://blog.docker.io/2013/09/docker-can-now-run-within-docker/ |
|
5 |
+# |
|
6 |
+# This script should be executed inside a docker container in privilieged mode |
|
7 |
+# ('docker run -privileged', introduced in docker 0.6). |
|
8 |
+ |
|
9 |
+# Usage: dind CMD [ARG...] |
|
10 |
+ |
|
11 |
+# First, make sure that cgroups are mounted correctly. |
|
12 |
+CGROUP=/sys/fs/cgroup |
|
13 |
+ |
|
14 |
+[ -d $CGROUP ] || |
|
15 |
+ mkdir $CGROUP |
|
16 |
+ |
|
17 |
+mountpoint -q $CGROUP || |
|
18 |
+ mount -n -t tmpfs -o uid=0,gid=0,mode=0755 cgroup $CGROUP || { |
|
19 |
+ echo "Could not make a tmpfs mount. Did you use -privileged?" |
|
20 |
+ exit 1 |
|
21 |
+ } |
|
22 |
+ |
|
23 |
+# Mount the cgroup hierarchies exactly as they are in the parent system. |
|
24 |
+for SUBSYS in $(cut -d: -f2 /proc/1/cgroup) |
|
25 |
+do |
|
26 |
+ [ -d $CGROUP/$SUBSYS ] || mkdir $CGROUP/$SUBSYS |
|
27 |
+ mountpoint -q $CGROUP/$SUBSYS || |
|
28 |
+ mount -n -t cgroup -o $SUBSYS cgroup $CGROUP/$SUBSYS |
|
29 |
+done |
|
30 |
+ |
|
31 |
+# Note: as I write those lines, the LXC userland tools cannot setup |
|
32 |
+# a "sub-container" properly if the "devices" cgroup is not in its |
|
33 |
+# own hierarchy. Let's detect this and issue a warning. |
|
34 |
+grep -q :devices: /proc/1/cgroup || |
|
35 |
+ echo "WARNING: the 'devices' cgroup should be in its own hierarchy." |
|
36 |
+grep -qw devices /proc/1/cgroup || |
|
37 |
+ echo "WARNING: it looks like the 'devices' cgroup is not mounted." |
|
38 |
+ |
|
39 |
+# Now, close extraneous file descriptors. |
|
40 |
+pushd /proc/self/fd |
|
41 |
+for FD in * |
|
42 |
+do |
|
43 |
+ case "$FD" in |
|
44 |
+ # Keep stdin/stdout/stderr |
|
45 |
+ [012]) |
|
46 |
+ ;; |
|
47 |
+ # Nuke everything else |
|
48 |
+ *) |
|
49 |
+ eval exec "$FD>&-" |
|
50 |
+ ;; |
|
51 |
+ esac |
|
52 |
+done |
|
53 |
+popd |
|
54 |
+ |
|
55 |
+# Mount /tmp |
|
56 |
+mount -t tmpfs none /tmp |
|
57 |
+ |
|
58 |
+exec $* |
0 | 59 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,91 @@ |
0 |
+#!/bin/bash |
|
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 inside the docker container specified |
|
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, and then |
|
18 |
+# "docker run hack/make.sh" in the resulting container image. |
|
19 |
+# |
|
20 |
+ |
|
21 |
+set -e |
|
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 "# WARNING! I don't seem to be running in a docker container. |
|
28 |
+ echo "# The result of this command might be an incorrect build, and will not be officially supported." |
|
29 |
+ echo "# Try this: 'docker build -t docker . && docker run docker ./hack/make.sh' |
|
30 |
+} |
|
31 |
+ |
|
32 |
+# List of bundles to create when no argument is passed |
|
33 |
+DEFAULT_BUNDLES=( |
|
34 |
+ test |
|
35 |
+ binary |
|
36 |
+ ubuntu |
|
37 |
+) |
|
38 |
+ |
|
39 |
+VERSION=$(cat ./VERSION) |
|
40 |
+GITCOMMIT=$(git rev-parse --short HEAD) |
|
41 |
+if test -n "$(git status --porcelain)" |
|
42 |
+then |
|
43 |
+ GITCOMMIT="$GITCOMMIT-dirty" |
|
44 |
+fi |
|
45 |
+ |
|
46 |
+# Use these flags when compiling the tests and final binary |
|
47 |
+LDFLAGS="-X main.GITCOMMIT $GITCOMMIT -X main.VERSION $VERSION -d -w" |
|
48 |
+ |
|
49 |
+ |
|
50 |
+bundle() { |
|
51 |
+ bundlescript=$1 |
|
52 |
+ bundle=$(basename $bundlescript) |
|
53 |
+ echo "---> Making bundle: $bundle" |
|
54 |
+ mkdir -p bundles/$VERSION/$bundle |
|
55 |
+ source $bundlescript $(pwd)/bundles/$VERSION/$bundle |
|
56 |
+} |
|
57 |
+ |
|
58 |
+main() { |
|
59 |
+ |
|
60 |
+ # We want this to fail if the bundles already exist. |
|
61 |
+ # This is to avoid mixing bundles from different versions of the code. |
|
62 |
+ mkdir -p bundles |
|
63 |
+ if [ -e "bundles/$VERSION" ]; then |
|
64 |
+ echo "bundles/$VERSION already exists. Removing." |
|
65 |
+ rm -fr bundles/$VERSION && mkdir bundles/$VERSION || exit 1 |
|
66 |
+ fi |
|
67 |
+ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
|
68 |
+ if [ $# -lt 1 ]; then |
|
69 |
+ bundles=($DEFAULT_BUNDLES) |
|
70 |
+ else |
|
71 |
+ bundles=($@) |
|
72 |
+ fi |
|
73 |
+ for bundle in ${bundles[@]}; do |
|
74 |
+ bundle $SCRIPTDIR/make/$bundle |
|
75 |
+ done |
|
76 |
+ cat <<EOF |
|
77 |
+############################################################################### |
|
78 |
+Now run the resulting image, making sure that you set AWS_S3_BUCKET, |
|
79 |
+AWS_ACCESS_KEY, and AWS_SECRET_KEY environment variables: |
|
80 |
+ |
|
81 |
+docker run -e AWS_S3_BUCKET=get-staging.docker.io \\ |
|
82 |
+ AWS_ACCESS_KEY=AKI1234... \\ |
|
83 |
+ AWS_SECRET_KEY=sEs3mE... \\ |
|
84 |
+ GPG_PASSPHRASE=sesame... \\ |
|
85 |
+ image_id_or_name |
|
86 |
+############################################################################### |
|
87 |
+EOF |
|
88 |
+} |
|
89 |
+ |
|
90 |
+main "$@" |
0 | 91 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,17 @@ |
0 |
+This directory holds scripts called by `make.sh` in the parent directory. |
|
1 |
+ |
|
2 |
+Each script is named after the bundle it creates. |
|
3 |
+They should not be called directly - instead, pass it as argument to make.sh, for example: |
|
4 |
+ |
|
5 |
+``` |
|
6 |
+./hack/make.sh test |
|
7 |
+./hack/make.sh binary ubuntu |
|
8 |
+ |
|
9 |
+# Or to run all bundles: |
|
10 |
+./hack/make.sh |
|
11 |
+``` |
|
12 |
+ |
|
13 |
+To add a bundle: |
|
14 |
+ |
|
15 |
+* Create a shell-compatible file here |
|
16 |
+* Add it to $DEFAULT_BUNDLES in make.sh |
0 | 4 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,27 @@ |
0 |
+DEST=$1 |
|
1 |
+ |
|
2 |
+set -e |
|
3 |
+ |
|
4 |
+# Run Docker's test suite, including sub-packages, and store their output as a bundle |
|
5 |
+bundle_test() { |
|
6 |
+ { |
|
7 |
+ date |
|
8 |
+ for test_dir in $(find_test_dirs); do ( |
|
9 |
+ set -x |
|
10 |
+ cd $test_dir |
|
11 |
+ go test -v -ldflags "$LDFLAGS" |
|
12 |
+ ) done |
|
13 |
+ } 2>&1 | tee $DEST/test.log |
|
14 |
+} |
|
15 |
+ |
|
16 |
+ |
|
17 |
+# This helper function walks the current directory looking for directories |
|
18 |
+# holding Go test files, and prints their paths on standard output, one per |
|
19 |
+# line. |
|
20 |
+find_test_dirs() { |
|
21 |
+ find . -name '*_test.go' | grep -v '^./vendor' | |
|
22 |
+ { while read f; do dirname $f; done; } | |
|
23 |
+ sort -u |
|
24 |
+} |
|
25 |
+ |
|
26 |
+bundle_test |
0 | 27 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,94 @@ |
0 |
+#!/bin/sh |
|
1 |
+ |
|
2 |
+DEST=$1 |
|
3 |
+ |
|
4 |
+PKGVERSION="$VERSION" |
|
5 |
+if test -n "$(git status --porcelain)" |
|
6 |
+then |
|
7 |
+ PKGVERSION="$PKGVERSION-$(date +%Y%m%d%H%M%S)-$GITCOMMIT" |
|
8 |
+fi |
|
9 |
+ |
|
10 |
+PACKAGE_ARCHITECTURE="$(dpkg-architecture -qDEB_HOST_ARCH)" |
|
11 |
+PACKAGE_URL="http://www.docker.io/" |
|
12 |
+PACKAGE_MAINTAINER="docker@dotcloud.com" |
|
13 |
+PACKAGE_DESCRIPTION="lxc-docker is a Linux container runtime |
|
14 |
+Docker complements LXC with a high-level API which operates at the process |
|
15 |
+level. It runs unix processes with strong guarantees of isolation and |
|
16 |
+repeatability across servers. |
|
17 |
+Docker is a great building block for automating distributed systems: |
|
18 |
+large-scale web deployments, database clusters, continuous deployment systems, |
|
19 |
+private PaaS, service-oriented architectures, etc." |
|
20 |
+ |
|
21 |
+UPSTART_SCRIPT='description "Docker daemon" |
|
22 |
+ |
|
23 |
+start on filesystem and started lxc-net |
|
24 |
+stop on runlevel [!2345] |
|
25 |
+ |
|
26 |
+respawn |
|
27 |
+ |
|
28 |
+script |
|
29 |
+ /usr/bin/docker -d |
|
30 |
+end script |
|
31 |
+' |
|
32 |
+ |
|
33 |
+# Build docker as an ubuntu package using FPM and REPREPRO (sue me). |
|
34 |
+# bundle_binary must be called first. |
|
35 |
+bundle_ubuntu() { |
|
36 |
+ DIR=$DEST/build |
|
37 |
+ |
|
38 |
+ # Generate an upstart config file (ubuntu-specific) |
|
39 |
+ mkdir -p $DIR/etc/init |
|
40 |
+ echo "$UPSTART_SCRIPT" > $DIR/etc/init/docker.conf |
|
41 |
+ |
|
42 |
+ # Copy the binary |
|
43 |
+ # This will fail if the binary bundle hasn't been built |
|
44 |
+ mkdir -p $DIR/usr/bin |
|
45 |
+ # Copy the binary |
|
46 |
+ # This will fail if the binary bundle hasn't been built |
|
47 |
+ cp $DEST/../binary/docker-$VERSION $DIR/usr/bin/docker |
|
48 |
+ |
|
49 |
+ # Generate postinstall/prerm scripts |
|
50 |
+ cat >/tmp/postinstall <<EOF |
|
51 |
+#!/bin/sh |
|
52 |
+/sbin/stop docker || true |
|
53 |
+/sbin/start docker |
|
54 |
+EOF |
|
55 |
+ cat >/tmp/prerm <<EOF |
|
56 |
+#!/bin/sh |
|
57 |
+/sbin/stop docker || true |
|
58 |
+EOF |
|
59 |
+ chmod +x /tmp/postinstall /tmp/prerm |
|
60 |
+ |
|
61 |
+ ( |
|
62 |
+ cd $DEST |
|
63 |
+ fpm -s dir -C $DIR \ |
|
64 |
+ --name lxc-docker-$VERSION --version $PKGVERSION \ |
|
65 |
+ --after-install /tmp/postinstall \ |
|
66 |
+ --before-remove /tmp/prerm \ |
|
67 |
+ --architecture "$PACKAGE_ARCHITECTURE" \ |
|
68 |
+ --prefix / \ |
|
69 |
+ --depends lxc --depends aufs-tools \ |
|
70 |
+ --description "$PACKAGE_DESCRIPTION" \ |
|
71 |
+ --maintainer "$PACKAGE_MAINTAINER" \ |
|
72 |
+ --conflicts lxc-docker-virtual-package \ |
|
73 |
+ --provides lxc-docker \ |
|
74 |
+ --provides lxc-docker-virtual-package \ |
|
75 |
+ --replaces lxc-docker \ |
|
76 |
+ --replaces lxc-docker-virtual-package \ |
|
77 |
+ --url "$PACKAGE_URL" \ |
|
78 |
+ --vendor "$PACKAGE_VENDOR" \ |
|
79 |
+ -t deb . |
|
80 |
+ mkdir empty |
|
81 |
+ fpm -s dir -C empty \ |
|
82 |
+ --name lxc-docker --version $PKGVERSION \ |
|
83 |
+ --architecture "$PACKAGE_ARCHITECTURE" \ |
|
84 |
+ --depends lxc-docker-$VERSION \ |
|
85 |
+ --description "$PACKAGE_DESCRIPTION" \ |
|
86 |
+ --maintainer "$PACKAGE_MAINTAINER" \ |
|
87 |
+ --url "$PACKAGE_URL" \ |
|
88 |
+ --vendor "$PACKAGE_VENDOR" \ |
|
89 |
+ -t deb . |
|
90 |
+ ) |
|
91 |
+} |
|
92 |
+ |
|
93 |
+bundle_ubuntu |
0 | 94 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,182 @@ |
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 -e |
|
12 |
+ |
|
13 |
+# Print a usage message and exit. |
|
14 |
+usage() { |
|
15 |
+ cat <<EOF |
|
16 |
+To run, I need: |
|
17 |
+- to be in a container generated by the Dockerfile at the top of the Docker |
|
18 |
+ repository; |
|
19 |
+- to be provided with the name of an S3 bucket, in environment variable |
|
20 |
+ AWS_S3_BUCKET; |
|
21 |
+- to be provided with AWS credentials for this S3 bucket, in environment |
|
22 |
+ variables AWS_ACCESS_KEY and AWS_SECRET_KEY; |
|
23 |
+- the passphrase to unlock the GPG key which will sign the deb packages |
|
24 |
+ (passed as environment variable GPG_PASSPHRASE); |
|
25 |
+- a generous amount of good will and nice manners. |
|
26 |
+The canonical way to run me is to run the image produced by the Dockerfile: e.g.:" |
|
27 |
+ |
|
28 |
+docker run -e AWS_S3_BUCKET=get-staging.docker.io \\ |
|
29 |
+ AWS_ACCESS_KEY=AKI1234... \\ |
|
30 |
+ AWS_SECRET_KEY=sEs4mE... \\ |
|
31 |
+ GPG_PASSPHRASE=m0resEs4mE... \\ |
|
32 |
+ f0058411 |
|
33 |
+EOF |
|
34 |
+ exit 1 |
|
35 |
+} |
|
36 |
+ |
|
37 |
+[ "$AWS_S3_BUCKET" ] || usage |
|
38 |
+[ "$AWS_ACCESS_KEY" ] || usage |
|
39 |
+[ "$AWS_SECRET_KEY" ] || usage |
|
40 |
+[ "$GPG_PASSPHRASE" ] || usage |
|
41 |
+[ -d /go/src/github.com/dotcloud/docker/ ] || usage |
|
42 |
+cd /go/src/github.com/dotcloud/docker/ |
|
43 |
+ |
|
44 |
+VERSION=$(cat VERSION) |
|
45 |
+BUCKET=$AWS_S3_BUCKET |
|
46 |
+ |
|
47 |
+setup_s3() { |
|
48 |
+ # Try creating the bucket. Ignore errors (it might already exist). |
|
49 |
+ s3cmd mb s3://$BUCKET 2>/dev/null || true |
|
50 |
+ # Check access to the bucket. |
|
51 |
+ # s3cmd has no useful exit status, so we cannot check that. |
|
52 |
+ # Instead, we check if it outputs anything on standard output. |
|
53 |
+ # (When there are problems, it uses standard error instead.) |
|
54 |
+ s3cmd info s3://$BUCKET | grep -q . |
|
55 |
+ # Make the bucket accessible through website endpoints. |
|
56 |
+ s3cmd ws-create --ws-index index --ws-error error s3://$BUCKET |
|
57 |
+} |
|
58 |
+ |
|
59 |
+# write_to_s3 uploads the contents of standard input to the specified S3 url. |
|
60 |
+write_to_s3() { |
|
61 |
+ DEST=$1 |
|
62 |
+ F=`mktemp` |
|
63 |
+ cat > $F |
|
64 |
+ s3cmd --acl-public put $F $DEST |
|
65 |
+ rm -f $F |
|
66 |
+} |
|
67 |
+ |
|
68 |
+s3_url() { |
|
69 |
+ echo "http://$BUCKET.s3.amazonaws.com" |
|
70 |
+} |
|
71 |
+ |
|
72 |
+# Upload the 'ubuntu' bundle to S3: |
|
73 |
+# 1. A full APT repository is published at $BUCKET/ubuntu/ |
|
74 |
+# 2. Instructions for using the APT repository are uploaded at $BUCKET/ubuntu/info |
|
75 |
+release_ubuntu() { |
|
76 |
+ # Make sure that we have our keys |
|
77 |
+ mkdir -p /.gnupg/ |
|
78 |
+ s3cmd sync s3://$BUCKET/ubuntu/.gnupg/ /.gnupg/ || true |
|
79 |
+ gpg --list-keys releasedocker >/dev/null || { |
|
80 |
+ gpg --gen-key --batch <<EOF |
|
81 |
+Key-Type: RSA |
|
82 |
+Key-Length: 2048 |
|
83 |
+Passphrase: $GPG_PASSPHRASE |
|
84 |
+Name-Real: Docker Release Tool |
|
85 |
+Name-Email: docker@dotcloud.com |
|
86 |
+Name-Comment: releasedocker |
|
87 |
+Expire-Date: 0 |
|
88 |
+%commit |
|
89 |
+EOF |
|
90 |
+ } |
|
91 |
+ |
|
92 |
+ # Sign our packages |
|
93 |
+ dpkg-sig -g "--passphrase $GPG_PASSPHRASE" -k releasedocker \ |
|
94 |
+ --sign builder bundles/$VERSION/ubuntu/*.deb |
|
95 |
+ |
|
96 |
+ # Setup the APT repo |
|
97 |
+ APTDIR=bundles/$VERSION/ubuntu/apt |
|
98 |
+ mkdir -p $APTDIR/conf $APTDIR/db |
|
99 |
+ s3cmd sync s3://$BUCKET/ubuntu/db/ $APTDIR/db/ || true |
|
100 |
+ cat > $APTDIR/conf/distributions <<EOF |
|
101 |
+Codename: docker |
|
102 |
+Components: main |
|
103 |
+Architectures: amd64 i386 |
|
104 |
+EOF |
|
105 |
+ |
|
106 |
+ # Add the DEB package to the APT repo |
|
107 |
+ DEBFILE=bundles/$VERSION/ubuntu/lxc-docker*.deb |
|
108 |
+ reprepro -b $APTDIR includedeb docker $DEBFILE |
|
109 |
+ |
|
110 |
+ # Sign |
|
111 |
+ for F in $(find $APTDIR -name Release) |
|
112 |
+ do |
|
113 |
+ gpg -u releasedocker --passphrase $GPG_PASSPHRASE \ |
|
114 |
+ --armor --sign --detach-sign \ |
|
115 |
+ --output $F.gpg $F |
|
116 |
+ done |
|
117 |
+ |
|
118 |
+ # Upload keys |
|
119 |
+ s3cmd sync /.gnupg/ s3://$BUCKET/ubuntu/.gnupg/ |
|
120 |
+ gpg --armor --export releasedocker > bundles/$VERSION/ubuntu/gpg |
|
121 |
+ s3cmd --acl-public put bundles/$VERSION/ubuntu/gpg s3://$BUCKET/gpg |
|
122 |
+ |
|
123 |
+ # Upload repo |
|
124 |
+ s3cmd --acl-public sync $APTDIR/ s3://$BUCKET/ubuntu/ |
|
125 |
+ cat <<EOF | write_to_s3 s3://$BUCKET/ubuntu/info |
|
126 |
+# Add the repository to your APT sources |
|
127 |
+echo deb $(s3_url $BUCKET)/ubuntu docker main > /etc/apt/sources.list.d/docker.list |
|
128 |
+# Then import the repository key |
|
129 |
+curl $(s3_url $BUCKET)/gpg | apt-key add - |
|
130 |
+# Install docker |
|
131 |
+apt-get update ; apt-get install -y lxc-docker |
|
132 |
+EOF |
|
133 |
+ echo "APT repository uploaded. Instructions available at $(s3_url $BUCKET)/ubuntu/info" |
|
134 |
+} |
|
135 |
+ |
|
136 |
+# Upload a static binary to S3 |
|
137 |
+release_binary() { |
|
138 |
+ [ -e bundles/$VERSION ] |
|
139 |
+ S3DIR=s3://$BUCKET/builds/Linux/x86_64 |
|
140 |
+ s3cmd --acl-public put bundles/$VERSION/binary/docker-$VERSION $S3DIR/docker-$VERSION |
|
141 |
+ cat <<EOF | write_to_s3 s3://$BUCKET/builds/info |
|
142 |
+# To install, run the following command as root: |
|
143 |
+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 |
|
144 |
+# Then start docker in daemon mode: |
|
145 |
+sudo /usr/local/bin/docker -d |
|
146 |
+EOF |
|
147 |
+ if [ -z "$NOLATEST" ]; then |
|
148 |
+ echo "Copying docker-$VERSION to docker-latest" |
|
149 |
+ s3cmd --acl-public cp $S3DIR/docker-$VERSION $S3DIR/docker-latest |
|
150 |
+ echo "Advertising $VERSION on $BUCKET as most recent version" |
|
151 |
+ echo $VERSION | write_to_s3 s3://$BUCKET/latest |
|
152 |
+ fi |
|
153 |
+} |
|
154 |
+ |
|
155 |
+# Upload the index script |
|
156 |
+release_index() { |
|
157 |
+ ( |
|
158 |
+ if [ "$BUCKET" != "get.docker.io" ] |
|
159 |
+ then |
|
160 |
+ sed s,https://get.docker.io/,http://$BUCKET.s3.amazonaws.com/, contrib/install.sh |
|
161 |
+ else |
|
162 |
+ cat contrib/install.sh |
|
163 |
+ fi |
|
164 |
+ ) | write_to_s3 s3://$BUCKET/index |
|
165 |
+} |
|
166 |
+ |
|
167 |
+release_test() { |
|
168 |
+ if [ -e "bundles/$VERSION/test" ]; then |
|
169 |
+ s3cmd --acl-public sync bundles/$VERSION/test/ s3://$BUCKET/test/ |
|
170 |
+ fi |
|
171 |
+} |
|
172 |
+ |
|
173 |
+main() { |
|
174 |
+ setup_s3 |
|
175 |
+ release_binary |
|
176 |
+ release_ubuntu |
|
177 |
+ release_index |
|
178 |
+ release_test |
|
179 |
+} |
|
180 |
+ |
|
181 |
+main |
0 | 182 |
deleted file mode 100644 |
... | ... |
@@ -1,106 +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 |
|
6 |
-to keep it 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 |
|
41 |
- end-user, using the present tense. Changes should be described in terms |
|
42 |
- of how they affect the user, for example "new feature X which allows Y", |
|
43 |
- "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 |
|
49 |
- container. |
|
50 |
-* Runtime: improve detection of kernel version |
|
51 |
-- Remote API: fix a bug in the optional unix socket transport |
|
52 |
-``` |
|
53 |
- |
|
54 |
-### 3. Change the contents of the VERSION file |
|
55 |
- |
|
56 |
-### 4. Run all tests |
|
57 |
- |
|
58 |
-```bash |
|
59 |
-go test |
|
60 |
-``` |
|
61 |
- |
|
62 |
-### 5. Commit and create a pull request |
|
63 |
- |
|
64 |
-```bash |
|
65 |
-git add CHANGELOG.md |
|
66 |
-git commit -m "Bump version to $VERSION" |
|
67 |
-git push origin bump_$VERSION |
|
68 |
-``` |
|
69 |
- |
|
70 |
-### 6. Get 2 other maintainers to validate the pull request |
|
71 |
- |
|
72 |
-### 7. Merge the pull request and apply tags |
|
73 |
- |
|
74 |
-```bash |
|
75 |
-git checkout master |
|
76 |
-git merge bump_$VERSION |
|
77 |
-git tag -a v$VERSION # Don't forget the v! |
|
78 |
-git tag -f -a latest |
|
79 |
-git push |
|
80 |
-git push --tags |
|
81 |
-``` |
|
82 |
- |
|
83 |
-### 8. Publish binaries |
|
84 |
- |
|
85 |
-To run this you will need access to the release credentials. |
|
86 |
-Get them from [the infrastructure maintainers]( |
|
87 |
-https://github.com/dotcloud/docker/blob/master/hack/infrastructure/MAINTAINERS). |
|
88 |
- |
|
89 |
-```bash |
|
90 |
-docker build -t releasedocker . |
|
91 |
-docker run \ |
|
92 |
- -e AWS_S3_BUCKET=get-nightly.docker.io \ |
|
93 |
- -e AWS_ACCESS_KEY=$(cat ~/.aws/access_key) \ |
|
94 |
- -e AWS_SECRET_KEY=$(cat ~/.aws/secret_key) \ |
|
95 |
- -e GPG_PASSPHRASE=supersecretsesame \ |
|
96 |
- releasedocker |
|
97 |
-``` |
|
98 |
- |
|
99 |
-It will build and upload the binaries on the specified bucket (you should |
|
100 |
-use get-nightly.docker.io for general testing, and once everything is fine, |
|
101 |
-switch to get.docker.io). |
|
102 |
- |
|
103 |
- |
|
104 |
-### 9. Rejoice! |
|
105 |
- |
|
106 |
-Congratulations! You're done. |
107 | 1 |
deleted file mode 100755 |
... | ... |
@@ -1,179 +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 |
- |
|
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 and started lxc-net |
|
56 |
-stop on runlevel [!2345] |
|
57 |
- |
|
58 |
-respawn |
|
59 |
- |
|
60 |
-script |
|
61 |
- /usr/bin/docker -d |
|
62 |
-end script |
|
63 |
-' |
|
64 |
- |
|
65 |
-# Each "bundle" is a different type of build artefact: static binary, Ubuntu |
|
66 |
-# package, etc. |
|
67 |
- |
|
68 |
-# Build Docker as a static binary file |
|
69 |
-bundle_binary() { |
|
70 |
- mkdir -p bundles/$VERSION/binary |
|
71 |
- go build -o bundles/$VERSION/binary/docker-$VERSION \ |
|
72 |
- -ldflags "-X main.GITCOMMIT $GITCOMMIT -X main.VERSION $VERSION -d -w" \ |
|
73 |
- ./docker |
|
74 |
-} |
|
75 |
- |
|
76 |
- |
|
77 |
-# Build Docker's test suite as a collection of binary files (one per |
|
78 |
-# sub-package to test) |
|
79 |
-bundle_test() { |
|
80 |
- mkdir -p bundles/$VERSION/test |
|
81 |
- for test_dir in $(find_test_dirs); do |
|
82 |
- test_binary=$( |
|
83 |
- cd $test_dir |
|
84 |
- go test -c -v -ldflags "-X main.GITCOMMIT $GITCOMMIT -X main.VERSION $VERSION -d -w" >&2 |
|
85 |
- find . -maxdepth 1 -type f -name '*.test' -executable |
|
86 |
- ) |
|
87 |
- cp $test_dir/$test_binary bundles/$VERSION/test/ |
|
88 |
- done |
|
89 |
-} |
|
90 |
- |
|
91 |
-# Build docker as an ubuntu package using FPM and REPREPRO (sue me). |
|
92 |
-# bundle_binary must be called first. |
|
93 |
-bundle_ubuntu() { |
|
94 |
- mkdir -p bundles/$VERSION/ubuntu |
|
95 |
- |
|
96 |
- DIR=$(pwd)/bundles/$VERSION/ubuntu/build |
|
97 |
- |
|
98 |
- # Generate an upstart config file (ubuntu-specific) |
|
99 |
- mkdir -p $DIR/etc/init |
|
100 |
- echo "$UPSTART_SCRIPT" > $DIR/etc/init/docker.conf |
|
101 |
- |
|
102 |
- # Copy the binary |
|
103 |
- mkdir -p $DIR/usr/bin |
|
104 |
- cp bundles/$VERSION/binary/docker-$VERSION $DIR/usr/bin/docker |
|
105 |
- |
|
106 |
- # Generate postinstall/prerm scripts |
|
107 |
- cat >/tmp/postinstall <<EOF |
|
108 |
-#!/bin/sh |
|
109 |
-/sbin/stop docker || true |
|
110 |
-/sbin/start docker |
|
111 |
-EOF |
|
112 |
- cat >/tmp/prerm <<EOF |
|
113 |
-#!/bin/sh |
|
114 |
-/sbin/stop docker || true |
|
115 |
-EOF |
|
116 |
- chmod +x /tmp/postinstall /tmp/prerm |
|
117 |
- |
|
118 |
- ( |
|
119 |
- cd bundles/$VERSION/ubuntu |
|
120 |
- fpm -s dir -C $DIR \ |
|
121 |
- --name lxc-docker-$VERSION --version $PKGVERSION \ |
|
122 |
- --after-install /tmp/postinstall \ |
|
123 |
- --before-remove /tmp/prerm \ |
|
124 |
- --architecture "$PACKAGE_ARCHITECTURE" \ |
|
125 |
- --prefix / \ |
|
126 |
- --depends lxc --depends aufs-tools \ |
|
127 |
- --description "$PACKAGE_DESCRIPTION" \ |
|
128 |
- --maintainer "$PACKAGE_MAINTAINER" \ |
|
129 |
- --conflicts lxc-docker-virtual-package \ |
|
130 |
- --provides lxc-docker \ |
|
131 |
- --provides lxc-docker-virtual-package \ |
|
132 |
- --replaces lxc-docker \ |
|
133 |
- --replaces lxc-docker-virtual-package \ |
|
134 |
- --url "$PACKAGE_URL" \ |
|
135 |
- --vendor "$PACKAGE_VENDOR" \ |
|
136 |
- -t deb . |
|
137 |
- mkdir empty |
|
138 |
- fpm -s dir -C empty \ |
|
139 |
- --name lxc-docker --version $PKGVERSION \ |
|
140 |
- --architecture "$PACKAGE_ARCHITECTURE" \ |
|
141 |
- --depends lxc-docker-$VERSION \ |
|
142 |
- --description "$PACKAGE_DESCRIPTION" \ |
|
143 |
- --maintainer "$PACKAGE_MAINTAINER" \ |
|
144 |
- --url "$PACKAGE_URL" \ |
|
145 |
- --vendor "$PACKAGE_VENDOR" \ |
|
146 |
- -t deb . |
|
147 |
- ) |
|
148 |
-} |
|
149 |
- |
|
150 |
- |
|
151 |
-# This helper function walks the current directory looking for directories |
|
152 |
-# holding Go test files, and prints their paths on standard output, one per |
|
153 |
-# line. |
|
154 |
-find_test_dirs() { |
|
155 |
- find . -name '*_test.go' | |
|
156 |
- { while read f; do dirname $f; done; } | |
|
157 |
- sort -u |
|
158 |
-} |
|
159 |
- |
|
160 |
- |
|
161 |
-main() { |
|
162 |
- bundle_binary |
|
163 |
- bundle_ubuntu |
|
164 |
- #bundle_test |
|
165 |
- cat <<EOF |
|
166 |
-############################################################################### |
|
167 |
-Now run the resulting image, making sure that you set AWS_S3_BUCKET, |
|
168 |
-AWS_ACCESS_KEY, and AWS_SECRET_KEY environment variables: |
|
169 |
- |
|
170 |
-docker run -e AWS_S3_BUCKET=get-staging.docker.io \\ |
|
171 |
- AWS_ACCESS_KEY=AKI1234... \\ |
|
172 |
- AWS_SECRET_KEY=sEs3mE... \\ |
|
173 |
- GPG_PASSPHRASE=sesame... \\ |
|
174 |
- image_id_or_name |
|
175 |
-############################################################################### |
|
176 |
-EOF |
|
177 |
-} |
|
178 |
- |
|
179 |
-main |
180 | 1 |
deleted file mode 100755 |
... | ... |
@@ -1,175 +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 -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 |
176 | 1 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,41 @@ |
0 |
+#!/bin/bash |
|
1 |
+ |
|
2 |
+# Downloads dependencies into vendor/ directory |
|
3 |
+if [[ ! -d vendor ]]; then |
|
4 |
+ mkdir vendor |
|
5 |
+fi |
|
6 |
+vendor_dir=${PWD}/vendor |
|
7 |
+ |
|
8 |
+git_clone () { |
|
9 |
+ PKG=$1 |
|
10 |
+ REV=$2 |
|
11 |
+ ( |
|
12 |
+ set -e |
|
13 |
+ cd $vendor_dir |
|
14 |
+ if [[ -d src/$PKG ]]; then |
|
15 |
+ echo "src/$PKG already exists. Removing." |
|
16 |
+ rm -fr src/$PKG |
|
17 |
+ fi |
|
18 |
+ cd $vendor_dir && git clone http://$PKG src/$PKG |
|
19 |
+ cd src/$PKG && git checkout -f $REV && rm -fr .git |
|
20 |
+ ) |
|
21 |
+} |
|
22 |
+ |
|
23 |
+git_clone github.com/kr/pty 27435c699 |
|
24 |
+ |
|
25 |
+git_clone github.com/gorilla/context/ 708054d61e5 |
|
26 |
+ |
|
27 |
+git_clone github.com/gorilla/mux/ 9b36453141c |
|
28 |
+ |
|
29 |
+git_clone github.com/dotcloud/tar/ d06045a6d9 |
|
30 |
+ |
|
31 |
+# Docker requires code.google.com/p/go.net/websocket |
|
32 |
+PKG=code.google.com/p/go.net REV=84a4013f96e0 |
|
33 |
+( |
|
34 |
+ set -e |
|
35 |
+ cd $vendor_dir |
|
36 |
+ if [[ ! -d src/$PKG ]]; then |
|
37 |
+ hg clone https://$PKG src/$PKG |
|
38 |
+ fi |
|
39 |
+ cd src/$PKG && hg checkout -r $REV |
|
40 |
+) |