Skip to content

Commit

Permalink
Add Puppeteer verification script and update README maintainer info
Browse files Browse the repository at this point in the history
  • Loading branch information
athrvk committed Dec 7, 2024
1 parent f36f1fc commit 3ba9a90
Show file tree
Hide file tree
Showing 6 changed files with 1,616 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ jobs:
images: calibre-puppeteer-base

- name: Build the Docker image
run: docker build . --file Dockerfile --tag calibre-puppeteer-base:${{ steps.meta.outputs.tags }}
run: docker build . --file Dockerfile --tag athrvk/calibre-puppeteer-base:${{ steps.meta.outputs.tags }}

- name: Verification step
run: |
# Run Calibre version command to verify installation
docker run --rm calibre-puppeteer-base:${{ steps.meta.outputs.tags }} ebook-convert --version
docker run --rm athrvk/calibre-puppeteer-base:${{ steps.meta.outputs.tags }} ebook-convert --version
# Run Puppeteer to verify installation
docker run --rm calibre-puppeteer-base:${{ steps.meta.outputs.tags }} node -e "const browser = require('puppeteer').launch(); console.log('Puppeteer works')"
docker run --rm --security-opt seccomp=chrome.json athrvk/calibre-puppeteer-base:${{ steps.meta.outputs.tags }} node -e "const browser = require('puppeteer').launch(); console.log('Puppeteer works')"
- name: Build and push Docker image
if: success() # Ensures this step runs only if the previous steps are successful
Expand Down
64 changes: 49 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ ENV DEBIAN_FRONTEND=noninteractive
# Install system dependencies
RUN apt-get update && apt-get install -y \
# Basic utilities
curl \
wget \
xz-utils \
gnupg \
# X11 and GUI dependencies
libx11-xcb1 \
Expand All @@ -30,6 +31,12 @@ RUN apt-get update && apt-get install -y \
libopengl0 \
libegl1 \
libgles2 \
# Calibre dependencies
libglx0 \
libgl1 \
libglx-mesa0 \
libgl1-mesa-dri \
libgl1-mesa-glx \
# Font support
fonts-wqy-microhei \
ttf-wqy-zenhei \
Expand All @@ -41,30 +48,57 @@ RUN apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/*

# Install Node.js
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
RUN wget -qO- https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm@latest

# Install Calibre
RUN curl -sSL https://download.calibre-ebook.com/linux-installer.sh | sh /dev/stdin
# Install Calibre (dynamic version retrieval)
RUN CALIBRE_VERSION=$(curl -sX GET "https://api.github.com/repos/kovidgoyal/calibre/releases/latest" | grep -Po '"tag_name": "\K[^"]*') \
&& CALIBRE_VERSION_NUM=$(echo ${CALIBRE_VERSION} | cut -c2-) \
&& CALIBRE_URL="https://download.calibre-ebook.com/${CALIBRE_VERSION_NUM}/calibre-${CALIBRE_VERSION_NUM}-x86_64.txz" \
&& wget -O /tmp/calibre-tarball.txz "$CALIBRE_URL" \
&& mkdir -p /opt/calibre \
&& tar -xvf /tmp/calibre-tarball.txz -C /opt/calibre \
&& /opt/calibre/calibre_postinstall \
&& rm /tmp/calibre-tarball.txz \
&& dbus-uuidgen > /etc/machine-id


RUN apt-get update \
&& apt-get install -y wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

# ENV PUPPETEER_SKIP_DOWNLOAD true

# Install Puppeteer
RUN npm install -g puppeteer
RUN npx puppeteer browsers install chrome --install-deps

# Create necessary directories and set permissions
RUN mkdir -p /usr/src/app \
&& mkdir -p /usr/src/app/.cache/puppeteer \
&& mkdir -p /usr/src/app/.npm \
&& chown -R nobody:nogroup /usr/src/app
# Verify installations
RUN ebook-convert --version
RUN node -v && npm -v

WORKDIR /usr/src/app
# WORKDIR /app

# Switch to non-root user
USER nobody
# RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
# && mkdir -p /home/pptruser/Downloads \
# && chown -R pptruser:pptruser /home/pptruser \
# && chown -R pptruser:pptruser /app

# Verify installations
RUN ebook-convert --version \
&& node -e "const browser = require('puppeteer').launch(); console.log('Puppeteer works')"
# Run everything after as non-privileged user.
# USER pptruser

# COPY package.json package.json
# COPY index.js index.js
# RUN npm i
# RUN npm start
# RUN rm -rf ./*

# Usage instructions in label
LABEL maintainer="[email protected]" \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The Dockerfile includes a step to verify the installations of Calibre and Puppet

## Maintainer

This image is maintained by [Atharva Kusumbia](mailto:[email protected]).
This image is maintained by [athrv.k](mailto:[email protected]).

## License

Expand Down
Loading

0 comments on commit 3ba9a90

Please sign in to comment.