Разговор с Google API от Go зависает - PullRequest
1 голос
/ 12 апреля 2019

Следуя примерам здесь , кажется, что код зависает при установлении https-соединения через gRPC к API Google.

Один и тот же код работает на App Engine Go1.11 и App Engine Flex. Вот мой Dockerfile

# Use the offical Golang image to create a build artifact.
# This is based on Debian and sets the GOPATH to /go.
# https://hub.docker.com/_/golang
FROM golang:1.12 as builder

# Copy local code to the container image.
WORKDIR /go/src/serverless
COPY . .

# Build the command inside the container.
# (You may fetch or manage dependencies here,
# either manually or with a tool like "godep".)
RUN go get . && CGO_ENABLED=0 GOOS=linux go build -v -o serverless

# Use a Docker multi-stage build to create a lean production image.
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
FROM alpine

# Copy the binary to the production image from the builder stage.
COPY --from=builder /go/src/serverless/serverless /serverless

# Run the web service on container startup.
CMD ["/serverless"]

1 Ответ

4 голосов
/ 12 апреля 2019

После небольшой отладки это, похоже, связано с отсутствием корневых сертификатов в контейнере. Добавление следующей строки после FROM alpine

# Enable the use of outbound https
RUN apk add --no-cache ca-certificates

исправляет проблему.

...