This repository has been archived by the owner on Jun 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 177
/
Dockerfile
91 lines (78 loc) · 4.6 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
FROM dockercore/golang-cross:1.13.10@sha256:ad2725ac9af0273f1de9bb85e166084d5e8d915df334154fe9c8bd9af912a90d AS cli-build
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
ARG CLI_CHANNEL=stable
ARG CLI_VERSION=19.03.8
RUN apt-get update && apt-get install -y -q --no-install-recommends \
coreutils \
util-linux \
uuid-runtime
WORKDIR /go/src/github.com/docker/cli
RUN git clone https://github.com/docker/cli . && git checkout v${CLI_VERSION}
RUN mkdir build
RUN curl -fL https://download.docker.com/linux/static/${CLI_CHANNEL}/x86_64/docker-${CLI_VERSION}.tgz | tar xzO docker/docker > build/docker-linux-amd64 && chmod +x build/docker-linux-amd64
RUN curl -fL https://download.docker.com/linux/static/${CLI_CHANNEL}/aarch64/docker-${CLI_VERSION}.tgz | tar xzO docker/docker > build/docker-linux-arm64 && chmod +x build/docker-linux-arm64
RUN curl -fL https://download.docker.com/linux/static/${CLI_CHANNEL}/armhf/docker-${CLI_VERSION}.tgz | tar xzO docker/docker > build/docker-linux-arm && chmod +x build/docker-linux-arm
RUN curl -fL https://download.docker.com/mac/static/${CLI_CHANNEL}/x86_64/docker-${CLI_VERSION}.tgz | tar xzO docker/docker > build/docker-darwin-amd64
ARG GOPROXY
RUN make binary-windows
# main dev image
FROM golang:1.13.10 AS dev
RUN apt-get update && apt-get install -y -q --no-install-recommends \
coreutils \
util-linux \
uuid-runtime
WORKDIR /go/src/github.com/docker/app/
COPY --from=cli-build /go/src/github.com/docker/cli/build/docker-linux-amd64 /usr/bin/docker
ENV PATH=${PATH}:/go/src/github.com/docker/app/bin/
ARG DEP_VERSION=v0.5.4
RUN curl -o /usr/bin/dep -L https://github.com/golang/dep/releases/download/${DEP_VERSION}/dep-linux-amd64 && \
chmod +x /usr/bin/dep
ARG GOTESTSUM_VERSION=v0.4.2
ARG GOPROXY
RUN mkdir $GOPATH/src/gotest.tools && \
git clone -q https://github.com/gotestyourself/gotestsum $GOPATH/src/gotest.tools/gotestsum && \
cd $GOPATH/src/gotest.tools/gotestsum && \
git -C $GOPATH/src/gotest.tools/gotestsum checkout -q $GOTESTSUM_VERSION && \
GO111MODULE=on GOOS=linux go build -o /usr/local/bin/gotestsum-linux gotest.tools/gotestsum && \
GO111MODULE=on GOOS=darwin go build -o /usr/local/bin/gotestsum-darwin gotest.tools/gotestsum && \
GO111MODULE=on GOOS=windows go build -o /usr/local/bin/gotestsum-windows.exe gotest.tools/gotestsum && \
ln -s gotestsum-linux /usr/local/bin/gotestsum
# Source for cmd/test2json is part of the Go distribution and is
# therefore available in the base image.
RUN GOOS=linux go build -o /usr/local/bin/test2json-linux cmd/test2json && \
GOOS=darwin go build -o /usr/local/bin/test2json-darwin cmd/test2json && \
GOOS=windows go build -o /usr/local/bin/test2json-windows.exe cmd/test2json
RUN go get -d gopkg.in/mjibson/esc.v0 && \
cd /go/src/github.com/mjibson/esc && \
go build -v -o /usr/bin/esc . && \
rm -rf /go/src/* /go/pkg/* /go/bin/*
COPY . .
FROM scratch AS cli
COPY --from=cli-build /go/src/github.com/docker/cli/build/docker-linux-amd64 docker-linux
COPY --from=cli-build /go/src/github.com/docker/cli/build/docker-darwin-amd64 docker-darwin
COPY --from=cli-build /go/src/github.com/docker/cli/build/docker-windows-amd64 docker-windows.exe
FROM dev AS cross-build
ARG TAG="unknown"
RUN make TAG=${TAG} cross
FROM scratch AS cross
ARG PROJECT_PATH=/go/src/github.com/docker/app
COPY --from=cross-build ${PROJECT_PATH}/bin/docker-app-linux docker-app-linux
COPY --from=cross-build ${PROJECT_PATH}/bin/docker-app-linux-arm64 docker-app-linux-arm64
COPY --from=cross-build ${PROJECT_PATH}/bin/docker-app-linux-arm docker-app-linux-arm
COPY --from=cross-build ${PROJECT_PATH}/bin/docker-app-darwin docker-app-darwin
COPY --from=cross-build ${PROJECT_PATH}/bin/docker-app-windows.exe docker-app-windows.exe
FROM cross-build AS e2e-cross-build
ARG TAG="unknown"
# Run e2e tests
RUN make TAG=${TAG} e2e-cross
FROM scratch AS e2e-cross
ARG PROJECT_PATH=/go/src/github.com/docker/app
COPY --from=e2e-cross-build ${PROJECT_PATH}/bin/docker-app-e2e-linux docker-app-e2e-linux
COPY --from=e2e-cross-build ${PROJECT_PATH}/bin/docker-app-e2e-darwin docker-app-e2e-darwin
COPY --from=e2e-cross-build ${PROJECT_PATH}/bin/docker-app-e2e-windows.exe docker-app-e2e-windows.exe
COPY --from=e2e-cross-build /usr/local/bin/gotestsum-linux gotestsum-linux
COPY --from=e2e-cross-build /usr/local/bin/gotestsum-darwin gotestsum-darwin
COPY --from=e2e-cross-build /usr/local/bin/gotestsum-windows.exe gotestsum-windows.exe
COPY --from=e2e-cross-build /usr/local/bin/test2json-linux test2json-linux
COPY --from=e2e-cross-build /usr/local/bin/test2json-darwin test2json-darwin
COPY --from=e2e-cross-build /usr/local/bin/test2json-windows.exe test2json-windows.exe