Skip to content

Commit

Permalink
chore(docker): remove chrome installation script
Browse files Browse the repository at this point in the history
  • Loading branch information
uetchy committed Jan 8, 2020
1 parent 0fd7b6a commit d7c58ec
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 28 deletions.
36 changes: 8 additions & 28 deletions Dockerfile
@@ -1,36 +1,16 @@
FROM node:10-slim
LABEL maintainer "spring-raining <harusamex.com@gmail.com>"

# Revision number is referenced from puppeteer
# https://github.com/GoogleChrome/puppeteer/releases
ARG chromium_revision=564778
FROM node:12-slim
LABEL maintainer "Vivliostyle Foundation <mail@vivliostyle.org>"

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" ]
10 changes: 10 additions & 0 deletions 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
1 change: 1 addition & 0 deletions src/lib/build.ts
Expand Up @@ -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();
Expand Down

0 comments on commit d7c58ec

Please sign in to comment.