From 2a9475c3fd99cea8674083e5dc42e73d8be38604 Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Mon, 8 Jul 2024 16:32:55 -0600 Subject: [PATCH] fix(agent): fixing agent image for playwrightt (#3926) * fix(agent): fixing agent image for playwrightt * fix(agent): fixing agent image for playwrightt --- Dockerfile.agent | 23 +++++++++++++++++++++++ agent/workers/trigger/playwrightengine.go | 21 ++++++++++++--------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/Dockerfile.agent b/Dockerfile.agent index eb314fbdea..682938f1d1 100644 --- a/Dockerfile.agent +++ b/Dockerfile.agent @@ -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 diff --git a/agent/workers/trigger/playwrightengine.go b/agent/workers/trigger/playwrightengine.go index 63cafb8e2e..a7c872858a 100644 --- a/agent/workers/trigger/playwrightengine.go +++ b/agent/workers/trigger/playwrightengine.go @@ -81,14 +81,16 @@ 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)) @@ -96,8 +98,9 @@ func start(traceId, spanId, url, method string) (string, error) { return "", err } - res, err = execCommand( + res, err := execCommand( app, + "--yes", libName, "--scriptPath", path,