@@ -6,7 +6,17 @@ FROM golang:1.11 AS build
6
6
RUN apt-get update && apt-get install -y \
7
7
zip # required for generate-index.bash
8
8
9
- ENV GODOC_REF release-branch.go1.11
9
+ # Check out the desired version of Go, both to build the godoc binary and serve
10
+ # as the goroot for content serving.
11
+ ARG GO_REF
12
+ RUN test -n "$GO_REF" # GO_REF is required.
13
+ RUN git clone --single-branch --depth=1 -b $GO_REF https://go.googlesource.com/go /goroot
14
+ RUN cd /goroot/src && ./make.bash
15
+
16
+ ENV GOROOT /goroot
17
+ ENV PATH=/goroot/bin:$PATH
18
+
19
+ RUN go version
10
20
11
21
RUN go get -v -d \
12
22
golang.org/x/net/context \
@@ -18,11 +28,24 @@ RUN go get -v -d \
18
28
COPY . /go/src/golang.org/x/tools
19
29
20
30
WORKDIR /go/src/golang.org/x/tools/cmd/godoc
21
- RUN git clone --single-branch --depth=1 -b $GODOC_REF https://go.googlesource.com/go /docset
22
- RUN GODOC_DOCSET=/docset ./generate-index.bash
31
+ RUN GODOC_DOCSET=/goroot ./generate-index.bash
23
32
24
33
RUN go build -o /godoc -tags=golangorg golang.org/x/tools/cmd/godoc
25
34
35
+ # Clean up goroot for the final image.
36
+ RUN cd /goroot && git clean -xdf
37
+
38
+ # Add build metadata.
39
+ ARG TOOLS_HEAD
40
+ ARG TOOLS_CLEAN
41
+ ARG DOCKER_TAG
42
+ RUN cd /goroot && echo "go repo HEAD: $(git rev-parse HEAD)" >> /goroot/buildinfo
43
+ RUN echo "requested go ref: ${GO_REF}" >> /goroot/buildinfo
44
+ RUN echo "x/tools HEAD: ${TOOLS_HEAD}" >> /goroot/buildinfo
45
+ RUN echo "x/tools clean: ${TOOLS_CLEAN}" >> /goroot/buildinfo
46
+ RUN echo "image: ${DOCKER_TAG}" >> /goroot/buildinfo
47
+
48
+ RUN rm -rf /goroot/.git
26
49
27
50
# Final image
28
51
#############
@@ -33,7 +56,7 @@ WORKDIR /app
33
56
COPY --from=build /godoc /app/
34
57
COPY --from=build /go/src/golang.org/x/tools/cmd/godoc/hg-git-mapping.bin /app/
35
58
36
- COPY --from=build /docset /goroot
59
+ COPY --from=build /goroot /goroot
37
60
ENV GOROOT /goroot
38
61
39
62
COPY --from=build /go/src/golang.org/x/tools/cmd/godoc/index.split.* /app/
0 commit comments