Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: mermaid compiler and puppeteer image #83

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ GPG_IMAGE_NAME := ${IMAGE_REPO}/gpg-vault
GPG_IMAGE_TAG := pk
RUNNER_IMAGE_NAME := ${IMAGE_REPO}/node
RUNNER_IMAGE_TAG := bookworm
PUPPETEER_IMAGE_NAME := ${IMAGE_REPO}/node-puppeteer
PUPPETEER_IMAGE_TAG := bookworm
MERMAID_IMAGE_NAME := ${IMAGE_REPO}/mermaid
MERMAID_IMAGE_TAG := bookworm
AUTH_PROXY_IMAGE_NAME := ${IMAGE_REPO}/auth-proxy
AUTH_PROXY_IMAGE_TAG := latest
CONTAINER_PROXY_IMAGE_NAME := ${IMAGE_REPO}/container-socket-proxy
Expand Down Expand Up @@ -228,6 +232,29 @@ image_runner_node_ios: submodules image_runner_node
-f './imags/cocoapods-runner/Containerfile' \
./imags/cocoapods-runner

# base for mermaid etc
image_runner_node_puppeteer: IMAGE_NAME = ${PUPPETEER_IMAGE_NAME}
image_runner_node_puppeteer: IMAGE_TAG = ${PUPPETEER_IMAGE_TAG}
image_runner_node_puppeteer: submodules # image_runner_node
${CMD} buildx build \
${BUILD_OPTIONS} \
--build-arg "SHELL=${USER_SHELL}" \
--build-arg "NODE_VERSION=20" \
-t "${IMAGE_NAME}:${IMAGE_TAG}" \
-f './imags/node-puppeteer/Containerfile' \
./imags/node-puppeteer

image_runner_mermaid: IMAGE_NAME = ${MERMAID_IMAGE_NAME}
image_runner_mermaid: IMAGE_TAG = ${MERMAID_IMAGE_TAG}
image_runner_mermaid: submodules # image_runner_node
${CMD} buildx build \
${BUILD_OPTIONS} \
--build-arg "SHELL=${USER_SHELL}" \
--build-arg "NODE_VERSION=20" \
-t "${IMAGE_NAME}:${IMAGE_TAG}" \
-f './imags/node-puppeteer/Containerfile.mermaid' \
./imags/node-puppeteer

image_runner_node_all: IMAGE_NAME = ${RUNNER_IMAGE_NAME}
image_runner_node_all: IMAGE_TAG = ${RUNNER_IMAGE_TAG}
image_runner_node_all: image_runner_node_20 image_runner_node_18 image_runner_node_22 # image_runner_node_ios
Expand Down Expand Up @@ -475,6 +502,9 @@ images: images_deps image_runner_node image_dnsmasq image_gpg_pk image_dev_shell

images_gui: images image_xterm image_firefox image_vnc

# these are optional and not enabled by default due to extra build time and disk usage
images_opt: images_runner_mermaid image_runner_node_all

images_test: images image_nvim_test

test: test_nvim test_runner_node test_gpg_pk
Expand Down
5 changes: 5 additions & 0 deletions contrib/bin/mmdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
export RUNNER_IMAGE=localhost/l7/mermaid:bookworm
RUNNER_OPTS="${RUNNER_OPTS} -i "
RUNNER_ENV="${RUNNER_ENV} PUPPETEER_CACHE_DIR=/opt/puppeteer"
l7-run-node mmdc ${@}
5 changes: 5 additions & 0 deletions contrib/bin/puppeteer
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
export RUNNER_IMAGE=localhost/l7/node:puppeteer-bookworm
RUNNER_OPTS="${RUNNER_OPTS} -i "
l7-run-node puppeteer ${@}

1 change: 1 addition & 0 deletions imags/node-puppeteer/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-scripts = true
62 changes: 62 additions & 0 deletions imags/node-puppeteer/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# syntax=docker/dockerfile:1.4-labs
ARG NODE_VERSION=20
FROM localhost/l7/node:${NODE_VERSION}-bookworm
USER root

# if done properly, make this multi-stage and/or add @lavamoat/allow-scripts
# https://github.com/puppeteer/puppeteer/blob/main/docker/Dockerfile

######
######
######
######
# Configure default locale (important for chrome-headless-shell).
ENV LANG en_US.UTF-8

# https://pptr.dev/troubleshooting/#chrome-doesnt-launch-on-linux
# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version of Chrome that Puppeteer
# installs, work.
# user/group mapping needs to be done in runtime too, if overriding user

ENV PUPPETEER_CACHE_DIR=/opt/puppeteer

RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-khmeros fonts-kacst fonts-freefont-ttf dbus dbus-x11 \
librsvg2-common \
fonts-ipafont-* fonts-kacst-one \
ca-certificates fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 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 lsb-release wget xdg-utils \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
&& usermod -a -G audio,video node \
&& mkdir -p ${PUPPETEER_CACHE_DIR}


WORKDIR /usr/local/lib

COPY .npmrc package.json package-lock.json .
# ENV DBUS_SESSION_BUS_ADDRESS autolaunch:

RUN npm i

WORKDIR ${PUPPETEER_CACHE_DIR}
USER root
RUN DEBUG='*' puppeteer browsers install chromium@latest \
&& DEBUG='*' puppeteer browsers install chrome-headless-shell@126.0.6478.126 \
&& DEBUG='*' puppeteer browsers install chrome-headless-shell@127.0.6533.88 \
&& DEBUG='*' puppeteer browsers install chrome-headless-shell@stable \
&& DEBUG='*' puppeteer browsers install firefox@stable \
&& DEBUG='*' puppeteer browsers install chrome@126.0.6478.126 \
&& DEBUG='*' puppeteer browsers install chrome@127.0.6533.88 \
&& DEBUG='*' puppeteer browsers install chrome@stable

RUN ln -sf /opt/puppeteer /home/node/.cache/puppeteer \
&& chown -R node /home/user /home/node

######
######
######
######

USER node
WORKDIR /
12 changes: 12 additions & 0 deletions imags/node-puppeteer/Containerfile.mermaid
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# syntax=docker/dockerfile:1.4-labs
ARG BASE_IMAGE=localhost/l7/node-puppeteer:bookworm
FROM ${BASE_IMAGE}
USER root

WORKDIR /usr/local/lib
RUN NPM_CONFIG_PREFIX='' npm add 'git+https://github.com/legobeat/mermaid-cli/#02153e234a876c95b44e1af84d02bca65681f6d1' \
&& chown -R node /home/user /home/node \
# allow user installing new engines but not modifying bundled ones \
&& chown node /opt/puppeteer/ /opt/puppeteer/*

USER node
Binary file not shown.
Loading
Loading