| 1 |
FROM golang:1.24-alpine as godist |
| 2 |
RUN go version |
| 3 |
|
| 4 |
FROM docker:25.0 |
| 5 |
|
| 6 |
# Log the version of Alpine in use. |
| 7 |
RUN cat /etc/alpine-release |
| 8 |
|
| 9 |
ENV GO111MODULE on |
| 10 |
|
| 11 |
RUN apk update && \ |
| 12 |
apk add ca-certificates wget git unzip |
| 13 |
# Install bash and ssh tools (needed to run regen.sh etc). |
| 14 |
RUN apk add bash openssh-client build-base |
| 15 |
RUN which bash |
| 16 |
|
| 17 |
# Install libc compatibility (required by protoc and go) |
| 18 |
RUN apk add libc6-compat |
| 19 |
|
| 20 |
# Install protoc and protobuf-dev (common protos). |
| 21 |
RUN apk add protoc protobuf-dev |
| 22 |
RUN protoc --version |
| 23 |
|
| 24 |
# Copy pre-built alpine Go |
| 25 |
COPY --from=godist /usr/local/go /usr/local/go |
| 26 |
ENV PATH /usr/local/go/bin:$PATH |
| 27 |
RUN go version |
| 28 |
|
| 29 |
# Install Go tools. |
| 30 |
RUN go install github.com/golang/protobuf/[email protected] && \ |
| 31 |
go install golang.org/x/lint/golint@latest && \ |
| 32 |
go install golang.org/x/tools/cmd/goimports@latest && \ |
| 33 |
go install honnef.co/go/tools/cmd/staticcheck@latest && \ |
| 34 |
go install github.com/googleapis/gapic-generator-go/cmd/[email protected] |
| 35 |
ENV PATH="${PATH}:/root/go/bin" |
| 36 |
|
| 37 |
# Source: http://debuggable.com/posts/disable-strict-host-checking-for-git-clone:49896ff3-0ac0-4263-9703-1eae4834cda3 |
| 38 |
RUN mkdir /root/.ssh && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config |
| 39 |
|
| 40 |
RUN echo -e '#!/bin/bash\n\ |
| 41 |
set -ex\n\ |
| 42 |
cd internal/gapicgen\n\ |
| 43 |
go run cloud.google.com/go/internal/gapicgen/cmd/genbot' >> /run.sh |
| 44 |
RUN chmod a+x /run.sh |
| 45 |
|
| 46 |
WORKDIR /google-cloud-go |
| 47 |
CMD ["bash", "-c", "/run.sh"] |