godev/cmd/telemetrygodev: include telemetry module in docker build
The godev module includes a dependency on the telemetry module
so it must be included in the docker build context.
Change-Id: Idec72e2330520e2ad1488a4d8f682da88e17e7b6
Reviewed-on: https://go-review.googlesource.com/c/telemetry/+/500240
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/godev/cmd/telemetrygodev/Dockerfile b/godev/cmd/telemetrygodev/Dockerfile
index f027d5a..a7a3f25 100644
--- a/godev/cmd/telemetrygodev/Dockerfile
+++ b/godev/cmd/telemetrygodev/Dockerfile
@@ -24,20 +24,28 @@
#### Building binaries
# Set the working directory outside $GOPATH to ensure module mode is enabled.
-WORKDIR /src
+WORKDIR /telemetry
# Copy go.mods and go.sums into the container.
# If they don't change, which is the common case, then docker can
# cache these COPYs and the subsequent RUN.
COPY go.mod go.sum ./
+WORKDIR /telemetry/godev
+
+COPY go.mod go.sum ./
+
# Download the dependencies.
RUN go mod download
+WORKDIR /telemetry
+
# Copy the repo from local machine into Docker client’s current working
# directory, so that we can use it to build the binary.
# See .dockerignore at the repo root for excluded files.
-COPY . /src
+COPY . ./
+
+WORKDIR /telemetry/godev
# Build the telemetrygodev binary and put it in /app.
RUN go build -mod=readonly -o /app/telemetrygodev ./cmd/telemetrygodev
diff --git a/godev/cmd/telemetrygodev/cloudbuild.yaml b/godev/cmd/telemetrygodev/cloudbuild.yaml
index eb8ffca..b38a5bc 100644
--- a/godev/cmd/telemetrygodev/cloudbuild.yaml
+++ b/godev/cmd/telemetrygodev/cloudbuild.yaml
@@ -5,13 +5,12 @@
steps:
# Build the container image
- name: "gcr.io/cloud-builders/docker"
- dir: "godev"
args:
- "build"
- "-t"
- "gcr.io/$PROJECT_ID/telemetrygodev:$COMMIT_SHA"
- "-f"
- - "cmd/telemetrygodev/Dockerfile"
+ - "godev/cmd/telemetrygodev/Dockerfile"
- "."
# Push the container image to Container Registry
- name: "gcr.io/cloud-builders/docker"