contrib: Dockerfile: add a base stage
ARG GOLANG_VERSION=1.11
+FROM golang:${GOLANG_VERSION} AS golang-base
+RUN mkdir -p /go/src/github.com/containerd/containerd
+WORKDIR /go/src/github.com/containerd/containerd
+
# Install proto3
-FROM golang:${GOLANG_VERSION} AS proto3
+FROM golang-base AS proto3
RUN apt-get update && apt-get install -y \
autoconf \
automake \
@@ -22,17 +26,17 @@ COPY script/setup/install-protobuf install-protobuf
RUN ./install-protobuf
# Install runc
-FROM golang:${GOLANG_VERSION} AS runc
+FROM golang-base AS runc
RUN apt-get update && apt-get install -y \
curl \
libseccomp-dev \
--no-install-recommends
-COPY vendor.conf /go/src/github.com/containerd/containerd/vendor.conf
+COPY vendor.conf vendor.conf
COPY script/setup/install-runc install-runc
RUN ./install-runc
-FROM golang:${GOLANG_VERSION} AS dev
+FROM golang-base AS dev
RUN apt-get update && apt-get install -y \
btrfs-tools \
gcc \
@@ -46,6 +50,4 @@ COPY --from=proto3 /usr/local/bin/protoc /usr/local/bin/protoc
COPY --from=proto3 /usr/local/include/google /usr/local/include/google
COPY --from=runc /usr/local/sbin/runc /usr/local/go/bin/runc
-COPY . /go/src/github.com/containerd/containerd
-
-WORKDIR /go/src/github.com/containerd/containerd
+COPY . .
