Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
161 changes: 161 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@

# Docker build args
variable "IMAGE_REPO" {default = "ghcr.io/riptideslabs/microservices-demo"}
variable "IMAGE_TAG" {default = "test"}

function "get_tag" {
params = [tags, name]
result = coalescelist(tags, ["${IMAGE_REPO}/${name}:${IMAGE_TAG}"])
}

# docker-bake.hcl
group "default" {
targets = [
"emailservice",
"productcatalogservice",
"recommendationservice",
"shoppingassistantservice",
"shippingservice",
"checkoutservice",
"paymentservice",
"currencyservice",
"cartservice",
"frontend",
"adservice",
"loadgenerator"
]
}

target "_common" {
output = [
"type=image",
]
platforms = [
"linux/arm64",
"linux/amd64",
]
}

target "docker-metadata-action" {
tags = []
}

target "emailservice" {
context = "src/emailservice"
dockerfile = "./Dockerfile"
inherits = [
"_common",
"docker-metadata-action",
]
tags = get_tag(target.docker-metadata-action.tags, "${target.emailservice.name}")
}

target "productcatalogservice" {
context = "src/productcatalogservice"
dockerfile = "./Dockerfile"
inherits = [
"_common",
"docker-metadata-action",
]
tags = get_tag(target.docker-metadata-action.tags, "${target.productcatalogservice.name}")
}

target "recommendationservice" {
context = "src/recommendationservice"
dockerfile = "./Dockerfile"
inherits = [
"_common",
"docker-metadata-action",
]
tags = get_tag(target.docker-metadata-action.tags, "${target.recommendationservice.name}")
}

target "shoppingassistantservice" {
context = "src/shoppingassistantservice"
dockerfile = "./Dockerfile"
inherits = [
"_common",
"docker-metadata-action",
]
tags = get_tag(target.docker-metadata-action.tags, "${target.shoppingassistantservice.name}")
}

target "shippingservice" {
context = "src/shippingservice"
dockerfile = "./Dockerfile"
inherits = [
"_common",
"docker-metadata-action",
]
tags = get_tag(target.docker-metadata-action.tags, "${target.shippingservice.name}")
}

target "checkoutservice" {
context = "src/checkoutservice"
dockerfile = "./Dockerfile"
inherits = [
"_common",
"docker-metadata-action",
]
tags = get_tag(target.docker-metadata-action.tags, "${target.checkoutservice.name}")
}

target "paymentservice" {
context = "src/paymentservice"
dockerfile = "./Dockerfile"
inherits = [
"_common",
"docker-metadata-action",
]
tags = get_tag(target.docker-metadata-action.tags, "${target.paymentservice.name}")
}

target "currencyservice" {
context = "src/currencyservice"
dockerfile = "./Dockerfile"
inherits = [
"_common",
"docker-metadata-action",
]
tags = get_tag(target.docker-metadata-action.tags, "${target.currencyservice.name}")
}

target "cartservice" {
context = "src/cartservice/src"
dockerfile = "./Dockerfile"
inherits = [
"_common",
"docker-metadata-action",
]
tags = get_tag(target.docker-metadata-action.tags, "${target.cartservice.name}")
}

target "frontend" {
context = "src/frontend"
dockerfile = "./Dockerfile"
inherits = [
"_common",
"docker-metadata-action",
]
tags = get_tag(target.docker-metadata-action.tags, "${target.frontend.name}")
}

target "adservice" {
context = "src/adservice"
dockerfile = "./Dockerfile"
inherits = [
"_common",
"docker-metadata-action",
]
tags = get_tag(target.docker-metadata-action.tags, "${target.adservice.name}")
}

target "loadgenerator" {
context = "src/loadgenerator"
dockerfile = "./Dockerfile"
inherits = [
"_common",
"docker-metadata-action",
]
tags = get_tag(target.docker-metadata-action.tags, "${target.loadgenerator.name}")
}
4 changes: 2 additions & 2 deletions helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.10.3
version: 0.10.4

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v0.10.3"
appVersion: "v0.10.4"
2 changes: 1 addition & 1 deletion helm-chart/templates/loadgenerator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ spec:
- ALL
privileged: false
readOnlyRootFilesystem: true
image: busybox:latest@sha256:37f7b378a29ceb4c551b1b5582e27747b855bbfaa73fa11914fe0df028dc581f
image: busybox:latest
env:
- name: FRONTEND_ADDR
value: "{{ .Values.frontend.name }}:80"
Expand Down
135 changes: 135 additions & 0 deletions helm-chart/templates/shoppingassistantservice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{{- if .Values.shoppingAssistantService.create }}
{{- if .Values.serviceAccounts.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Values.shoppingAssistantService.name }}
namespace: {{ .Release.Namespace }}
{{- if not .Values.serviceAccounts.annotationsOnlyForCartservice }}
{{- with .Values.serviceAccounts.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

---
{{- end }}

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.shoppingAssistantService.name }}
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Values.shoppingAssistantService.name }}
spec:
selector:
matchLabels:
app: {{ .Values.shoppingAssistantService.name }}
template:
metadata:
labels:
app: {{ .Values.shoppingAssistantService.name }}
spec:
{{- if .Values.serviceAccounts.create }}
serviceAccountName: {{ .Values.shoppingAssistantService.name }}
{{- else }}
serviceAccountName: default
{{- end }}
terminationGracePeriodSeconds: 5
{{- if .Values.securityContext.enable }}
securityContext:
fsGroup: 1000
runAsGroup: 1000
runAsNonRoot: true
runAsUser: 1000
{{- if .Values.seccompProfile.enable }}
seccompProfile:
type: {{ .Values.seccompProfile.type }}
{{- end }}
{{- end }}
containers:
- name: server
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
privileged: false
image: {{ .Values.images.repository }}/{{ .Values.shoppingAssistantService.name }}:{{ .Values.images.tag | default .Chart.AppVersion }}
ports:
- containerPort: 8080
env:
- name: PORT
value: "8080"
- name: GOOGLE_APPLICATION_CREDENTIALS
value: "/var/secrets/google/key.json"
- name: ALLOYDB_CLUSTER_NAME
value: {{ .Values.shoppingAssistantService.alloydbClusterName | quote }}
- name: ALLOYDB_INSTANCE_NAME
value: {{ .Values.shoppingAssistantService.alloydbInstanceName | quote }}
- name: ALLOYDB_DATABASE_NAME
value: {{ .Values.shoppingAssistantService.alloydbDatabaseName | quote }}
- name: ALLOYDB_TABLE_NAME
value: {{ .Values.shoppingAssistantService.alloydbTableName | quote }}
- name: ALLOYDB_SECRET_NAME
value: {{ .Values.shoppingAssistantService.alloydbSecretName | quote }}
- name: PROJECT_ID
value: {{ .Values.shoppingAssistantService.projectId | quote }}
- name: REGION
value: {{ .Values.shoppingAssistantService.region | quote }}
{{- if .Values.opentelemetryCollector.create }}
- name: COLLECTOR_SERVICE_ADDR
value: "{{ .Values.opentelemetryCollector.name }}:4317"
- name: OTEL_SERVICE_NAME
value: "{{ .Values.shoppingAssistantService.name }}"
{{- end }}
{{- if .Values.googleCloudOperations.tracing }}
- name: ENABLE_TRACING
value: "1"
{{- end }}
{{- if not .Values.googleCloudOperations.profiler }}
- name: DISABLE_PROFILER
value: "1"
{{- end }}
volumeMounts:
- name: gcp-key
mountPath: /var/secrets/google
readOnly: true
volumes:
- name: gcp-key
secret:
secretName: {{ .Values.shoppingAssistantService.name }}-gcp-key
resources:
{{- toYaml .Values.shoppingAssistantService.resources | nindent 10 }}

---

apiVersion: v1
kind: Service
metadata:
name: {{ .Values.shoppingAssistantService.name }}
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Values.shoppingAssistantService.name }}
spec:
type: ClusterIP
selector:
app: {{ .Values.shoppingAssistantService.name }}
ports:
- name: http
port: 80
targetPort: 8080


# Make sure to create a secret like this one with the GCP credentials
# apiVersion: v1
# kind: Secret
# metadata:
# name: {{ .Values.shoppingAssistantService.name }}-gcp-key
# namespace: {{ .Release.Namespace }}
# type: Opaque
# data:
# key.json: ""

{{ end -}}
19 changes: 15 additions & 4 deletions helm-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Declare variables to be passed into your templates.

images:
repository: us-central1-docker.pkg.dev/google-samples/microservices-demo
repository: ghcr.io/riptideslabs/microservices-demo
# Overrides the image tag whose default is the chart appVersion.
tag: ""

Expand Down Expand Up @@ -213,8 +213,19 @@ cartDatabase:
endpointPort: ""
certificate: ""

# @TODO: This service is not currently available in Helm.
# https://github.com/GoogleCloudPlatform/microservices-demo/tree/main/kustomize/components/shopping-assistant
shoppingAssistantService:
create: false
create: true
name: shoppingassistantservice
alloydbClusterName: microservices-demo
alloydbInstanceName: microservices-demo-primary
alloydbDatabaseName: shoppingassistant
alloydbTableName: catalog_items
projectId: ""
region: europe-west1
resources:
requests:
cpu: 100m
memory: 64Mi
limits:
cpu: 200m
memory: 128Mi
4 changes: 4 additions & 0 deletions skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,13 @@ requires:
- configs:
- app
build:
platforms: ["linux/amd64", "linux/arm64"]
artifacts:
- image: loadgenerator
context: src/loadgenerator
local:
useDockerCLI: true
useBuildkit: true
manifests:
rawYaml:
- ./kubernetes-manifests/loadgenerator.yaml
Expand Down
4 changes: 2 additions & 2 deletions src/adservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM --platform=$BUILDPLATFORM eclipse-temurin:21.0.5_11-jdk@sha256:a20cfa6afdbf57ff2c4de77ae2d0e3725a6349f1936b5ad7c3d1b06f6d1b840a AS builder
FROM eclipse-temurin:21.0.7_6-jdk AS builder

WORKDIR /app

Expand All @@ -25,7 +25,7 @@ COPY . .
RUN chmod +x gradlew
RUN ./gradlew installDist

FROM eclipse-temurin:21.0.5_11-jre-alpine@sha256:4300bfe1e11f3dfc3e3512f39939f9093cf18d0e581d1ab1ccd0512f32fe33f0
FROM eclipse-temurin:21.0.7_6-jre-alpine

# @TODO: https://github.com/GoogleCloudPlatform/microservices-demo/issues/2517
# Download Stackdriver Profiler Java agent
Expand Down
Loading