Skip to content

Commit 2d66e2d

Browse files
committed
Add playwright in helm
1 parent 750acf5 commit 2d66e2d

File tree

6 files changed

+110
-3
lines changed

6 files changed

+110
-3
lines changed

deploy/helm/ifrcgo-helm/templates/config/configmap.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ data:
2222
AZURE_STORAGE_ENABLED: "true"
2323
{{- end }}
2424

25+
{{- if .Values.playwright.enabled }}
26+
PLAYWRIGHT_SERVER_URL: "ws://{{ template "ifrcgo-helm.fullname" . }}-playwright:{{ .Values.playwright.containerPort }}/"
27+
{{- else }}
28+
PLAYWRIGHT_SERVER_URL: {{ required "env.PLAYWRIGHT_SERVER_URL" .Values.env.PLAYWRIGHT_SERVER_URL | quote }}
29+
{{- end }}
30+
2531
CACHE_MIDDLEWARE_SECONDS: {{ .Values.env.CACHE_MIDDLEWARE_SECONDS | quote }}
2632
DJANGO_DEBUG: {{ .Values.env.DJANGO_DEBUG | quote }}
2733
ELASTIC_SEARCH_HOST: {{ default (printf "elasticsearch://%s-elasticsearch:9200" (include "ifrcgo-helm.fullname" .)) .Values.env.ELASTIC_SEARCH_HOST | quote }}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{{- if .Values.playwright.enabled }}
2+
3+
apiVersion: apps/v1
4+
kind: Deployment
5+
metadata:
6+
name: {{ template "ifrcgo-helm.fullname" . }}-playwright
7+
labels:
8+
component: playwright-deployment
9+
environment: {{ .Values.environment }}
10+
release: {{ .Release.Name }}
11+
spec:
12+
replicas: {{ .Values.playwright.replicaCount }}
13+
selector:
14+
matchLabels:
15+
app: {{ template "ifrcgo-helm.name" . }}
16+
release: {{ .Release.Name }}
17+
run: {{ .Release.Name }}-playwright
18+
template:
19+
metadata:
20+
labels:
21+
app: {{ template "ifrcgo-helm.name" . }}
22+
release: {{ .Release.Name }}
23+
run: {{ .Release.Name }}-playwright
24+
spec:
25+
containers:
26+
- name: playwright
27+
image: "{{ .Values.playwright.image.name }}:{{ .Values.playwright.image.tag }}"
28+
workingDir: /home/pwuser
29+
securityContext:
30+
runAsUser: 1001 # pwuser
31+
runAsNonRoot: true
32+
command:
33+
- "bash"
34+
- "-xc"
35+
- |
36+
PLAYWRIGHT_VERSION=$(cat /ms-playwright/.docker-info | grep -oP '"driverVersion": "\K[^"]+')
37+
npx -y playwright@$$PLAYWRIGHT_VERSION run-server --host 0.0.0.0 --port {{ .Values.playwright.containerPort }}
38+
ports:
39+
- name: http
40+
containerPort: {{ .Values.playwright.containerPort }}
41+
protocol: TCP
42+
# livenessProbe: # TODO:
43+
# httpGet:
44+
# path: /
45+
# port: {{ .Values.playwright.containerPort }}
46+
# initialDelaySeconds: 10180
47+
# periodSeconds: 5
48+
resources:
49+
requests:
50+
cpu: {{ .Values.playwright.resources.requests.cpu }}
51+
memory: {{ .Values.playwright.resources.requests.memory }}
52+
limits:
53+
cpu: {{ .Values.playwright.resources.limits.cpu }}
54+
memory: {{ .Values.playwright.resources.limits.memory }}
55+
56+
{{- end }}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{- if .Values.playwright.enabled -}}
2+
3+
apiVersion: v1
4+
kind: Service
5+
metadata:
6+
name: {{ template "ifrcgo-helm.fullname" . }}-playwright
7+
labels:
8+
app: {{ template "ifrcgo-helm.name" . }}
9+
component: playwright-service
10+
environment: {{ .Values.environment }}
11+
release: {{ .Release.Name }}
12+
spec:
13+
type: ClusterIP
14+
ports:
15+
- protocol: TCP
16+
port: {{ .Values.playwright.containerPort }}
17+
targetPort: {{ .Values.playwright.containerPort }}
18+
nodePort: null
19+
selector:
20+
app: {{ template "ifrcgo-helm.name" . }}
21+
release: {{ .Release.Name }}
22+
run: {{ .Release.Name }}-playwright
23+
24+
{{- end }}

deploy/helm/ifrcgo-helm/values.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,23 @@ postgresql:
149149
enabled: true
150150
size: 8Gi
151151

152+
playwright:
153+
enabled: rue
154+
replicaCount: 1
155+
containerPort: 3000
156+
image:
157+
# NOTE: Make sure this matches with pyproject playwright dependency and root docker-compose
158+
name: 'mcr.microsoft.com/playwright'
159+
tag: 'v1.50.0-noble'
160+
pullPolicy: 'IfNotPresent'
161+
resources:
162+
requests:
163+
cpu: "0.1"
164+
memory: 1Gi
165+
limits:
166+
cpu: "2"
167+
memory: 2Gi
168+
152169
api:
153170
domain: "go-staging.ifrc.org"
154171
tls:

docker-compose.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,16 @@ services:
7777
volumes:
7878
- redis-data:/data
7979

80-
# NOTE: Make sure this matches with pyproject playwright dependency
80+
# NOTE: Make sure this matches with pyproject playwright dependency and helm
8181
playwright:
8282
image: mcr.microsoft.com/playwright:v1.50.0-noble
8383
working_dir: /home/pwuser
8484
user: pwuser
85-
command: bash -c "npx -y [email protected] run-server --port 3000 --host 0.0.0.0"
85+
command: >
86+
bash -xc "
87+
PLAYWRIGHT_VERSION=$(cat /ms-playwright/.docker-info | grep -oP '\"driverVersion\": \"\\K[^\"]+')
88+
npx -y playwright@$$PLAYWRIGHT_VERSION run-server --port 3000 --host 0.0.0.0
89+
"
8690
extra_hosts:
8791
- "host.docker.internal:host-gateway"
8892

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ dev = [
9696
"django-stubs",
9797
]
9898
celery = [
99-
"playwright==1.50.0" # NOTE: Make sure this matches with running playwright server instance
99+
"playwright==1.50.0" # NOTE: Make sure this matches with root docker-compose and helm
100100
]
101101

102102
[tool.pyright]

0 commit comments

Comments
 (0)