update docker

This commit is contained in:
Kai Ton 2024-02-27 02:50:39 +00:00
parent 2a313b18d9
commit 7f933297bc
4 changed files with 35 additions and 14 deletions

View File

@ -1,13 +1,18 @@
FROM alpine:3.18
FROM linuxserver/rdesktop:alpine-icewm
# FROM linuxserver/rdesktop:alpine-openbox
# FROM alpine:3.18
RUN apk update --no-cache
RUN apk add --no-cache npm chromium
RUN mkdir /app
WORKDIR /app
RUN mkdir /puppeteer
WORKDIR /puppeteer
COPY ./puppeteer.js /app/puppeteer.js
COPY ./server.js /app/server.js
COPY ./package.json /app/package.json
COPY ./puppeteer.js /puppeteer/puppeteer.js
COPY ./server.js /puppeteer/server.js
CMD sh -c 'npm i && node server.js'
USER root
COPY ./puppeteer.sh /puppeteer.sh
RUN chmod +x /puppeteer.sh
CMD [ "sh", "/puppeteer.sh" ]

View File

@ -1,5 +0,0 @@
{
"dependencies": {
"puppeteer": "^0.11.0"
}
}

View File

@ -1,6 +1,6 @@
const puppeteer = require('puppeteer');
module.exports = async (
const launch = async (
config = { url: '', screenshotPath: '', executablePath: '', timeout: 1000 }
) => {
@ -11,9 +11,25 @@ module.exports = async (
timeout: 1000,
}, config)
const profile = {
data: [
// 'wormlazy199210',
'wormlazy199211',
'wormlazy199212',
],
select: function() {
return this.data[Math.floor(Math.random() * this.data.length)]
}
}
const browser = await puppeteer.launch({
executablePath: config.executablePath,
args: ['--no-sandbox', '--headless', '--disable-gpu']
args: [
'--no-sandbox',
'--headless',
'--disable-gpu',
`--user-data-dir=/puppeteer/chrome-profiles/${profile.select()}`
]
});
const page = await browser.newPage();
@ -37,3 +53,4 @@ module.exports = async (
await browser.close();
}
};
module.exports = launch

View File

@ -0,0 +1,4 @@
#!/bin/sh
sudo chown abc:abc -R /puppeteer/chrome-profiles
npm i puppeteer
node server.js