Puppeteer working?
This commit is contained in:
parent
01a7d8f94c
commit
42bd97b03e
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Escape slashes
|
# Escape slashes
|
||||||
LOGO=${LOGO//\//\\/}
|
LOGO=$(echo "${LOGO}" | sed 's/\//\\\//g')
|
||||||
|
|
||||||
# HTML replacement
|
# HTML replacement
|
||||||
sed -i -e 's/My Website/'"${TITLE}"'/g' /app/index.html
|
sed -i -e 's/My Website/'"${TITLE}"'/g' /app/index.html
|
||||||
|
33
dockerfile
33
dockerfile
@ -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
|
ARG BUILD_DATE
|
||||||
|
|
||||||
@ -30,9 +49,13 @@ ENV NEWWINDOW "true"
|
|||||||
|
|
||||||
COPY version /
|
COPY version /
|
||||||
|
|
||||||
EXPOSE 4173
|
|
||||||
|
|
||||||
RUN chmod +x /app/docker-entrypoint.sh
|
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
|
2
start.js
2
start.js
@ -19,6 +19,8 @@ function runNpmCommand(command) {
|
|||||||
async function renderHomePage() {
|
async function renderHomePage() {
|
||||||
const browser = await puppeteer.launch({
|
const browser = await puppeteer.launch({
|
||||||
headless: true,
|
headless: true,
|
||||||
|
args: ["--no-sandbox", "--disable-setuid-sandbox"],
|
||||||
|
executablePath: "chromium",
|
||||||
});
|
});
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user