Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
fix puppeteer
Browse files- Dockerfile +2 -4
- src/routes/api/models/[id]/+server.ts +40 -40
Dockerfile
CHANGED
@@ -11,11 +11,9 @@ COPY --chown=1000 package.json package-lock.json ./
|
|
11 |
|
12 |
# Install dependencies
|
13 |
RUN npm install
|
14 |
-
RUN apt-get update && apt-get install -y \
|
15 |
-
chromium \
|
16 |
|
17 |
-
|
18 |
-
|
19 |
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
|
20 |
ENV PUPPETEER_DOWNLOAD_PATH=/root/.cache/puppeteer
|
21 |
ENV PUPPETEER_CACHE_DIR=/root/.cache/puppeteer
|
|
|
11 |
|
12 |
# Install dependencies
|
13 |
RUN npm install
|
|
|
|
|
14 |
|
15 |
+
# Set the environment variable for Puppeteer's download path.
|
16 |
+
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
|
17 |
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
|
18 |
ENV PUPPETEER_DOWNLOAD_PATH=/root/.cache/puppeteer
|
19 |
ENV PUPPETEER_CACHE_DIR=/root/.cache/puppeteer
|
src/routes/api/models/[id]/+server.ts
CHANGED
@@ -89,46 +89,46 @@ export async function GET({ url, params } : RequestEvent) {
|
|
89 |
}
|
90 |
|
91 |
// get puppeteer screenshot
|
92 |
-
if (!model.metadata && metadata) {
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
}
|
132 |
|
133 |
return json({
|
134 |
model: {
|
|
|
89 |
}
|
90 |
|
91 |
// get puppeteer screenshot
|
92 |
+
// if (!model.metadata && metadata) {
|
93 |
+
// const browser = await puppeteer.launch({
|
94 |
+
// headless: true,
|
95 |
+
// defaultViewport: {
|
96 |
+
// width: 1920,
|
97 |
+
// height: 1080,
|
98 |
+
// },
|
99 |
+
// args: [
|
100 |
+
// '--no-sandbox',
|
101 |
+
// '--disable-setuid-sandbox',
|
102 |
+
// '--disable-dev-shm-usage',
|
103 |
+
// ],
|
104 |
+
// ignoreDefaultArgs: ['--disable-extensions']
|
105 |
+
// });
|
106 |
+
|
107 |
+
// const page = await browser.newPage();
|
108 |
+
// await page.goto(process.env.SPACE_HOST + '/metadata/models/' + model.id, {
|
109 |
+
// waitUntil: 'networkidle0',
|
110 |
+
// });
|
111 |
+
|
112 |
+
// const buffer = await page.screenshot({
|
113 |
+
// type: 'png',
|
114 |
+
// });
|
115 |
+
|
116 |
+
// const dir = await promises.opendir(process?.env?.PUBLIC_FILE_UPLOAD_DIR as string).catch(() => null)
|
117 |
+
// if (!dir) await promises.mkdir(process?.env?.PUBLIC_FILE_UPLOAD_DIR as string)
|
118 |
+
// const file_name_formatted = randomUUID() + "_" + "metadata" + model.id.replace("/", "-") + ".png"
|
119 |
+
// await promises.writeFile(`${process.env.PUBLIC_FILE_UPLOAD_DIR}/${file_name_formatted}`, buffer)
|
120 |
+
|
121 |
+
// await prisma.model.update({
|
122 |
+
// where: {
|
123 |
+
// id,
|
124 |
+
// },
|
125 |
+
// data: {
|
126 |
+
// metadata: file_name_formatted
|
127 |
+
// }
|
128 |
+
// })
|
129 |
+
|
130 |
+
// await browser.close();
|
131 |
+
// }
|
132 |
|
133 |
return json({
|
134 |
model: {
|