update docker
This commit is contained in:
parent
2a313b18d9
commit
7f933297bc
|
|
@ -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 update --no-cache
|
||||||
RUN apk add --no-cache npm chromium
|
RUN apk add --no-cache npm chromium
|
||||||
|
|
||||||
RUN mkdir /app
|
RUN mkdir /puppeteer
|
||||||
WORKDIR /app
|
WORKDIR /puppeteer
|
||||||
|
|
||||||
COPY ./puppeteer.js /app/puppeteer.js
|
COPY ./puppeteer.js /puppeteer/puppeteer.js
|
||||||
COPY ./server.js /app/server.js
|
COPY ./server.js /puppeteer/server.js
|
||||||
COPY ./package.json /app/package.json
|
|
||||||
|
|
||||||
CMD sh -c 'npm i && node server.js'
|
USER root
|
||||||
|
COPY ./puppeteer.sh /puppeteer.sh
|
||||||
|
RUN chmod +x /puppeteer.sh
|
||||||
|
|
||||||
|
CMD [ "sh", "/puppeteer.sh" ]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"dependencies": {
|
|
||||||
"puppeteer": "^0.11.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const puppeteer = require('puppeteer');
|
const puppeteer = require('puppeteer');
|
||||||
|
|
||||||
module.exports = async (
|
const launch = async (
|
||||||
config = { url: '', screenshotPath: '', executablePath: '', timeout: 1000 }
|
config = { url: '', screenshotPath: '', executablePath: '', timeout: 1000 }
|
||||||
) => {
|
) => {
|
||||||
|
|
||||||
|
|
@ -11,9 +11,25 @@ module.exports = async (
|
||||||
timeout: 1000,
|
timeout: 1000,
|
||||||
}, config)
|
}, config)
|
||||||
|
|
||||||
|
const profile = {
|
||||||
|
data: [
|
||||||
|
// 'wormlazy199210',
|
||||||
|
'wormlazy199211',
|
||||||
|
'wormlazy199212',
|
||||||
|
],
|
||||||
|
select: function() {
|
||||||
|
return this.data[Math.floor(Math.random() * this.data.length)]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const browser = await puppeteer.launch({
|
const browser = await puppeteer.launch({
|
||||||
executablePath: config.executablePath,
|
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();
|
const page = await browser.newPage();
|
||||||
|
|
||||||
|
|
@ -37,3 +53,4 @@ module.exports = async (
|
||||||
await browser.close();
|
await browser.close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
module.exports = launch
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/sh
|
||||||
|
sudo chown abc:abc -R /puppeteer/chrome-profiles
|
||||||
|
npm i puppeteer
|
||||||
|
node server.js
|
||||||
Loading…
Reference in New Issue