chore: disable puppeteer
This commit is contained in:
+11
-11
@@ -14,19 +14,19 @@ WORKDIR /app
|
||||
#
|
||||
# This is a little brittle, since the puppeteer chrome could in theory diverge
|
||||
# from the official apt chrome's shared lib deps. But it works..
|
||||
RUN apt-get update \
|
||||
&& apt-get install curl gnupg -y \
|
||||
&& curl --location --silent 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 google-chrome-stable -y --no-install-recommends \
|
||||
&& apt-get remove google-chrome-stable -y \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
# RUN apt-get update \
|
||||
# && apt-get install curl gnupg -y \
|
||||
# && curl --location --silent 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 google-chrome-stable -y --no-install-recommends \
|
||||
# && apt-get remove google-chrome-stable -y \
|
||||
# && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Add emoji fonts.
|
||||
# Source: https://gist.github.com/win0err/9d8c7f0feabdfe8a4c9787b02c79ac51
|
||||
RUN mkdir ~/.fonts/ && \
|
||||
wget https://github.com/samuelngs/apple-emoji-linux/releases/download/ios-15.4/AppleColorEmoji.ttf -O ~/.fonts/AppleColorEmoji.ttf
|
||||
# RUN mkdir ~/.fonts/ && \
|
||||
# wget https://github.com/samuelngs/apple-emoji-linux/releases/download/ios-15.4/AppleColorEmoji.ttf -O ~/.fonts/AppleColorEmoji.ttf
|
||||
|
||||
COPY package.json /app/
|
||||
RUN npm install --frozen-lockfile
|
||||
@@ -34,4 +34,4 @@ COPY ./ /app/
|
||||
|
||||
ENV PORT 3002
|
||||
EXPOSE 3002
|
||||
CMD ["node", "server.js"]
|
||||
CMD ["npm", "start"]
|
||||
Generated
-1184
File diff suppressed because it is too large
Load Diff
@@ -36,7 +36,6 @@
|
||||
"multer": "^1.4.3",
|
||||
"nodemailer": "^6.9.5",
|
||||
"nodemon": "^3.0.1",
|
||||
"puppeteer": "^20.9.0",
|
||||
"zeptomail": "^6.0.0",
|
||||
"zod": "^3.21.4"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// const { getPdfBuffer } = require('./puppeteer');
|
||||
const { marked } = require('marked');
|
||||
const puppeteer = require('puppeteer');
|
||||
// const puppeteer = require('puppeteer');
|
||||
|
||||
function getHtmlTemplate(body) {
|
||||
return `
|
||||
@@ -155,57 +155,58 @@ function getCourseBody({ courseTitle, orgName, orgTheme, lessons }) {
|
||||
}
|
||||
|
||||
async function generateSinglePdfFromHtml(htmlContent, courseTitle, orgTheme) {
|
||||
const args = [
|
||||
'--disable-web-security',
|
||||
'--no-sandbox',
|
||||
'--disable-setuid-sandbox',
|
||||
];
|
||||
const browser = await puppeteer.launch({
|
||||
headless: 'new',
|
||||
args,
|
||||
});
|
||||
const page = await browser.newPage();
|
||||
throw 'Download disabled';
|
||||
// const args = [
|
||||
// '--disable-web-security',
|
||||
// '--no-sandbox',
|
||||
// '--disable-setuid-sandbox',
|
||||
// ];
|
||||
// const browser = await puppeteer.launch({
|
||||
// headless: 'new',
|
||||
// args,
|
||||
// });
|
||||
// const page = await browser.newPage();
|
||||
|
||||
await page.setContent(htmlContent);
|
||||
// await page.setContent(htmlContent);
|
||||
|
||||
const pdfOptions = {
|
||||
format: 'A4',
|
||||
printBackground: true,
|
||||
displayHeaderFooter: true,
|
||||
headerTemplate:
|
||||
"<div><div class='pageNumber'></div> <div>/</div><div class='totalPages'></div></div>",
|
||||
footerTemplate: `
|
||||
<div class="footer" style="position: relative; display: flex; text-align: right; margin-right: 5%; font-size: 8px; width: 297mm; padding-top: 30px;">
|
||||
<div style="position: absolute; right: 50%; bottom: 3%;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>
|
||||
<div style="position: absolute; right: 0; bottom: 3%;">${courseTitle} | Powered by <a href="https://app.classroomio.com" style="text-decoration: underline;">ClassroomIO</a></div>
|
||||
</div>
|
||||
`,
|
||||
margin: {
|
||||
top: '0.3cm',
|
||||
bottom: '0.5cm',
|
||||
},
|
||||
};
|
||||
// const pdfOptions = {
|
||||
// format: 'A4',
|
||||
// printBackground: true,
|
||||
// displayHeaderFooter: true,
|
||||
// headerTemplate:
|
||||
// "<div><div class='pageNumber'></div> <div>/</div><div class='totalPages'></div></div>",
|
||||
// footerTemplate: `
|
||||
// <div class="footer" style="position: relative; display: flex; text-align: right; margin-right: 5%; font-size: 8px; width: 297mm; padding-top: 30px;">
|
||||
// <div style="position: absolute; right: 50%; bottom: 3%;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>
|
||||
// <div style="position: absolute; right: 0; bottom: 3%;">${courseTitle} | Powered by <a href="https://app.classroomio.com" style="text-decoration: underline;">ClassroomIO</a></div>
|
||||
// </div>
|
||||
// `,
|
||||
// margin: {
|
||||
// top: '0.3cm',
|
||||
// bottom: '0.5cm',
|
||||
// },
|
||||
// };
|
||||
|
||||
const numPages = await page.evaluate(() => {
|
||||
const content = document.body; // Change this to the specific element containing content
|
||||
const style = window.getComputedStyle(content);
|
||||
const contentHeight = parseInt(style.height, 10);
|
||||
const pageHeight = 900; // Set this to an appropriate value based on your PDF format
|
||||
// const numPages = await page.evaluate(() => {
|
||||
// const content = document.body; // Change this to the specific element containing content
|
||||
// const style = window.getComputedStyle(content);
|
||||
// const contentHeight = parseInt(style.height, 10);
|
||||
// const pageHeight = 900; // Set this to an appropriate value based on your PDF format
|
||||
|
||||
return Math.ceil(contentHeight / pageHeight);
|
||||
});
|
||||
// return Math.ceil(contentHeight / pageHeight);
|
||||
// });
|
||||
|
||||
const pagesPdfBuffer = [];
|
||||
// const pagesPdfBuffer = [];
|
||||
|
||||
for (let currentPage = 1; currentPage <= numPages; currentPage++) {
|
||||
await page.evaluate(() => {});
|
||||
// for (let currentPage = 1; currentPage <= numPages; currentPage++) {
|
||||
// await page.evaluate(() => {});
|
||||
|
||||
const pdfBuffer = await page.pdf(pdfOptions);
|
||||
pagesPdfBuffer.push(pdfBuffer);
|
||||
}
|
||||
// const pdfBuffer = await page.pdf(pdfOptions);
|
||||
// pagesPdfBuffer.push(pdfBuffer);
|
||||
// }
|
||||
|
||||
await browser.close();
|
||||
return Buffer.concat(pagesPdfBuffer);
|
||||
// await browser.close();
|
||||
// return Buffer.concat(pagesPdfBuffer);
|
||||
}
|
||||
|
||||
async function generateCoursePdf(params) {
|
||||
@@ -217,5 +218,5 @@ async function generateCoursePdf(params) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
generateCoursePdf,
|
||||
generateCoursePdf
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// const { getPdfBuffer } = require('./puppeteer');
|
||||
const { marked } = require('marked');
|
||||
const puppeteer = require('puppeteer');
|
||||
// const puppeteer = require('puppeteer');
|
||||
|
||||
function getHtmlTemplate(body) {
|
||||
return `
|
||||
@@ -75,15 +75,7 @@ function getHtmlTemplate(body) {
|
||||
`;
|
||||
}
|
||||
|
||||
function getLessonBody({
|
||||
title,
|
||||
number,
|
||||
orgName,
|
||||
note,
|
||||
slideUrl,
|
||||
video,
|
||||
courseTitle,
|
||||
}) {
|
||||
function getLessonBody({ title, number, orgName, note, slideUrl, video, courseTitle }) {
|
||||
const noteHtml = marked.parse(note);
|
||||
const showExtraResources = slideUrl || (video && video.length > 0);
|
||||
return `
|
||||
@@ -148,54 +140,56 @@ function getLessonBody({
|
||||
}
|
||||
|
||||
async function generateSinglePdfFromHtml(htmlContent, courseTitle) {
|
||||
const args = [
|
||||
'--disable-web-security',
|
||||
'--no-sandbox',
|
||||
'--disable-setuid-sandbox',
|
||||
];
|
||||
const browser = await puppeteer.launch({
|
||||
headless: 'new',
|
||||
args,
|
||||
});
|
||||
const page = await browser.newPage();
|
||||
// const args = [
|
||||
// '--disable-web-security',
|
||||
// '--no-sandbox',
|
||||
// '--disable-setuid-sandbox',
|
||||
// ];
|
||||
// const browser = await puppeteer.launch({
|
||||
// headless: 'new',
|
||||
// args,
|
||||
// });
|
||||
// const page = await browser.newPage();
|
||||
|
||||
await page.setContent(htmlContent);
|
||||
// await page.setContent(htmlContent);
|
||||
|
||||
const pdfOptions = {
|
||||
format: 'A4',
|
||||
printBackground: true,
|
||||
displayHeaderFooter: true,
|
||||
headerTemplate:
|
||||
"<div><div class='pageNumber'></div> <div>/</div><div class='totalPages'></div></div>",
|
||||
footerTemplate: `<div class="footer" style="text-align: right; margin-right: 5%; font-size: 8px; width: 297mm; padding-top: 30px;">
|
||||
${courseTitle} | Powered by <a href="https://app.classroomio.com" style="color: blue; text-decoration: underline;">ClassroomIO</a>
|
||||
</div>`,
|
||||
margin: {
|
||||
top: '0.4cm',
|
||||
bottom: '1cm',
|
||||
},
|
||||
};
|
||||
// const pdfOptions = {
|
||||
// format: 'A4',
|
||||
// printBackground: true,
|
||||
// displayHeaderFooter: true,
|
||||
// headerTemplate:
|
||||
// "<div><div class='pageNumber'></div> <div>/</div><div class='totalPages'></div></div>",
|
||||
// footerTemplate: `<div class="footer" style="text-align: right; margin-right: 5%; font-size: 8px; width: 297mm; padding-top: 30px;">
|
||||
// ${courseTitle} | Powered by <a href="https://app.classroomio.com" style="color: blue; text-decoration: underline;">ClassroomIO</a>
|
||||
// </div>`,
|
||||
// margin: {
|
||||
// top: '0.4cm',
|
||||
// bottom: '1cm',
|
||||
// },
|
||||
// };
|
||||
|
||||
const numPages = await page.evaluate(() => {
|
||||
const content = document.body; // Change this to the specific element containing content
|
||||
const style = window.getComputedStyle(content);
|
||||
const contentHeight = parseInt(style.height, 10);
|
||||
const pageHeight = 900; // Set this to an appropriate value based on your PDF format
|
||||
// const numPages = await page.evaluate(() => {
|
||||
// const content = document.body; // Change this to the specific element containing content
|
||||
// const style = window.getComputedStyle(content);
|
||||
// const contentHeight = parseInt(style.height, 10);
|
||||
// const pageHeight = 900; // Set this to an appropriate value based on your PDF format
|
||||
|
||||
return Math.ceil(contentHeight / pageHeight);
|
||||
});
|
||||
// return Math.ceil(contentHeight / pageHeight);
|
||||
// });
|
||||
|
||||
const pagesPdfBuffer = [];
|
||||
// const pagesPdfBuffer = [];
|
||||
|
||||
for (let currentPage = 1; currentPage <= numPages; currentPage++) {
|
||||
await page.evaluate(() => {});
|
||||
// for (let currentPage = 1; currentPage <= numPages; currentPage++) {
|
||||
// await page.evaluate(() => {});
|
||||
|
||||
const pdfBuffer = await page.pdf(pdfOptions);
|
||||
pagesPdfBuffer.push(pdfBuffer);
|
||||
}
|
||||
// const pdfBuffer = await page.pdf(pdfOptions);
|
||||
// pagesPdfBuffer.push(pdfBuffer);
|
||||
// }
|
||||
|
||||
await browser.close();
|
||||
return Buffer.concat(pagesPdfBuffer);
|
||||
// await browser.close();
|
||||
// return Buffer.concat(pagesPdfBuffer);
|
||||
|
||||
throw 'Download disabled';
|
||||
}
|
||||
|
||||
async function generateLessonPdf(params) {
|
||||
@@ -223,5 +217,5 @@ async function generateLessonPdf(params) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
generateLessonPdf,
|
||||
generateLessonPdf
|
||||
};
|
||||
|
||||
@@ -1,38 +1,39 @@
|
||||
const puppeteer = require('puppeteer');
|
||||
// const puppeteer = require('puppeteer');
|
||||
|
||||
const getPdfBuffer = async (html, pdfParams) => {
|
||||
const args = [
|
||||
'--disable-web-security',
|
||||
'--no-sandbox',
|
||||
'--disable-setuid-sandbox',
|
||||
];
|
||||
const defaultPdfParams = {
|
||||
width: '1123px',
|
||||
height: '794px',
|
||||
};
|
||||
throw 'Puppeteer disabled';
|
||||
// const args = [
|
||||
// '--disable-web-security',
|
||||
// '--no-sandbox',
|
||||
// '--disable-setuid-sandbox',
|
||||
// ];
|
||||
// const defaultPdfParams = {
|
||||
// width: '1123px',
|
||||
// height: '794px',
|
||||
// };
|
||||
|
||||
// launch a new chrome instance
|
||||
const browser = await puppeteer.launch({
|
||||
headless: 'new',
|
||||
args,
|
||||
});
|
||||
// // launch a new chrome instance
|
||||
// const browser = await puppeteer.launch({
|
||||
// headless: 'new',
|
||||
// args,
|
||||
// });
|
||||
|
||||
// create a new page
|
||||
const page = await browser.newPage();
|
||||
await page.setViewport({ width: 1123, height: 794 });
|
||||
await page.goto('data:text/html,' + html, { waitUntil: 'networkidle2' });
|
||||
await page.addStyleTag({ content: '@page { size: auto; }' });
|
||||
await page.emulateMediaType('screen');
|
||||
// // create a new page
|
||||
// const page = await browser.newPage();
|
||||
// await page.setViewport({ width: 1123, height: 794 });
|
||||
// await page.goto('data:text/html,' + html, { waitUntil: 'networkidle2' });
|
||||
// await page.addStyleTag({ content: '@page { size: auto; }' });
|
||||
// await page.emulateMediaType('screen');
|
||||
|
||||
// create a pdf buffer
|
||||
const pdfBuffer = await page.pdf(pdfParams || defaultPdfParams);
|
||||
// // create a pdf buffer
|
||||
// const pdfBuffer = await page.pdf(pdfParams || defaultPdfParams);
|
||||
|
||||
// close the browser
|
||||
await browser.close();
|
||||
// // close the browser
|
||||
// await browser.close();
|
||||
|
||||
return pdfBuffer;
|
||||
// return pdfBuffer;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getPdfBuffer,
|
||||
getPdfBuffer
|
||||
};
|
||||
|
||||
@@ -9,15 +9,16 @@ COPY ./pnpm-lock.yaml ./
|
||||
|
||||
# Set environment variables
|
||||
ENV IS_SELFHOSTED=true
|
||||
ENV PUBLIC_SUPABASE_URL=${PUBLIC_SUPABASE_URL}
|
||||
ENV PUBLIC_SUPABASE_ANON_KEY=${PUBLIC_SUPABASE_ANON_KEY}
|
||||
ENV PRIVATE_SUPABASE_SERVICE_ROLE=${PRIVATE_SUPABASE_SERVICE_ROLE}
|
||||
ENV PRIVATE_APP_HOST=${PRIVATE_APP_HOST}
|
||||
ENV PRIVATE_APP_SUBDOMAINS=${PRIVATE_APP_SUBDOMAINS}
|
||||
ENV UNSPLASH_API_KEY=${UNSPLASH_API_KEY}
|
||||
ENV OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||
ENV PUBLIC_SERVER_URL=${PUBLIC_SERVER_URL}
|
||||
ENV PUBLIC_IP_REGISTRY_KEY=${PUBLIC_IP_REGISTRY_KEY}
|
||||
ENV PUBLIC_SUPABASE_URL=$PUBLIC_SUPABASE_URL
|
||||
ENV PUBLIC_SUPABASE_ANON_KEY=$PUBLIC_SUPABASE_ANON_KEY
|
||||
ENV PRIVATE_SUPABASE_SERVICE_ROLE=$PRIVATE_SUPABASE_SERVICE_ROLE
|
||||
ENV PRIVATE_APP_HOST=$PRIVATE_APP_HOST
|
||||
ENV PRIVATE_APP_SUBDOMAINS=$PRIVATE_APP_SUBDOMAINS
|
||||
ENV UNSPLASH_API_KEY=$UNSPLASH_API_KEY
|
||||
ENV OPENAI_API_KEY=$OPENAI_API_KEY
|
||||
ENV PUBLIC_SERVER_URL=$PUBLIC_SERVER_URL
|
||||
ENV PUBLIC_IP_REGISTRY_KEY=$PUBLIC_IP_REGISTRY_KEY
|
||||
ENV NODE_OPTIONS="--max-old-space-size=2048"
|
||||
|
||||
RUN pnpm i --frozen-lockfile
|
||||
|
||||
|
||||
@@ -12,13 +12,17 @@ export let supabase: SupabaseClient;
|
||||
export const getServerSupabase = () => {
|
||||
if (supabase) return supabase;
|
||||
|
||||
supabase = createClient(config.supabaseConfig.url, env.PRIVATE_SUPABASE_SERVICE_ROLE || '', {
|
||||
supabase = createClient(
|
||||
config.supabaseConfig.url,
|
||||
env.PRIVATE_SUPABASE_SERVICE_ROLE || 'some-key-here',
|
||||
{
|
||||
auth: {
|
||||
persistSession: false,
|
||||
autoRefreshToken: false,
|
||||
detectSessionInUrl: false
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
return supabase;
|
||||
};
|
||||
|
||||
@@ -49,6 +49,7 @@ services:
|
||||
- .:/app
|
||||
- /app/node_modules
|
||||
- /app/apps/dashboard/node_modules
|
||||
- /app/apps/dashboard/build
|
||||
# command: sh -c "npm install -g pnpm && rm -rf node_modules && yes | pnpm install --frozen-lockfile && cd apps/dashboard && pnpm build && pnpm start"
|
||||
environment:
|
||||
- IS_SELFHOSTED=true
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"concurrently": "^8.2.2",
|
||||
"cypress": "^13.8.0",
|
||||
"eslint": "^8.54.0",
|
||||
"prettier": "^3.1.0",
|
||||
"prettier-plugin-svelte": "^3.1.2",
|
||||
|
||||
Generated
+42
-1006
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user