fix compile error
[platform/upstream/docker-engine.git] / Dockerfile
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 -e DOCKER_GITCOMMIT=foo --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
26 FROM debian:jessie
27
28 # allow replacing httpredir or deb mirror
29 ARG APT_MIRROR=deb.debian.org
30 RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list
31
32 # Packaged dependencies
33 RUN apt-get update && apt-get install -y \
34         apparmor \
35         apt-utils \
36         aufs-tools \
37         automake \
38         bash-completion \
39         binutils-mingw-w64 \
40         bsdmainutils \
41         btrfs-tools \
42         build-essential \
43         cmake \
44         createrepo \
45         curl \
46         dpkg-sig \
47         gcc-mingw-w64 \
48         git \
49         iptables \
50         jq \
51         less \
52         libapparmor-dev \
53         libcap-dev \
54         libnl-3-dev \
55         libprotobuf-c0-dev \
56         libprotobuf-dev \
57         libsystemd-journal-dev \
58         libtool \
59         mercurial \
60         net-tools \
61         pkg-config \
62         protobuf-compiler \
63         protobuf-c-compiler \
64         python-dev \
65         python-mock \
66         python-pip \
67         python-websocket \
68         tar \
69         vim \
70         vim-common \
71         xfsprogs \
72         zip \
73         --no-install-recommends \
74         && pip install awscli==1.10.15
75 # Get lvm2 source for compiling statically
76 ENV LVM2_VERSION 2.02.103
77 RUN mkdir -p /usr/local/lvm2 \
78         && curl -fsSL "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${LVM2_VERSION}.tgz" \
79                 | tar -xzC /usr/local/lvm2 --strip-components=1
80 # See https://git.fedorahosted.org/cgit/lvm2.git/refs/tags for release tags
81
82 # Compile and install lvm2
83 RUN cd /usr/local/lvm2 \
84         && ./configure \
85                 --build="$(gcc -print-multiarch)" \
86                 --enable-static_link \
87         && make device-mapper \
88         && make install_device-mapper
89 # See https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL
90
91 # Install seccomp: the version shipped upstream is too old
92 ENV SECCOMP_VERSION 2.3.2
93 RUN set -x \
94         && export SECCOMP_PATH="$(mktemp -d)" \
95         && curl -fsSL "https://github.com/seccomp/libseccomp/releases/download/v${SECCOMP_VERSION}/libseccomp-${SECCOMP_VERSION}.tar.gz" \
96                 | tar -xzC "$SECCOMP_PATH" --strip-components=1 \
97         && ( \
98                 cd "$SECCOMP_PATH" \
99                 && ./configure --prefix=/usr/local \
100                 && make \
101                 && make install \
102                 && ldconfig \
103         ) \
104         && rm -rf "$SECCOMP_PATH"
105
106 # Install Go
107 # IMPORTANT: If the version of Go is updated, the Windows to Linux CI machines
108 #            will need updating, to avoid errors. Ping #docker-maintainers on IRC
109 #            with a heads-up.
110 ENV GO_VERSION 1.8.3
111 RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" \
112         | tar -xzC /usr/local
113
114 ENV PATH /go/bin:/usr/local/go/bin:$PATH
115 ENV GOPATH /go
116
117 # Dependency for golint
118 ENV GO_TOOLS_COMMIT 823804e1ae08dbb14eb807afc7db9993bc9e3cc3
119 RUN git clone https://github.com/golang/tools.git /go/src/golang.org/x/tools \
120         && (cd /go/src/golang.org/x/tools && git checkout -q $GO_TOOLS_COMMIT)
121
122 # Grab Go's lint tool
123 ENV GO_LINT_COMMIT 32a87160691b3c96046c0c678fe57c5bef761456
124 RUN git clone https://github.com/golang/lint.git /go/src/github.com/golang/lint \
125         && (cd /go/src/github.com/golang/lint && git checkout -q $GO_LINT_COMMIT) \
126         && go install -v github.com/golang/lint/golint
127
128 # Install CRIU for checkpoint/restore support
129 ENV CRIU_VERSION 2.12.1
130 # Install dependancy packages specific to criu
131 RUN apt-get install libnet-dev -y && \
132         mkdir -p /usr/src/criu \
133         && curl -sSL https://github.com/xemul/criu/archive/v${CRIU_VERSION}.tar.gz | tar -v -C /usr/src/criu/ -xz --strip-components=1 \
134         && cd /usr/src/criu \
135         && make \
136         && make install-criu
137
138 # Install two versions of the registry. The first is an older version that
139 # only supports schema1 manifests. The second is a newer version that supports
140 # both. This allows integration-cli tests to cover push/pull with both schema1
141 # and schema2 manifests.
142 ENV REGISTRY_COMMIT_SCHEMA1 ec87e9b6971d831f0eff752ddb54fb64693e51cd
143 ENV REGISTRY_COMMIT 47a064d4195a9b56133891bbb13620c3ac83a827
144 RUN set -x \
145         && export GOPATH="$(mktemp -d)" \
146         && git clone https://github.com/docker/distribution.git "$GOPATH/src/github.com/docker/distribution" \
147         && (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT") \
148         && GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \
149                 go build -o /usr/local/bin/registry-v2 github.com/docker/distribution/cmd/registry \
150         && (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT_SCHEMA1") \
151         && GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \
152                 go build -o /usr/local/bin/registry-v2-schema1 github.com/docker/distribution/cmd/registry \
153         && rm -rf "$GOPATH"
154
155 # Install notary and notary-server
156 ENV NOTARY_VERSION v0.5.0
157 RUN set -x \
158         && export GOPATH="$(mktemp -d)" \
159         && git clone https://github.com/docker/notary.git "$GOPATH/src/github.com/docker/notary" \
160         && (cd "$GOPATH/src/github.com/docker/notary" && git checkout -q "$NOTARY_VERSION") \
161         && GOPATH="$GOPATH/src/github.com/docker/notary/vendor:$GOPATH" \
162                 go build -o /usr/local/bin/notary-server github.com/docker/notary/cmd/notary-server \
163         && GOPATH="$GOPATH/src/github.com/docker/notary/vendor:$GOPATH" \
164                 go build -o /usr/local/bin/notary github.com/docker/notary/cmd/notary \
165         && rm -rf "$GOPATH"
166
167 # Get the "docker-py" source so we can run their integration tests
168 ENV DOCKER_PY_COMMIT a962578e515185cf06506050b2200c0b81aa84ef
169 # To run integration tests docker-pycreds is required.
170 # Before running the integration tests conftest.py is
171 # loaded which results in loads auth.py that
172 # imports the docker-pycreds module.
173 RUN git clone https://github.com/docker/docker-py.git /docker-py \
174         && cd /docker-py \
175         && git checkout -q $DOCKER_PY_COMMIT \
176         && pip install docker-pycreds==0.2.1 \
177         && pip install -r test-requirements.txt
178
179 # Install yamllint for validating swagger.yaml
180 RUN pip install yamllint==1.5.0
181
182 # Install go-swagger for validating swagger.yaml
183 ENV GO_SWAGGER_COMMIT c28258affb0b6251755d92489ef685af8d4ff3eb
184 RUN git clone https://github.com/go-swagger/go-swagger.git /go/src/github.com/go-swagger/go-swagger \
185         && (cd /go/src/github.com/go-swagger/go-swagger && git checkout -q $GO_SWAGGER_COMMIT) \
186         && go install -v github.com/go-swagger/go-swagger/cmd/swagger
187
188 # Set user.email so crosbymichael's in-container merge commits go smoothly
189 RUN git config --global user.email 'docker-dummy@example.com'
190
191 # Add an unprivileged user to be used for tests which need it
192 RUN groupadd -r docker
193 RUN useradd --create-home --gid docker unprivilegeduser
194
195 VOLUME /var/lib/docker
196 WORKDIR /go/src/github.com/docker/docker
197 ENV DOCKER_BUILDTAGS apparmor seccomp selinux
198
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
204 # Get useful and necessary Hub images so we can "docker load" locally instead of pulling
205 COPY contrib/download-frozen-image-v2.sh /go/src/github.com/docker/docker/contrib/
206 RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \
207         buildpack-deps:jessie@sha256:85b379ec16065e4fe4127eb1c5fb1bcc03c559bd36dbb2e22ff496de55925fa6 \
208         busybox:latest@sha256:32f093055929dbc23dec4d03e09dfe971f5973a9ca5cf059cbfb644c206aa83f \
209         debian:jessie@sha256:72f784399fd2719b4cb4e16ef8e369a39dc67f53d978cd3e2e7bf4e502c7b793 \
210         hello-world:latest@sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
211 # See also ensureFrozenImagesLinux() in "integration-cli/fixtures_linux_daemon_test.go" (which needs to be updated when adding images to this list)
212
213 # Install tomlv, vndr, runc, containerd, tini, docker-proxy dockercli
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 dockercli
218 ENV PATH=/usr/local/cli:$PATH
219
220 # Activate bash completion if mounted with DOCKER_BASH_COMPLETION_PATH
221 RUN ln -s /usr/local/completion/bash/docker /etc/bash_completion.d/docker
222
223 # Wrap all commands in the "docker-in-docker" script to allow nested containers
224 ENTRYPOINT ["hack/dind"]
225
226 # Upload docker source
227 COPY . /go/src/github.com/docker/docker