From d7c58ecbb852e57749a5357832ddc8e7f4ad59b2 Mon Sep 17 00:00:00 2001 From: Yasuaki Uechi Date: Thu, 9 Jan 2020 08:41:13 +0900 Subject: [PATCH] chore(docker): remove chrome installation script Ref: https://github.com/vivliostyle/vivliostyle-cli/pull/32#issuecomment-570953172 --- Dockerfile | 36 ++++++++---------------------------- Makefile | 10 ++++++++++ src/lib/build.ts | 1 + 3 files changed, 19 insertions(+), 28 deletions(-) create mode 100644 Makefile diff --git a/Dockerfile b/Dockerfile index ac907b79..cea7b3d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,36 +1,16 @@ -FROM node:10-slim -LABEL maintainer "spring-raining " - -# Revision number is referenced from puppeteer -# https://github.com/GoogleChrome/puppeteer/releases -ARG chromium_revision=564778 +FROM node:12-slim +LABEL maintainer "Vivliostyle Foundation " RUN set -x \ && apt-get update \ && apt-get install -y --no-install-recommends \ libasound2-dev libgtk-3-0 libnss3-dev libx11-xcb-dev libxss-dev libxtst-dev \ - wget unzip \ - && cd /opt \ - && wget -q https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/${chromium_revision}/chrome-linux.zip \ - && unzip -q chrome-linux.zip \ - && chmod -R +rx chrome-linux \ - && ln -s /opt/chrome-linux/chrome /usr/local/bin/chromium-browser \ - && ln -s /opt/chrome-linux/chrome /usr/local/bin/chromium \ - && rm -rf /opt/chrome-linux.zip /var/lib/apt/lists/ /src/*.deb + ghostscript poppler-utils -ADD . /opt/vivliostyle-cli WORKDIR /opt/vivliostyle-cli +COPY package.json yarn.lock /opt/vivliostyle-cli/ +RUN yarn install +COPY . /opt/vivliostyle-cli +RUN yarn build && yarn link -RUN groupadd -r vivliostyle \ - && useradd -s /bin/bash -r -m -g vivliostyle -G audio,video vivliostyle \ - && mkdir -p /home/vivliostyle/Downloads \ - && chown -R vivliostyle:vivliostyle /home/vivliostyle \ - && chown -R vivliostyle:vivliostyle /opt/vivliostyle-cli - -USER vivliostyle -RUN set -x \ - && yarn install \ - && yarn build - -ENTRYPOINT [ "./dist/cli.js" ] -CMD [] +ENTRYPOINT [ "vivliostyle" ] diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..7eaba4e8 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +default: test + +build: + docker build -t vivliostyle/cli . + +test: build + docker run --rm -it vivliostyle/cli build tests/fixtures/wood --no-sandbox -b -s A4 -o test.pdf + +run: build + docker run --rm -it --entrypoint bash vivliostyle/cli diff --git a/src/lib/build.ts b/src/lib/build.ts index 85a0b825..eefb43d7 100644 --- a/src/lib/build.ts +++ b/src/lib/build.ts @@ -65,6 +65,7 @@ export default async function run({ log(`Launching build environment... `); const browser = await puppeteer.launch({ headless: true, + // Why `--no-sandbox` flag? Running Chrome as root without --no-sandbox is not supported. See https://crbug.com/638180. args: [sandbox ? '' : '--no-sandbox'], }); const version = await browser.version();