Browse code

Merge pull request #19013 from hqhq/add_support_docker_aarch64

Add support for build and test docker on arm64

Jess Frazelle authored on 2016/01/27 03:33:48
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,183 @@
0
+# This file describes the standard way to build Docker on aarch64, using docker
1
+#
2
+# Usage:
3
+#
4
+# # Assemble the full dev environment. This is slow the first time.
5
+# docker build -t docker -f Dockerfile.aarch64 .
6
+#
7
+# # Mount your source in an interactive container for quick testing:
8
+# docker run -v `pwd`:/go/src/github.com/docker/docker --privileged -i -t docker bash
9
+#
10
+# # Run the test suite:
11
+# docker run --privileged docker hack/make.sh test
12
+#
13
+# # Publish a release:
14
+# docker run --privileged \
15
+#  -e AWS_S3_BUCKET=baz \
16
+#  -e AWS_ACCESS_KEY=foo \
17
+#  -e AWS_SECRET_KEY=bar \
18
+#  -e GPG_PASSPHRASE=gloubiboulga \
19
+#  docker hack/release.sh
20
+#
21
+# Note: AppArmor used to mess with privileged mode, but this is no longer
22
+# the case. Therefore, you don't have to disable it anymore.
23
+#
24
+
25
+FROM aarch64/ubuntu:trusty
26
+
27
+# Packaged dependencies
28
+RUN apt-get update && apt-get install -y \
29
+	apparmor \
30
+	aufs-tools \
31
+	automake \
32
+	bash-completion \
33
+	btrfs-tools \
34
+	build-essential \
35
+	createrepo \
36
+	curl \
37
+	dpkg-sig \
38
+	g++ \
39
+	gcc \
40
+	git \
41
+	iptables \
42
+	jq \
43
+	libapparmor-dev \
44
+	libc6-dev \
45
+	libcap-dev \
46
+	libsqlite3-dev \
47
+	libsystemd-journal-dev \
48
+	mercurial \
49
+	parallel \
50
+	pkg-config \
51
+	python-dev \
52
+	python-mock \
53
+	python-pip \
54
+	python-websocket \
55
+	s3cmd=1.1.0* \
56
+	--no-install-recommends
57
+
58
+# Install armhf loader to use armv6 binaries on armv8
59
+RUN dpkg --add-architecture armhf \
60
+	&& apt-get update \
61
+	&& apt-get install -y libc6:armhf
62
+
63
+# Get lvm2 source for compiling statically
64
+ENV LVM2_VERSION 2.02.103
65
+RUN mkdir -p /usr/local/lvm2 \
66
+	&& curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \
67
+		| tar -xzC /usr/local/lvm2 --strip-components=1
68
+# see https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags
69
+
70
+# fix platform enablement in lvm2 to support aarch64 properly
71
+RUN set -e \
72
+	&& for f in config.guess config.sub; do \
73
+		curl -fsSL -o "/usr/local/lvm2/autoconf/$f" "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=$f;hb=HEAD"; \
74
+	done
75
+# "arch.c:78:2: error: #error the arch code needs to know about your machine type"
76
+
77
+# Compile and install lvm2
78
+RUN cd /usr/local/lvm2 \
79
+	&& ./configure \
80
+		--build="$(gcc -print-multiarch)" \
81
+		--enable-static_link \
82
+	&& make device-mapper \
83
+	&& make install_device-mapper
84
+# see https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL
85
+
86
+# Install Go
87
+# We don't have official binary tarballs for ARM64, eigher for Go or bootstrap,
88
+# so we use the official armv6 released binaries as a GOROOT_BOOTSTRAP, and
89
+# build Go from source code.
90
+ENV BOOT_STRAP_VERSION 1.6beta1
91
+ENV GO_VERSION 1.5.3
92
+RUN mkdir -p /usr/src/go-bootstrap \
93
+	&& curl -fsSL https://storage.googleapis.com/golang/go${BOOT_STRAP_VERSION}.linux-arm6.tar.gz | tar -v -C /usr/src/go-bootstrap -xz --strip-components=1 \
94
+	&& mkdir /usr/src/go \
95
+	&& curl -fsSL https://storage.googleapis.com/golang/go${GO_VERSION}.src.tar.gz | tar -v -C /usr/src/go -xz --strip-components=1 \
96
+	&& cd /usr/src/go/src \
97
+	&& GOOS=linux GOARCH=arm64 GOROOT_BOOTSTRAP=/usr/src/go-bootstrap ./make.bash
98
+ENV PATH /usr/src/go/bin:$PATH
99
+ENV GOPATH /go:/go/src/github.com/docker/docker/vendor
100
+
101
+# Install registry
102
+ENV REGISTRY_COMMIT a7ae88da459b98b481a245e5b1750134724ac67d
103
+RUN set -x \
104
+	&& export GOPATH="$(mktemp -d)" \
105
+	&& git clone https://github.com/docker/distribution.git "$GOPATH/src/github.com/docker/distribution" \
106
+	&& (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT") \
107
+	&& GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \
108
+		go build -o /usr/local/bin/registry-v2 github.com/docker/distribution/cmd/registry \
109
+	&& rm -rf "$GOPATH"
110
+
111
+# Install notary server
112
+ENV NOTARY_COMMIT 0c11a970826e62479379ccc75a45184460b9200f
113
+RUN set -x \
114
+	&& export GOPATH="$(mktemp -d)" \
115
+	&& git clone https://github.com/docker/notary.git "$GOPATH/src/github.com/docker/notary" \
116
+	&& (cd "$GOPATH/src/github.com/docker/notary" && git checkout -q "$NOTARY_COMMIT") \
117
+	&& GOPATH="$GOPATH/src/github.com/docker/notary/Godeps/_workspace:$GOPATH" \
118
+		go build -o /usr/local/bin/notary-server github.com/docker/notary/cmd/notary-server \
119
+	&& rm -rf "$GOPATH"
120
+
121
+# Get the "docker-py" source so we can run their integration tests
122
+ENV DOCKER_PY_COMMIT 57512760c83fbe41302891aa51e34a86f4db74de
123
+RUN git clone https://github.com/docker/docker-py.git /docker-py \
124
+	&& cd /docker-py \
125
+	&& git checkout -q $DOCKER_PY_COMMIT \
126
+	&& pip install -r test-requirements.txt
127
+
128
+# Setup s3cmd config
129
+RUN { \
130
+		echo '[default]'; \
131
+		echo 'access_key=$AWS_ACCESS_KEY'; \
132
+		echo 'secret_key=$AWS_SECRET_KEY'; \
133
+	} > ~/.s3cfg
134
+
135
+# Set user.email so crosbymichael's in-container merge commits go smoothly
136
+RUN git config --global user.email 'docker-dummy@example.com'
137
+
138
+# Add an unprivileged user to be used for tests which need it
139
+RUN groupadd -r docker
140
+RUN useradd --create-home --gid docker unprivilegeduser
141
+
142
+VOLUME /var/lib/docker
143
+WORKDIR /go/src/github.com/docker/docker
144
+ENV DOCKER_BUILDTAGS apparmor selinux
145
+
146
+# Let us use a .bashrc file
147
+RUN ln -sfv $PWD/.bashrc ~/.bashrc
148
+
149
+# Register Docker's bash completion.
150
+RUN ln -sv $PWD/contrib/completion/bash/docker /etc/bash_completion.d/docker
151
+
152
+# Get useful and necessary Hub images so we can "docker load" locally instead of pulling
153
+COPY contrib/download-frozen-image-v2.sh /go/src/github.com/docker/docker/contrib/
154
+RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \
155
+	aarch64/busybox:latest@sha256:b23a6a37cf269dff6e46d2473b6e227afa42b037e6d23435f1d2bc40fc8c2828 \
156
+	aarch64/debian:jessie@sha256:4be74a41a7c70ebe887b634b11ffe516cf4fcd56864a54941e56bb49883c3170 \
157
+	aarch64/hello-world:latest@sha256:65a4a158587b307bb02db4de41b836addb0c35175bdc801367b1ac1ddeb9afda
158
+# see also "hack/make/.ensure-frozen-images" (which needs to be updated any time this list is)
159
+
160
+# Download man page generator
161
+RUN set -x \
162
+	&& export GOPATH="$(mktemp -d)" \
163
+	&& git clone -b v1.0.4 https://github.com/cpuguy83/go-md2man.git "$GOPATH/src/github.com/cpuguy83/go-md2man" \
164
+	&& git clone -b v1.4 https://github.com/russross/blackfriday.git "$GOPATH/src/github.com/russross/blackfriday" \
165
+	&& go get -v -d github.com/cpuguy83/go-md2man \
166
+	&& go build -v -o /usr/local/bin/go-md2man github.com/cpuguy83/go-md2man \
167
+	&& rm -rf "$GOPATH"
168
+
169
+# Download toml validator
170
+ENV TOMLV_COMMIT 9baf8a8a9f2ed20a8e54160840c492f937eeaf9a
171
+RUN set -x \
172
+	&& export GOPATH="$(mktemp -d)" \
173
+	&& git clone https://github.com/BurntSushi/toml.git "$GOPATH/src/github.com/BurntSushi/toml" \
174
+	&& (cd "$GOPATH/src/github.com/BurntSushi/toml" && git checkout -q "$TOMLV_COMMIT") \
175
+	&& go build -v -o /usr/local/bin/tomlv github.com/BurntSushi/toml/cmd/tomlv \
176
+	&& rm -rf "$GOPATH"
177
+
178
+# Wrap all commands in the "docker-in-docker" script to allow nested containers
179
+ENTRYPOINT ["hack/dind"]
180
+
181
+# Upload docker source
182
+COPY . /go/src/github.com/docker/docker
... ...
@@ -9,8 +9,7 @@ ifeq ($(DOCKER_OSARCH), linux/arm)
9 9
 	DOCKERFILE := Dockerfile.armhf
10 10
 else
11 11
 ifeq ($(DOCKER_OSARCH), linux/arm64)
12
-	# TODO .arm64
13
-	DOCKERFILE := Dockerfile.armhf
12
+	DOCKERFILE := Dockerfile.aarch64
14 13
 else
15 14
 ifeq ($(DOCKER_OSARCH), linux/ppc64le)
16 15
 	DOCKERFILE := Dockerfile.ppc64le
... ...
@@ -14,6 +14,9 @@ case "$DOCKER_ENGINE_OSARCH" in
14 14
 	linux/arm)
15 15
 		imagePrefix='armhf'
16 16
 		;;
17
+	linux/arm64)
18
+		imagePrefix='aarch64'
19
+		;;
17 20
 	linux/ppc64le)
18 21
 		imagePrefix='ppc64le'
19 22
 		;;