Browse code

update for mac

Signed-off-by: Jessica Frazelle <acidburn@docker.com>

Jessica Frazelle authored on 2015/11/09 10:59:09
Showing 2 changed files
... ...
@@ -26,9 +26,14 @@
26 26
 FROM ubuntu:14.04
27 27
 MAINTAINER Tianon Gravi <admwiggin@gmail.com> (@tianon)
28 28
 
29
+# add zfs ppa
29 30
 RUN	apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys E871F18B51E0147C77796AC81196BA81F6B0FC61
30 31
 RUN	echo deb http://ppa.launchpad.net/zfs-native/stable/ubuntu trusty main > /etc/apt/sources.list.d/zfs.list
31 32
 
33
+# add llvm repo
34
+RUN	apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 15CF4D18AF4F7421
35
+RUN	echo deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty main > /etc/apt/sources.list.d/llvm.list
36
+
32 37
 # Packaged dependencies
33 38
 RUN apt-get update && apt-get install -y \
34 39
 	apparmor \
... ...
@@ -37,6 +42,7 @@ RUN apt-get update && apt-get install -y \
37 37
 	bash-completion \
38 38
 	btrfs-tools \
39 39
 	build-essential \
40
+	clang-3.8 \
40 41
 	createrepo \
41 42
 	curl \
42 43
 	dpkg-sig \
... ...
@@ -58,7 +64,9 @@ RUN apt-get update && apt-get install -y \
58 58
 	ubuntu-zfs \
59 59
 	xfsprogs \
60 60
 	libzfs-dev \
61
-	--no-install-recommends
61
+	--no-install-recommends \
62
+	&& ln -snf /usr/bin/clang-3.8 /usr/local/bin/clang \
63
+	&& ln -snf /usr/bin/clang++-3.8 /usr/local/bin/clang++
62 64
 
63 65
 # Get lvm2 source for compiling statically
64 66
 RUN git clone -b v2_02_103 https://git.fedorahosted.org/git/lvm2.git /usr/local/lvm2
... ...
@@ -105,6 +113,15 @@ RUN git clone https://github.com/golang/lint.git /go/src/github.com/golang/lint
105 105
 	&& (cd /go/src/github.com/golang/lint && git checkout -q $GO_LINT_COMMIT) \
106 106
 	&& go install -v github.com/golang/lint/golint
107 107
 
108
+# Configure the container for OSX cross compilation
109
+ENV OSX_SDK MacOSX10.11.sdk
110
+RUN set -x \
111
+	&& export OSXCROSS_PATH="/osxcross" \
112
+	&& git clone --depth 1 https://github.com/tpoechtrager/osxcross.git $OSXCROSS_PATH \
113
+	&& curl -sSL https://s3.dockerproject.org/darwin/${OSX_SDK}.tar.xz -o "${OSXCROSS_PATH}/tarballs/${OSX_SDK}.tar.xz" \
114
+	&& UNATTENDED=yes OSX_VERSION_MIN=10.6 ${OSXCROSS_PATH}/build.sh
115
+ENV PATH /osxcross/target/bin:$PATH
116
+
108 117
 # Install registry
109 118
 ENV REGISTRY_COMMIT ec87e9b6971d831f0eff752ddb54fb64693e51cd
110 119
 RUN set -x \
... ...
@@ -25,8 +25,15 @@ if [ "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" == "windows/amd64" ] && [ "$(go e
25 25
 	export LDFLAGS_STATIC_DOCKER="$LDFLAGS_STATIC_DOCKER -linkmode=internal"
26 26
 fi
27 27
 
28
-if [ "$IAMSTATIC" == "true" ]; then
29
-	export BUILDFLAGS=( "${BUILDFLAGS[@]/pkcs11 /}" ) # we cannot dlopen in pkcs11 in a static binary
28
+if [ "$IAMSTATIC" == "true" ] && [ "$(go env GOHOSTOS)" == "linux" ] && [ "$DOCKER_EXPERIMENTAL" ]; then
29
+	if  [ "${GOOS}/${GOARCH}" == "darwin/amd64" ]; then
30
+		export CGO_ENABLED=1
31
+		export CC=o64-clang
32
+		export LDFLAGS='-linkmode external -s'
33
+		export LDFLAGS_STATIC_DOCKER='-extld='${CC}
34
+	else
35
+		export BUILDFLAGS=( "${BUILDFLAGS[@]/pkcs11 /}" ) # we cannot dlopen in pkcs11 in a static binary
36
+	fi
30 37
 fi
31 38
 
32 39
 echo "Building: $DEST/$BINARY_FULLNAME"