Dockerfile.dapper 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. FROM ubuntu:16.04
  2. # FROM arm64=aarch64/ubuntu:16.04 arm=armhf/ubuntu:16.04
  3. ENV DAPPER_ENV VERSION DEV_BUILD
  4. ENV DAPPER_DOCKER_SOCKET true
  5. ENV DAPPER_SOURCE /go/src/github.com/rancher/os
  6. ENV DAPPER_OUTPUT ./bin ./dist ./build/initrd
  7. ENV DAPPER_RUN_ARGS --privileged
  8. ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache
  9. ENV SHELL /bin/bash
  10. WORKDIR ${DAPPER_SOURCE}
  11. ########## General Configuration #####################
  12. ARG DAPPER_HOST_ARCH=amd64
  13. ARG HOST_ARCH=${DAPPER_HOST_ARCH}
  14. ARG ARCH=${HOST_ARCH}
  15. ARG OS_REPO=rancher
  16. ARG HOSTNAME_DEFAULT=rancher
  17. ARG DISTRIB_ID=RancherOS
  18. ARG DOCKER_VERSION=1.11.2
  19. ARG DOCKER_PATCH_VERSION=v${DOCKER_VERSION}-ros1
  20. ARG DOCKER_BUILD_VERSION=1.10.3
  21. ARG DOCKER_BUILD_PATCH_VERSION=v${DOCKER_BUILD_VERSION}-ros1
  22. ARG SELINUX_POLICY_URL=https://github.com/rancher/refpolicy/releases/download/v0.0.2/policy.29
  23. ARG KERNEL_URL_amd64=https://github.com/rancher/os-kernel/releases/download/Ubuntu-4.4.0-23.41-rancher2/linux-4.4.10-rancher-x86.tar.gz
  24. ARG KERNEL_URL_arm64=https://github.com/imikushin/os-kernel/releases/download/Estuary-4.4.0-arm64.8/linux-4.4.0-rancher-arm64.tar.gz
  25. ARG DOCKER_URL_amd64=https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION}.tgz
  26. ARG DOCKER_URL_arm=https://github.com/rancher/docker/releases/download/${DOCKER_PATCH_VERSION}/docker-${DOCKER_VERSION}_arm.tgz
  27. ARG DOCKER_URL_arm64=https://github.com/rancher/docker/releases/download/${DOCKER_PATCH_VERSION}/docker-${DOCKER_VERSION}_arm64.tgz
  28. ARG BUILD_DOCKER_URL_amd64=https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_BUILD_VERSION}
  29. ARG BUILD_DOCKER_URL_arm=https://github.com/rancher/docker/releases/download/${DOCKER_BUILD_PATCH_VERSION}/docker-${DOCKER_BUILD_VERSION}_arm
  30. ARG BUILD_DOCKER_URL_arm64=https://github.com/rancher/docker/releases/download/${DOCKER_BUILD_PATCH_VERSION}/docker-${DOCKER_BUILD_VERSION}_arm64
  31. ARG TOOLCHAIN_arm64=aarch64-linux-gnu
  32. ARG TOOLCHAIN_arm=arm-linux-gnueabihf
  33. ARG OS_RELEASES_YML=https://releases.rancher.com/os/releases.yml
  34. ARG VBOX_MODULES_URL_amd64=https://github.com/rancher/os-vbox/releases/download/v0.0.2/vbox-modules.tar.gz
  35. ARG OS_SERVICES_REPO=https://raw.githubusercontent.com/${OS_REPO}/os-services
  36. ARG IMAGE_NAME=${OS_REPO}/os
  37. ARG DFS_IMAGE=${OS_REPO}/docker:v${DOCKER_VERSION}
  38. ARG OS_BASE_URL_amd64=https://github.com/rancher/os-base/releases/download/v2016.05-3/os-base_amd64.tar.xz
  39. ARG OS_BASE_URL_arm64=https://github.com/rancher/os-base/releases/download/v2016.05-3/os-base_arm64.tar.xz
  40. ARG OS_BASE_URL_arm=https://github.com/rancher/os-base/releases/download/v2016.05-3/os-base_arm.tar.xz
  41. ######################################################
  42. # Set up environment and export all ARGS as ENV
  43. ENV ARCH ${ARCH}
  44. ENV BUILD_DOCKER_URL BUILD_DOCKER_URL_${ARCH}
  45. ENV BUILD_DOCKER_URL_amd64 ${BUILD_DOCKER_URL_amd64}
  46. ENV BUILD_DOCKER_URL_arm ${BUILD_DOCKER_URL_arm}
  47. ENV BUILD_DOCKER_URL_arm64 ${BUILD_DOCKER_URL_arm64}
  48. ENV DAPPER_HOST_ARCH ${DAPPER_HOST_ARCH}
  49. ENV DFS_IMAGE ${DFS_IMAGE}
  50. ENV DISTRIB_ID ${DISTRIB_ID}
  51. ENV DOCKER_PATCH_VERSION ${DOCKER_PATCH_VERSION}
  52. ENV DOCKER_URL DOCKER_URL_${ARCH}
  53. ENV DOCKER_URL_amd64 ${DOCKER_URL_amd64}
  54. ENV DOCKER_URL_arm ${DOCKER_URL_arm}
  55. ENV DOCKER_URL_arm64 ${DOCKER_URL_arm64}
  56. ENV DOCKER_VERSION ${DOCKER_VERSION}
  57. ENV DOWNLOADS /usr/src/downloads
  58. ENV GOPATH /go
  59. ENV GO_VERSION 1.6.2
  60. ENV GOARCH $ARCH
  61. ENV HOSTNAME_DEFAULT ${HOSTNAME_DEFAULT}
  62. ENV HOST_ARCH ${HOST_ARCH}
  63. ENV IMAGE_NAME ${IMAGE_NAME}
  64. ENV KERNEL_URL KERNEL_URL_${ARCH}
  65. ENV KERNEL_URL_amd64 ${KERNEL_URL_amd64}
  66. ENV KERNEL_URL_arm64 ${KERNEL_URL_arm64}
  67. ENV OS_BASE_SHA1 OS_BASE_SHA1_${ARCH}
  68. ENV OS_BASE_URL OS_BASE_URL_${ARCH}
  69. ENV OS_BASE_URL_amd64 ${OS_BASE_URL_amd64}
  70. ENV OS_BASE_URL_arm ${OS_BASE_URL_arm}
  71. ENV OS_BASE_URL_arm64 ${OS_BASE_URL_arm64}
  72. ENV OS_RELEASES_YML ${OS_RELEASES_YML}
  73. ENV OS_REPO ${OS_REPO}
  74. ENV OS_SERVICES_REPO ${OS_SERVICES_REPO}
  75. ENV PATH ${GOPATH}/bin:/usr/local/go/bin:$PATH
  76. ENV REPO_VERSION master
  77. ENV SELINUX_POLICY_URL ${SELINUX_POLICY_URL}
  78. ENV TOOLCHAIN_arm ${TOOLCHAIN_arm}
  79. ENV TOOLCHAIN_arm64 ${TOOLCHAIN_arm64}
  80. ENV VBOX_MODULES_URL ${VBOX_MODULES_URL}
  81. ENV VBOX_MODULES_URL VBOX_MODULES_URL_${ARCH}
  82. ENV VBOX_MODULES_URL_amd64 ${VBOX_MODULES_URL_amd64}
  83. RUN mkdir -p ${DOWNLOADS}
  84. RUN apt-get update && \
  85. apt-get install -y \
  86. build-essential \
  87. ca-certificates \
  88. cpio \
  89. curl \
  90. dosfstools \
  91. gccgo \
  92. genisoimage \
  93. git \
  94. isolinux \
  95. less \
  96. libblkid-dev \
  97. libmount-dev \
  98. libselinux1-dev \
  99. locales \
  100. module-init-tools \
  101. pkg-config \
  102. python-pip \
  103. qemu \
  104. qemu-kvm \
  105. rsync \
  106. sudo \
  107. tox \
  108. vim \
  109. wget \
  110. xorriso
  111. # Download kernel
  112. RUN rm /bin/sh && ln -s /bin/bash /bin/sh
  113. RUN if [ -n "${!KERNEL_URL}" ]; then \
  114. curl -fL ${!KERNEL_URL} > ${DOWNLOADS}/kernel.tar.gz \
  115. ;fi
  116. # Download SELinux Policy
  117. RUN curl -pfL ${SELINUX_POLICY_URL} > ${DOWNLOADS}/$(basename ${SELINUX_POLICY_URL})
  118. # VBox URL
  119. RUN if [ -n "${!VBOX_MODULES_URL}" ]; then \
  120. curl -pfL ${!VBOX_MODULES_URL} > ${DOWNLOADS}/vbox-modules.tar.gz \
  121. ;fi
  122. # Install Go
  123. COPY assets/go-dnsclient.patch ${DAPPER_SOURCE}
  124. RUN ln -sf go-6 /usr/bin/go && \
  125. curl -sfL https://storage.googleapis.com/golang/go${GO_VERSION}.src.tar.gz | tar -xzf - -C /usr/local && \
  126. patch /usr/local/go/src/net/dnsclient_unix.go ${DAPPER_SOURCE}/go-dnsclient.patch && \
  127. cd /usr/local/go/src && \
  128. GOROOT_BOOTSTRAP=/usr GOARCH=${HOST_ARCH} GOHOSTARCH=${HOST_ARCH} ./make.bash && \
  129. rm /usr/bin/go
  130. # Install Host Docker
  131. RUN curl -fL ${!BUILD_DOCKER_URL} > /usr/bin/docker && \
  132. chmod +x /usr/bin/docker
  133. # Install Target Docker
  134. RUN curl -fL ${!DOCKER_URL} > ${DOWNLOADS}/docker.tgz
  135. # Install Trash
  136. RUN go get github.com/rancher/trash
  137. # Install dapper
  138. RUN curl -sL https://releases.rancher.com/dapper/latest/dapper-`uname -s`-`uname -m | sed 's/arm.*/arm/'` > /usr/bin/dapper && \
  139. chmod +x /usr/bin/dapper
  140. # Install toolchain
  141. RUN TOOLCHAIN=TOOLCHAIN_${ARCH} && \
  142. echo export TOOLCHAIN=${!TOOLCHAIN} > /usr/src/toolchain-env
  143. RUN source /usr/src/toolchain-env && \
  144. if [ "${TOOLCHAIN}" != "" ] && ! which ${TOOLCHAIN}-gcc; then \
  145. apt-get install -y gcc-${TOOLCHAIN} g++-${TOOLCHAIN} \
  146. ;fi
  147. RUN source /usr/src/toolchain-env; if [ "${TOOLCHAIN}" != "" ]; then \
  148. apt-get update && \
  149. cd /usr/local/src && \
  150. for i in libselinux libsepol pcre3 util-linux; do \
  151. apt-get build-dep -y $i && \
  152. apt-get source -y $i \
  153. ;done \
  154. ;fi
  155. RUN source /usr/src/toolchain-env; if [ "${TOOLCHAIN}" != "" ]; then \
  156. cd /usr/local/src/pcre3-* && \
  157. autoreconf && \
  158. CC=${TOOLCHAIN}-gcc CXX=${TOOLCHAIN}-g++ ./configure --host=${TOOLCHAIN} --prefix=/usr/${TOOLCHAIN} && \
  159. make -j$(nproc) && \
  160. make install \
  161. ;fi
  162. RUN source /usr/src/toolchain-env; if [ "${TOOLCHAIN}" != "" ]; then \
  163. cd /usr/local/src/libselinux-* && \
  164. CC=${TOOLCHAIN}-gcc CXX=${TOOLCHAIN}-g++ make CFLAGS=-Wall && \
  165. make PREFIX=/usr/${TOOLCHAIN} DESTDIR=/usr/${TOOLCHAIN} install && \
  166. cd /usr/local/src/libsepol-* && \
  167. CC=${TOOLCHAIN}-gcc CXX=${TOOLCHAIN}-g++ make CFLAGS=-Wall && \
  168. make PREFIX=/usr/${TOOLCHAIN} DESTDIR=/usr/${TOOLCHAIN} install \
  169. ;fi
  170. RUN source /usr/src/toolchain-env; if [ "${TOOLCHAIN}" != "" ]; then \
  171. cd /usr/local/src/util-linux-* && \
  172. autoreconf && \
  173. CC=${TOOLCHAIN}-gcc CXX=${TOOLCHAIN}-g++ ./configure --host=${TOOLCHAIN} --prefix=/usr/${TOOLCHAIN} \
  174. --disable-all-programs \
  175. --enable-libmount \
  176. --enable-libblkid \
  177. --enable-libuuid \
  178. --enable-mount && \
  179. make -j$(nproc) && \
  180. make install \
  181. ;fi
  182. RUN mkdir -p images/00-rootfs/build && \
  183. curl -pfL ${!OS_BASE_URL} | tar xvJf - -C images/00-rootfs/build
  184. ENTRYPOINT ["./scripts/entry"]
  185. CMD ["ci"]