diff --git a/README.md b/README.md index b097c5f..bdc5f7e 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,8 @@ Find **Protocol Buffers Descriptions** at the [`./pb` directory](./pb). `image:` fields with `gcr.io/[...]` and change them to your own GCP project ID. -6. Run `skaffold run` from the root of this repository. This command: +6. Run `./deploy.sh` from the root of this repository. This script: + - generates source context for cloud debugger - builds the container images - pushes them to GCR - applies the `./kubernetes-manifests` deploying the application to diff --git a/depoly.sh b/depoly.sh new file mode 100755 index 0000000..e99589b --- /dev/null +++ b/depoly.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Fist generate code context for the cloud debugger +gcloud debug source gen-repo-info-file +for module in src/*; do + cp source-context.json "$module" +done + +# Now deploy on GKE +skaffold run diff --git a/src/adservice/Dockerfile b/src/adservice/Dockerfile index 7b41366..497f154 100644 --- a/src/adservice/Dockerfile +++ b/src/adservice/Dockerfile @@ -11,10 +11,19 @@ RUN ./gradlew installDist FROM openjdk:8-alpine +RUN apk add --update --no-cache \ + gcc \ + linux-headers \ + libc6-compat + RUN GRPC_HEALTH_PROBE_VERSION=v0.2.0 && \ wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ chmod +x /bin/grpc_health_probe +RUN mkdir -p /opt/cdbg +RUN wget -qO- https://storage.googleapis.com/cloud-debugger/compute-java/debian-wheezy/cdbg_java_agent_gce.tar.gz | \ + tar xvz -C /opt/cdbg + WORKDIR /app COPY --from=builder /app . diff --git a/src/adservice/build.gradle b/src/adservice/build.gradle index 11e1be4..736522e 100644 --- a/src/adservice/build.gradle +++ b/src/adservice/build.gradle @@ -112,7 +112,11 @@ task adService(type: CreateStartScripts) { outputDir = new File(project.buildDir, 'tmp') classpath = jar.outputs.files + project.configurations.runtime defaultJvmOpts = - ["-Dlog4j2.contextDataInjector=io.opencensus.contrib.logcorrelation.log4j2.OpenCensusTraceContextDataInjector"] + ["-Dlog4j2.contextDataInjector=io.opencensus.contrib.logcorrelation.log4j2.OpenCensusTraceContextDataInjector", + "-agentpath:/opt/cdbg/cdbg_java_agent.so", + "-Dcom.google.cdbg.module=adservice", + "-Dcom.google.cdbg.version=1.0.0" + ] } task adServiceClient(type: CreateStartScripts) { diff --git a/src/productcatalogservice/Dockerfile b/src/productcatalogservice/Dockerfile index 82deb04..558151c 100644 --- a/src/productcatalogservice/Dockerfile +++ b/src/productcatalogservice/Dockerfile @@ -1,5 +1,5 @@ FROM golang:1.10-alpine AS builder -RUN apk add --no-cache ca-certificates git && \ +RUN apk add --no-cache ca-certificates git gcc g++ && \ wget -qO/go/bin/dep https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 && \ chmod +x /go/bin/dep @@ -11,16 +11,27 @@ COPY Gopkg.* ./ RUN dep ensure --vendor-only -v COPY . . -RUN go build -o /productcatalogservice . +RUN go build -gcflags=all='-N -l' -o /productcatalogservice . FROM alpine AS release -RUN apk add --no-cache ca-certificates +RUN apk add --no-cache ca-certificates \ + libc6-compat + RUN GRPC_HEALTH_PROBE_VERSION=v0.2.0 && \ wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ chmod +x /bin/grpc_health_probe + WORKDIR /productcatalogservice + +RUN wget -O go-cloud-debug https://storage.googleapis.com/cloud-debugger/compute-go/go-cloud-debug \ + && chmod 0755 go-cloud-debug + COPY --from=builder /productcatalogservice ./server COPY products.json . -EXPOSE 3550 -ENTRYPOINT ["/productcatalogservice/server"] +COPY source-context.json . + +EXPOSE 3550 +ENTRYPOINT ["./go-cloud-debug", "-sourcecontext=source-context.json", \ + "-appmodule=productcatalogservice", "-appversion=1.0.0" , \ + "--", "/productcatalogservice/server"] diff --git a/src/recommendationservice/source-context.json b/src/recommendationservice/source-context.json deleted file mode 100644 index 4b8216b..0000000 --- a/src/recommendationservice/source-context.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "git": { - "revisionId": "1fe7f8dcec94e4c90a2ce8c3c9652eb38152bb46", - "url": "git@github.com:hrasadi/microservices-demo.git" - } -} \ No newline at end of file