Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memorystore: add Dockerfile for Cloud Run deployment #1538

Merged
merged 8 commits into from Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions badfiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var allowList = []string{
"LICENSE",
"**/*Dockerfile*",
"**/.dockerignore",
"**/.gcloudignore",
"**/Makefile",
".gitignore",

Expand Down
6 changes: 6 additions & 0 deletions memorystore/redis/.gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cloud_run_deployment/
gae_flex_deployment/
gae_standard_deployment/
gce_deployment/
gke_deployment/
README.md
31 changes: 31 additions & 0 deletions memorystore/redis/cloud_run_deployment/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Use the official 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.13 as builder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use 1.13 or 1.14? If this is only for Cloud Run, it seems like we should use 1.14?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current "canonical" Dockerfile base image is golang:1.13-buster, though #1541 proposed to update that to 1.14. I'm fine rolling that forward. More significantly, this Dockerfile is a copy of an earlier version of the template used in Cloud Run, it would be best to update this from the Cloud Run Pub/Sub sample Dockerfile

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the Dockerfile based on the Cloud Run Pub/Sub sample, thanks


# Create and change to the app directory.
WORKDIR /app

# Retrieve application dependencies.
# This allows the container build to reuse cached dependencies.
COPY go.* ./
RUN go mod download

# Copy local code to the container image.
COPY . ./

# Build the binary.
RUN CGO_ENABLED=0 GOOS=linux go build -v -o server

# Use the official Alpine image for a lean production container.
# https://hub.docker.com/_/alpine
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
FROM alpine:3
RUN apk add --no-cache ca-certificates

# Copy the binary to the production image from the builder stage.
COPY --from=builder /app/server /server

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

5 changes: 5 additions & 0 deletions memorystore/redis/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/GoogleCloudPlatform/golang-samples/memorystore/redis

go 1.13

require github.com/gomodule/redigo v2.0.0+incompatible
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the redigo community has been spinning on what to do about this incompatible flag, possibly 2.0 is meant to be ignored.

Resolution in gomodule/redigo#366 or gomodule/redigo#440 are not clearly documented.

I wonder if it's since been fixed, and re-generating the go.mod and go.sum would help?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's fixed - I regenerated go.mod and go.sum

2 changes: 2 additions & 0 deletions memorystore/redis/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0=
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=