playwright-community / playwright-go

Playwright for Go a browser automation library to control Chromium, Firefox and WebKit with a single API.
https://playwright-community.github.io/playwright-go/
MIT License
1.94k stars 144 forks source link

could not launch playwright when updating to v0.4101.0 #409

Closed abdelilahakebli closed 3 months ago

abdelilahakebli commented 5 months ago

Could not launch playwright when updating to v0.4101.0 using docker

RUN go mod download
RUN go run github.com/playwright-community/playwright-go/cmd/playwright@latest install --with-deps
RUN make build
2024/01/24 15:46:34 could not launch playwright: could not start driver: fork/exec /root/.cache/ms-playwright-go/1.40.1/playwright.sh: no such file or directory

Rolling back to v0.4001.0 fixed the issue for me

RUN go mod download
RUN go run github.com/playwright-community/playwright-go/cmd/playwright@v0.4001.0 install --with-deps
RUN make build
canstand commented 5 months ago

take a look go.mod, you need run go get -u github.com/playwright-community/playwright-go upgrade, not only install new driver and deps

keremcankabadayi commented 4 months ago

is there any working Dockerfile example with alpine or ubuntu?

dbelozerovx1 commented 3 months ago

same problem

canstand commented 3 months ago

Look at the example below. Please make sure the playwright-go version in go.mod is the same as v0.4201.0 in the Dockerfile.

# Step 1: Modules caching
FROM golang:1.21 as modules
COPY go.mod go.sum /modules/
WORKDIR /modules
RUN go mod download

# Step 2: Build
FROM golang:1.21 as builder
COPY --from=modules /go/pkg /go/pkg
COPY . /app
WORKDIR /app
RUN go install github.com/playwright-community/playwright-go/cmd/playwright@v0.4201.0
RUN GOOS=linux GOARCH=amd64 \
    go build -o /bin/app

# Step 3: Final
FROM ubuntu:jammy
COPY --from=builder /go/bin/playwright /playwright
COPY --from=builder /bin/app /app
RUN apt-get update && apt-get install -y ca-certificates tzdata \
    && /playwright install --with-deps chromium \
    && rm -rf /var/lib/apt/lists/*
CMD ["/app"]
canstand commented 3 months ago

Take a look at https://github.com/playwright-community/playwright-go#docker