mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
feat(docker): use playwright install-deps for building docker image (#5995)
This commit is contained in:
parent
9473f39b0b
commit
28b14fc5f7
@ -47,6 +47,9 @@ export async function installDeps(browserTypes: string[]) {
|
||||
commands.push(['apt-get', 'install', '-y', '--no-install-recommends',
|
||||
...uniqueLibraries,
|
||||
].join(' '));
|
||||
const child = childProcess.spawn('sudo', ['--', 'sh', '-c', `${commands.join('; ')}`], { stdio: 'inherit' });
|
||||
const isRoot = (process.getuid() === 0);
|
||||
const child = isRoot ?
|
||||
childProcess.spawn('sh', ['-c', `${commands.join('; ')}`], { stdio: 'inherit' }) :
|
||||
childProcess.spawn('sudo', ['--', 'sh', '-c', `${commands.join('; ')}`], { stdio: 'inherit' });
|
||||
await new Promise(f => child.on('exit', f));
|
||||
}
|
||||
|
||||
@ -1,118 +1,5 @@
|
||||
FROM ubuntu:bionic
|
||||
|
||||
# === GENERATED BROWSER DEPENDENCIES ===
|
||||
|
||||
# (generated with ./updateDockerDeps.js)
|
||||
|
||||
# tools
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
xvfb
|
||||
|
||||
# chromium
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
fonts-liberation\
|
||||
libasound2\
|
||||
libatk-bridge2.0-0\
|
||||
libatk1.0-0\
|
||||
libatspi2.0-0\
|
||||
libcairo2\
|
||||
libcups2\
|
||||
libdbus-1-3\
|
||||
libdrm2\
|
||||
libegl1\
|
||||
libgbm1\
|
||||
libglib2.0-0\
|
||||
libgtk-3-0\
|
||||
libnspr4\
|
||||
libnss3\
|
||||
libpango-1.0-0\
|
||||
libx11-6\
|
||||
libxcb1\
|
||||
libxcomposite1\
|
||||
libxdamage1\
|
||||
libxext6\
|
||||
libxfixes3\
|
||||
libxrandr2\
|
||||
libxshmfence1
|
||||
|
||||
# firefox
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
ffmpeg\
|
||||
libatk1.0-0\
|
||||
libcairo-gobject2\
|
||||
libcairo2\
|
||||
libdbus-1-3\
|
||||
libdbus-glib-1-2\
|
||||
libfontconfig1\
|
||||
libfreetype6\
|
||||
libgdk-pixbuf2.0-0\
|
||||
libglib2.0-0\
|
||||
libgtk-3-0\
|
||||
libpango-1.0-0\
|
||||
libpangocairo-1.0-0\
|
||||
libpangoft2-1.0-0\
|
||||
libx11-6\
|
||||
libx11-xcb1\
|
||||
libxcb-shm0\
|
||||
libxcb1\
|
||||
libxcomposite1\
|
||||
libxcursor1\
|
||||
libxdamage1\
|
||||
libxext6\
|
||||
libxfixes3\
|
||||
libxi6\
|
||||
libxrender1\
|
||||
libxt6
|
||||
|
||||
# webkit
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
gstreamer1.0-libav\
|
||||
gstreamer1.0-plugins-bad\
|
||||
gstreamer1.0-plugins-base\
|
||||
gstreamer1.0-plugins-good\
|
||||
libatk-bridge2.0-0\
|
||||
libatk1.0-0\
|
||||
libbrotli1\
|
||||
libcairo2\
|
||||
libegl1\
|
||||
libenchant1c2a\
|
||||
libepoxy0\
|
||||
libfontconfig1\
|
||||
libfreetype6\
|
||||
libgdk-pixbuf2.0-0\
|
||||
libgl1\
|
||||
libgles2\
|
||||
libglib2.0-0\
|
||||
libgstreamer-gl1.0-0\
|
||||
libgstreamer1.0-0\
|
||||
libgtk-3-0\
|
||||
libharfbuzz-icu0\
|
||||
libharfbuzz0b\
|
||||
libhyphen0\
|
||||
libicu60\
|
||||
libjpeg-turbo8\
|
||||
libnotify4\
|
||||
libopenjp2-7\
|
||||
libopus0\
|
||||
libpango-1.0-0\
|
||||
libpng16-16\
|
||||
libsecret-1-0\
|
||||
libvpx5\
|
||||
libwayland-client0\
|
||||
libwayland-egl1\
|
||||
libwayland-server0\
|
||||
libwebp6\
|
||||
libwebpdemux2\
|
||||
libwoff1\
|
||||
libx11-6\
|
||||
libxcomposite1\
|
||||
libxdamage1\
|
||||
libxkbcommon0\
|
||||
libxml2\
|
||||
libxslt1.1
|
||||
|
||||
# === GENERATED BROWSER DEPENDENCIES END ===
|
||||
|
||||
# === INSTALL Node.js ===
|
||||
|
||||
# Install node14
|
||||
@ -137,6 +24,7 @@ RUN apt-get update && apt-get install -y python3.8 python3-pip && \
|
||||
# === BAKE BROWSERS INTO IMAGE ===
|
||||
|
||||
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# 1. Add tip-of-tree Playwright package to install its browsers.
|
||||
# The package should be built beforehand from tip-of-tree Playwright.
|
||||
@ -149,6 +37,7 @@ COPY ./playwright.tar.gz /tmp/playwright.tar.gz
|
||||
RUN mkdir /ms-playwright && \
|
||||
mkdir /tmp/pw && cd /tmp/pw && npm init -y && \
|
||||
npm i /tmp/playwright.tar.gz && \
|
||||
DEBIAN_FRONTEND=noninteractive npx playwright install-deps && \
|
||||
rm -rf /tmp/pw && rm /tmp/playwright.tar.gz && \
|
||||
chmod -R 777 /ms-playwright
|
||||
|
||||
|
||||
@ -1,118 +1,5 @@
|
||||
FROM ubuntu:focal
|
||||
|
||||
# === GENERATED BROWSER DEPENDENCIES ===
|
||||
|
||||
# (generated with ./updateDockerDeps.js)
|
||||
|
||||
# tools
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
xvfb
|
||||
|
||||
# chromium
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
fonts-liberation\
|
||||
libasound2\
|
||||
libatk-bridge2.0-0\
|
||||
libatk1.0-0\
|
||||
libatspi2.0-0\
|
||||
libcairo2\
|
||||
libcups2\
|
||||
libdbus-1-3\
|
||||
libdrm2\
|
||||
libegl1\
|
||||
libgbm1\
|
||||
libglib2.0-0\
|
||||
libgtk-3-0\
|
||||
libnspr4\
|
||||
libnss3\
|
||||
libpango-1.0-0\
|
||||
libx11-6\
|
||||
libxcb1\
|
||||
libxcomposite1\
|
||||
libxdamage1\
|
||||
libxext6\
|
||||
libxfixes3\
|
||||
libxrandr2\
|
||||
libxshmfence1
|
||||
|
||||
# firefox
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
ffmpeg\
|
||||
libatk1.0-0\
|
||||
libcairo-gobject2\
|
||||
libcairo2\
|
||||
libdbus-1-3\
|
||||
libdbus-glib-1-2\
|
||||
libfontconfig1\
|
||||
libfreetype6\
|
||||
libgdk-pixbuf2.0-0\
|
||||
libglib2.0-0\
|
||||
libgtk-3-0\
|
||||
libpango-1.0-0\
|
||||
libpangocairo-1.0-0\
|
||||
libpangoft2-1.0-0\
|
||||
libx11-6\
|
||||
libx11-xcb1\
|
||||
libxcb-shm0\
|
||||
libxcb1\
|
||||
libxcomposite1\
|
||||
libxcursor1\
|
||||
libxdamage1\
|
||||
libxext6\
|
||||
libxfixes3\
|
||||
libxi6\
|
||||
libxrender1\
|
||||
libxt6
|
||||
|
||||
# webkit
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
gstreamer1.0-libav\
|
||||
gstreamer1.0-plugins-bad\
|
||||
gstreamer1.0-plugins-base\
|
||||
gstreamer1.0-plugins-good\
|
||||
libatk-bridge2.0-0\
|
||||
libatk1.0-0\
|
||||
libcairo2\
|
||||
libegl1\
|
||||
libenchant1c2a\
|
||||
libepoxy0\
|
||||
libfontconfig1\
|
||||
libfreetype6\
|
||||
libgdk-pixbuf2.0-0\
|
||||
libgl1\
|
||||
libgles2\
|
||||
libglib2.0-0\
|
||||
libgstreamer-gl1.0-0\
|
||||
libgstreamer1.0-0\
|
||||
libgtk-3-0\
|
||||
libharfbuzz-icu0\
|
||||
libharfbuzz0b\
|
||||
libhyphen0\
|
||||
libicu66\
|
||||
libjpeg-turbo8\
|
||||
libnotify4\
|
||||
libopenjp2-7\
|
||||
libopus0\
|
||||
libpango-1.0-0\
|
||||
libpng16-16\
|
||||
libsecret-1-0\
|
||||
libsoup2.4-1\
|
||||
libvpx6\
|
||||
libwayland-client0\
|
||||
libwayland-egl1\
|
||||
libwayland-server0\
|
||||
libwebp6\
|
||||
libwebpdemux2\
|
||||
libwoff1\
|
||||
libx11-6\
|
||||
libxcomposite1\
|
||||
libxdamage1\
|
||||
libxkbcommon0\
|
||||
libxml2\
|
||||
libxslt1.1
|
||||
|
||||
# === GENERATED BROWSER DEPENDENCIES END ===
|
||||
|
||||
# === INSTALL Node.js ===
|
||||
|
||||
# Install node14
|
||||
@ -149,6 +36,7 @@ COPY ./playwright.tar.gz /tmp/playwright.tar.gz
|
||||
RUN mkdir /ms-playwright && \
|
||||
mkdir /tmp/pw && cd /tmp/pw && npm init -y && \
|
||||
npm i /tmp/playwright.tar.gz && \
|
||||
DEBIAN_FRONTEND=noninteractive npx playwright install-deps && \
|
||||
rm -rf /tmp/pw && rm /tmp/playwright.tar.gz && \
|
||||
chmod -R 777 /ms-playwright
|
||||
|
||||
|
||||
@ -1,37 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the 'License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const { deps } = require('../../lib/nativeDeps');
|
||||
for (const distro in deps) {
|
||||
const file = fs.readFileSync(require.resolve(`./Dockerfile.${distro}`), 'utf-8');
|
||||
const newContent = [];
|
||||
newContent.push('# === GENERATED BROWSER DEPENDENCIES ===');
|
||||
newContent.push('');
|
||||
newContent.push('# (generated with ./updateDockerDeps.js)');
|
||||
for (const browser in deps[distro]) {
|
||||
newContent.push('');
|
||||
newContent.push(`# ${browser}`);
|
||||
newContent.push(`RUN apt-get update && apt-get install -y --no-install-recommends \\`);
|
||||
newContent.push(' ' + deps[distro][browser].join('\\\n '));
|
||||
}
|
||||
newContent.push('');
|
||||
newContent.push('# === GENERATED BROWSER DEPENDENCIES END ===');
|
||||
const result = file.replace(/# === GENERATED BROWSER DEPENDENCIES ===[.\s\S]*# === GENERATED BROWSER DEPENDENCIES END ===/g, newContent.join('\n'));
|
||||
console.log(`Updating Dockerfile.${distro}`);
|
||||
fs.writeFileSync(require.resolve(`./Dockerfile.${distro}`), result);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user