Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

chore(playwright-service): run chromium as non-root (#4171)

tomsideguidedeea077f111d
diff --git a/apps/playwright-service-ts/Dockerfile b/apps/playwright-service-ts/Dockerfile
index 7f72c38b0..371ed70a1 100644
--- a/apps/playwright-service-ts/Dockerfile
+++ b/apps/playwright-service-ts/Dockerfile
@@ -19,9 +19,14 @@ RUN pnpm exec playwright install chromium --with-deps
RUN pnpm run build
+RUN chown -R node:node /usr/src/app \
+ && chmod -R a+rX /usr/local/share/playwright
+
ARG PORT
ENV PORT=${PORT}
EXPOSE ${PORT}
+USER node
+
CMD [ "pnpm", "start" ]
diff --git a/docker-compose.yaml b/docker-compose.yaml
index 67b7fec64..e2ade0104 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -76,6 +76,10 @@ services:
MAX_CONCURRENT_PAGES: ${CRAWL_CONCURRENT_REQUESTS:-10}
networks:
- backend
+ security_opt:
+ - no-new-privileges:true
+ cap_drop:
+ - ALL
# Resource limits for Docker Compose (not Swarm)
cpus: 2.0
mem_limit: 4G
diff --git a/examples/kubernetes/cluster-install/playwright-service.yaml b/examples/kubernetes/cluster-install/playwright-service.yaml
index 5298a4584..554951cbe 100644
--- a/examples/kubernetes/cluster-install/playwright-service.yaml
+++ b/examples/kubernetes/cluster-install/playwright-service.yaml
@@ -22,10 +22,21 @@ spec:
spec:
imagePullSecrets:
- name: docker-registry-secret
+ securityContext:
+ runAsNonRoot: true
+ runAsUser: 1000
+ runAsGroup: 1000
+ seccompProfile:
+ type: RuntimeDefault
containers:
- name: playwright-service
image: ghcr.io/firecrawl/playwright-service:latest
imagePullPolicy: Always
+ securityContext:
+ allowPrivilegeEscalation: false
+ capabilities:
+ drop:
+ - ALL
ports:
- containerPort: 3000
envFrom: