Skip to content

Commit

Permalink
fix(agent): fixing agent image for playwrightt (kubeshop#3926)
Browse files Browse the repository at this point in the history
* fix(agent): fixing agent image for playwrightt

* fix(agent): fixing agent image for playwrightt
  • Loading branch information
xoscar authored Jul 8, 2024
1 parent 90116ff commit 2a9475c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
23 changes: 23 additions & 0 deletions Dockerfile.agent
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@ COPY ./tracetest /app/tracetest
COPY ./agent/entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh

USER root
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/main" > /etc/apk/repositories \
&& echo "https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
&& echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& echo "https://dl-cdn.alpinelinux.org/alpine/v3.16/main" >> /etc/apk/repositories \
&& echo "https://dl-cdn.alpinelinux.org/alpine/v3.16/community" \
&& apk upgrade -U -a \
&& apk add \
libstdc++ \
chromium \
harfbuzz \
nss \
freetype \
ttf-freefont \
font-noto-emoji \
wqy-zenhei \
&& rm -rf /var/cache/* \
&& mkdir /var/cache/apk

# Playwright
ENV PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/lib/chromium/chromium \
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1

# Setup additional runtimes used by triggers
RUN apk add nodejs npm

Expand Down
21 changes: 12 additions & 9 deletions agent/workers/trigger/playwrightengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,26 @@ func start(traceId, spanId, url, method string) (string, error) {
return "", err
}

res, err := execCommand(
app,
"playwright",
"install",
)

if err != nil {
return "", fmt.Errorf("error installing playwright: %s, %w", res, err)
if os.Getenv("PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD") != "1" {
res, err := execCommand(
app,
"playwright",
"install",
)

if err != nil {
return "", fmt.Errorf("error installing playwright: %s, %w", res, err)
}
}

path, err := filepath.Abs(fmt.Sprintf("%s/%s", wd, scriptPath))
if err != nil {
return "", err
}

res, err = execCommand(
res, err := execCommand(
app,
"--yes",
libName,
"--scriptPath",
path,
Expand Down

0 comments on commit 2a9475c

Please sign in to comment.