最近写的一个自动化程序需要go-playwright支持,但开发和部署环境是RockyLinux9, playwright安装依赖的时候是基于Ubuntu的,下面是在Rockey Linux环境下的解决办法。
安装Distrobox
dnf install epel-release
dnf install distrobox
创建ubuntu容器
distrobox create -n ubuntu --image ubuntu:24.04
进入ubuntu容器
distrobox enter ubuntu
在容器中安装golang,playwright及其依赖
wget https://golang.google.cn/dl/go1.25.5.linux-amd64.tar.gz && \
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.25.5.linux-amd64.tar.gz && \
export GOPROXY=https://goproxy.cn,direct && \
go install github.com/playwright-community/playwright-go/cmd/playwright@latest && \
playwright install --with-deps
运行程序
distrobox enter ubuntu -- [执行的命令]