Puppeteer working?

This commit is contained in:
Jordan Roher 2023-12-14 14:27:46 -08:00
parent 01a7d8f94c
commit 42bd97b03e
3 changed files with 31 additions and 6 deletions

View File

@ -1,7 +1,7 @@
#!/bin/sh
# Escape slashes
LOGO=${LOGO//\//\\/}
LOGO=$(echo "${LOGO}" | sed 's/\//\\\//g')
# HTML replacement
sed -i -e 's/My Website/'"${TITLE}"'/g' /app/index.html

View File

@ -1,4 +1,23 @@
FROM node:18-alpine
# Build site using Node JS
FROM node:21-slim as builder
# 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 Chromium that Puppeteer
# installs, work.
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 chromium fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
ENV PUPPETEER_SKIP_DOWNLOAD true
# Install puppeteer so it's available in the container.
RUN npm init -y && \
npm i -g puppeteer
ARG BUILD_DATE
@ -30,9 +49,13 @@ ENV NEWWINDOW "true"
COPY version /
EXPOSE 4173
RUN chmod +x /app/docker-entrypoint.sh
ENTRYPOINT ["/app/docker-entrypoint.sh"]
RUN /app/docker-entrypoint.sh
RUN npm run start
CMD ["npm", "run", "start"]
# Serve site using nginx
FROM nginx
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80

View File

@ -19,6 +19,8 @@ function runNpmCommand(command) {
async function renderHomePage() {
const browser = await puppeteer.launch({
headless: true,
args: ["--no-sandbox", "--disable-setuid-sandbox"],
executablePath: "chromium",
});
const page = await browser.newPage();