Dockerfile 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. # This file describes the standard way to build Docker, using docker
  2. #
  3. # Usage:
  4. #
  5. # # Assemble the full dev environment. This is slow the first time.
  6. # docker build -t docker .
  7. #
  8. # # Mount your source in an interactive container for quick testing:
  9. # docker run -v `pwd`:/go/src/github.com/docker/docker --privileged -i -t docker bash
  10. #
  11. # # Run the test suite:
  12. # docker run --privileged docker hack/make.sh test-unit test-integration-cli test-docker-py
  13. #
  14. # # Publish a release:
  15. # docker run --privileged \
  16. # -e AWS_S3_BUCKET=baz \
  17. # -e AWS_ACCESS_KEY=foo \
  18. # -e AWS_SECRET_KEY=bar \
  19. # -e GPG_PASSPHRASE=gloubiboulga \
  20. # docker hack/release.sh
  21. #
  22. # Note: AppArmor used to mess with privileged mode, but this is no longer
  23. # the case. Therefore, you don't have to disable it anymore.
  24. #
  25. FROM debian:jessie
  26. # allow replacing httpredir or deb mirror
  27. ARG APT_MIRROR=deb.debian.org
  28. RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list
  29. # Add zfs ppa
  30. RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys E871F18B51E0147C77796AC81196BA81F6B0FC61 \
  31. || apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys E871F18B51E0147C77796AC81196BA81F6B0FC61
  32. RUN echo deb http://ppa.launchpad.net/zfs-native/stable/ubuntu trusty main > /etc/apt/sources.list.d/zfs.list
  33. # Packaged dependencies
  34. RUN apt-get update && apt-get install -y \
  35. apparmor \
  36. apt-utils \
  37. aufs-tools \
  38. automake \
  39. bash-completion \
  40. binutils-mingw-w64 \
  41. bsdmainutils \
  42. btrfs-tools \
  43. build-essential \
  44. clang \
  45. cmake \
  46. createrepo \
  47. curl \
  48. dpkg-sig \
  49. gcc-mingw-w64 \
  50. git \
  51. iptables \
  52. jq \
  53. less \
  54. libapparmor-dev \
  55. libcap-dev \
  56. libltdl-dev \
  57. libnl-3-dev \
  58. libprotobuf-c0-dev \
  59. libprotobuf-dev \
  60. libsqlite3-dev \
  61. libsystemd-journal-dev \
  62. libtool \
  63. libzfs-dev \
  64. mercurial \
  65. net-tools \
  66. pkg-config \
  67. protobuf-compiler \
  68. protobuf-c-compiler \
  69. python-dev \
  70. python-mock \
  71. python-pip \
  72. python-websocket \
  73. tar \
  74. ubuntu-zfs \
  75. vim \
  76. vim-common \
  77. xfsprogs \
  78. zip \
  79. --no-install-recommends \
  80. && pip install awscli==1.10.15
  81. # Get lvm2 source for compiling statically
  82. ENV LVM2_VERSION 2.02.103
  83. RUN mkdir -p /usr/local/lvm2 \
  84. && curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \
  85. | tar -xzC /usr/local/lvm2 --strip-components=1
  86. # See https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags
  87. # Compile and install lvm2
  88. RUN cd /usr/local/lvm2 \
  89. && ./configure \
  90. --build="$(gcc -print-multiarch)" \
  91. --enable-static_link \
  92. && make device-mapper \
  93. && make install_device-mapper
  94. # See https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL
  95. # Configure the container for OSX cross compilation
  96. ENV OSX_SDK MacOSX10.11.sdk
  97. ENV OSX_CROSS_COMMIT a9317c18a3a457ca0a657f08cc4d0d43c6cf8953
  98. RUN set -x \
  99. && export OSXCROSS_PATH="/osxcross" \
  100. && git clone https://github.com/tpoechtrager/osxcross.git $OSXCROSS_PATH \
  101. && ( cd $OSXCROSS_PATH && git checkout -q $OSX_CROSS_COMMIT) \
  102. && curl -sSL https://s3.dockerproject.org/darwin/v2/${OSX_SDK}.tar.xz -o "${OSXCROSS_PATH}/tarballs/${OSX_SDK}.tar.xz" \
  103. && UNATTENDED=yes OSX_VERSION_MIN=10.6 ${OSXCROSS_PATH}/build.sh
  104. ENV PATH /osxcross/target/bin:$PATH
  105. # Install seccomp: the version shipped in trusty is too old
  106. ENV SECCOMP_VERSION 2.3.1
  107. RUN set -x \
  108. && export SECCOMP_PATH="$(mktemp -d)" \
  109. && curl -fsSL "https://github.com/seccomp/libseccomp/releases/download/v${SECCOMP_VERSION}/libseccomp-${SECCOMP_VERSION}.tar.gz" \
  110. | tar -xzC "$SECCOMP_PATH" --strip-components=1 \
  111. && ( \
  112. cd "$SECCOMP_PATH" \
  113. && ./configure --prefix=/usr/local \
  114. && make \
  115. && make install \
  116. && ldconfig \
  117. ) \
  118. && rm -rf "$SECCOMP_PATH"
  119. # Install Go
  120. # IMPORTANT: If the version of Go is updated, the Windows to Linux CI machines
  121. # will need updating, to avoid errors. Ping #docker-maintainers on IRC
  122. # with a heads-up.
  123. ENV GO_VERSION 1.7.3
  124. RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" \
  125. | tar -xzC /usr/local
  126. ENV PATH /go/bin:/usr/local/go/bin:$PATH
  127. ENV GOPATH /go
  128. # Compile Go for cross compilation
  129. ENV DOCKER_CROSSPLATFORMS \
  130. linux/386 linux/arm \
  131. darwin/amd64 \
  132. freebsd/amd64 freebsd/386 freebsd/arm \
  133. windows/amd64 windows/386 \
  134. solaris/amd64
  135. # Dependency for golint
  136. ENV GO_TOOLS_COMMIT 823804e1ae08dbb14eb807afc7db9993bc9e3cc3
  137. RUN git clone https://github.com/golang/tools.git /go/src/golang.org/x/tools \
  138. && (cd /go/src/golang.org/x/tools && git checkout -q $GO_TOOLS_COMMIT)
  139. # Grab Go's lint tool
  140. ENV GO_LINT_COMMIT 32a87160691b3c96046c0c678fe57c5bef761456
  141. RUN git clone https://github.com/golang/lint.git /go/src/github.com/golang/lint \
  142. && (cd /go/src/github.com/golang/lint && git checkout -q $GO_LINT_COMMIT) \
  143. && go install -v github.com/golang/lint/golint
  144. # Install CRIU for checkpoint/restore support
  145. ENV CRIU_VERSION 2.2
  146. RUN mkdir -p /usr/src/criu \
  147. && curl -sSL https://github.com/xemul/criu/archive/v${CRIU_VERSION}.tar.gz | tar -v -C /usr/src/criu/ -xz --strip-components=1 \
  148. && cd /usr/src/criu \
  149. && make \
  150. && make install-criu
  151. # Install two versions of the registry. The first is an older version that
  152. # only supports schema1 manifests. The second is a newer version that supports
  153. # both. This allows integration-cli tests to cover push/pull with both schema1
  154. # and schema2 manifests.
  155. ENV REGISTRY_COMMIT_SCHEMA1 ec87e9b6971d831f0eff752ddb54fb64693e51cd
  156. ENV REGISTRY_COMMIT 47a064d4195a9b56133891bbb13620c3ac83a827
  157. RUN set -x \
  158. && export GOPATH="$(mktemp -d)" \
  159. && git clone https://github.com/docker/distribution.git "$GOPATH/src/github.com/docker/distribution" \
  160. && (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT") \
  161. && GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \
  162. go build -o /usr/local/bin/registry-v2 github.com/docker/distribution/cmd/registry \
  163. && (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT_SCHEMA1") \
  164. && GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \
  165. go build -o /usr/local/bin/registry-v2-schema1 github.com/docker/distribution/cmd/registry \
  166. && rm -rf "$GOPATH"
  167. # Install notary and notary-server
  168. ENV NOTARY_VERSION v0.4.2
  169. RUN set -x \
  170. && export GOPATH="$(mktemp -d)" \
  171. && git clone https://github.com/docker/notary.git "$GOPATH/src/github.com/docker/notary" \
  172. && (cd "$GOPATH/src/github.com/docker/notary" && git checkout -q "$NOTARY_VERSION") \
  173. && GOPATH="$GOPATH/src/github.com/docker/notary/vendor:$GOPATH" \
  174. go build -o /usr/local/bin/notary-server github.com/docker/notary/cmd/notary-server \
  175. && GOPATH="$GOPATH/src/github.com/docker/notary/vendor:$GOPATH" \
  176. go build -o /usr/local/bin/notary github.com/docker/notary/cmd/notary \
  177. && rm -rf "$GOPATH"
  178. # Get the "docker-py" source so we can run their integration tests
  179. ENV DOCKER_PY_COMMIT e2655f658408f9ad1f62abdef3eb6ed43c0cf324
  180. RUN git clone https://github.com/docker/docker-py.git /docker-py \
  181. && cd /docker-py \
  182. && git checkout -q $DOCKER_PY_COMMIT \
  183. && pip install -r test-requirements.txt
  184. # Install yamllint for validating swagger.yaml
  185. RUN pip install yamllint==1.5.0
  186. # Install go-swagger for validating swagger.yaml
  187. ENV GO_SWAGGER_COMMIT c28258affb0b6251755d92489ef685af8d4ff3eb
  188. RUN git clone https://github.com/go-swagger/go-swagger.git /go/src/github.com/go-swagger/go-swagger \
  189. && (cd /go/src/github.com/go-swagger/go-swagger && git checkout -q $GO_SWAGGER_COMMIT) \
  190. && go install -v github.com/go-swagger/go-swagger/cmd/swagger
  191. # Set user.email so crosbymichael's in-container merge commits go smoothly
  192. RUN git config --global user.email 'docker-dummy@example.com'
  193. # Add an unprivileged user to be used for tests which need it
  194. RUN groupadd -r docker
  195. RUN useradd --create-home --gid docker unprivilegeduser
  196. VOLUME /var/lib/docker
  197. WORKDIR /go/src/github.com/docker/docker
  198. ENV DOCKER_BUILDTAGS apparmor pkcs11 seccomp selinux
  199. # Let us use a .bashrc file
  200. RUN ln -sfv $PWD/.bashrc ~/.bashrc
  201. # Add integration helps to bashrc
  202. RUN echo "source $PWD/hack/make/.integration-test-helpers" >> /etc/bash.bashrc
  203. # Register Docker's bash completion.
  204. RUN ln -sv $PWD/contrib/completion/bash/docker /etc/bash_completion.d/docker
  205. # Get useful and necessary Hub images so we can "docker load" locally instead of pulling
  206. COPY contrib/download-frozen-image-v2.sh /go/src/github.com/docker/docker/contrib/
  207. RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \
  208. buildpack-deps:jessie@sha256:25785f89240fbcdd8a74bdaf30dd5599a9523882c6dfc567f2e9ef7cf6f79db6 \
  209. busybox:latest@sha256:e4f93f6ed15a0cdd342f5aae387886fba0ab98af0a102da6276eaf24d6e6ade0 \
  210. debian:jessie@sha256:f968f10b4b523737e253a97eac59b0d1420b5c19b69928d35801a6373ffe330e \
  211. hello-world:latest@sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7
  212. # See also "hack/make/.ensure-frozen-images" (which needs to be updated any time this list is)
  213. # Install tomlv, vndr, runc, containerd, tini, docker-proxy
  214. # Please edit hack/dockerfile/install-binaries.sh to update them.
  215. COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
  216. COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
  217. RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy
  218. # Wrap all commands in the "docker-in-docker" script to allow nested containers
  219. ENTRYPOINT ["hack/dind"]
  220. # Upload docker source
  221. COPY . /go/src/github.com/docker/docker