Improve Docker image and clean TODOs

This commit is contained in:
ngosang 2021-10-18 00:23:28 +02:00
parent cfd158462f
commit 77a87c79fd
5 changed files with 13 additions and 13 deletions

View File

@ -11,6 +11,7 @@ Check closed issues as well, because your issue may have already been fixed.
* **Last working FlareSolverr version**: * **Last working FlareSolverr version**:
* **Operating system**: * **Operating system**:
* **Are you using Docker**: [yes/no] * **Are you using Docker**: [yes/no]
* **FlareSolverr User-Agent (see log traces or / endpoint)**:
* **Are you using a proxy or VPN?** [yes/no] * **Are you using a proxy or VPN?** [yes/no]
* **Are you using Captcha Solver:** [yes/no] * **Are you using Captcha Solver:** [yes/no]
* **If using captcha solver, which one:** * **If using captcha solver, which one:**

View File

@ -1,13 +1,14 @@
FROM --platform=${TARGETPLATFORM:-linux/amd64} node:14-alpine3.14 FROM --platform=${TARGETPLATFORM:-linux/amd64} node:16-alpine3.14
# Print build information # Print build information
ARG TARGETPLATFORM ARG TARGETPLATFORM
ARG BUILDPLATFORM ARG BUILDPLATFORM
RUN printf "I am running on ${BUILDPLATFORM:-linux/amd64}, building for ${TARGETPLATFORM:-linux/amd64}\n$(uname -a)\n" RUN printf "I am running on ${BUILDPLATFORM:-linux/amd64}, building for ${TARGETPLATFORM:-linux/amd64}\n$(uname -a)\n"
# Install the web browser # Install the web browser (package firefox-esr is available too)
RUN apk update && \ RUN apk update && \
apk add --no-cache firefox-esr dumb-init apk add --no-cache firefox dumb-init && \
rm -Rf /var/cache
# Copy FlareSolverr code # Copy FlareSolverr code
USER node USER node
@ -28,3 +29,6 @@ RUN npm install && \
EXPOSE 8191 EXPOSE 8191
ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["npm", "start"] CMD ["npm", "start"]
# docker build -t flaresolverr:custom .
# docker run -p 8191:8191 -e LOG_LEVEL=debug flaresolverr:custom

View File

@ -26,7 +26,7 @@ const version = 'v' + require('./package.json').version;
fsZipName: 'windows-x64', fsZipName: 'windows-x64',
fsLicenseName: 'LICENSE.txt' fsLicenseName: 'LICENSE.txt'
} }
// TODO: this is working but changes are required in sessions.ts to find chrome path // todo: this is working but changes are required in sessions.ts to find chrome path
// { // {
// platform: 'mac', // platform: 'mac',
// version: 756035, // version: 756035,

View File

@ -102,7 +102,7 @@ export default async function resolveChallenge(url: string, page: Page, response
// const captchaSolver = getCaptchaSolver() // const captchaSolver = getCaptchaSolver()
// if (captchaSolver) { // if (captchaSolver) {
// // todo: get the params // // to-do: get the params
// log.info('Waiting to receive captcha token to bypass challenge...') // log.info('Waiting to receive captcha token to bypass challenge...')
// const token = await captchaSolver({ // const token = await captchaSolver({
// url, // url,
@ -110,7 +110,7 @@ export default async function resolveChallenge(url: string, page: Page, response
// type: captchaType // type: captchaType
// }) // })
// log.debug(`Token received: ${token}`); // log.debug(`Token received: ${token}`);
// // todo: send the token // // to-do: send the token
// } // }
// } else { // } else {
// throw new Error('Captcha detected but no automatic solver is configured.'); // throw new Error('Captcha detected but no automatic solver is configured.');

View File

@ -24,7 +24,7 @@ export interface SessionCreateOptions {
oneTimeSession: boolean oneTimeSession: boolean
cookies?: SetCookie[], cookies?: SetCookie[],
maxTimeout?: number maxTimeout?: number
proxy?: any// TODO: use interface not any proxy?: Proxy
} }
const sessionCache: SessionsCache = {} const sessionCache: SessionsCache = {}
@ -120,12 +120,9 @@ export async function create(session: string, options: SessionCreateOptions): Pr
log.debug('Launching web browser...') log.debug('Launching web browser...')
// TODO: maybe access env variable? // todo: the retries are required?
// TODO: sometimes browser instances are created and not connected to correctly.
// how do we handle/quit those instances inside Docker?
let launchTries = 3 let launchTries = 3
let browser: Browser; let browser: Browser;
while (0 <= launchTries--) { while (0 <= launchTries--) {
try { try {
browser = await puppeteer.launch(puppeteerOptions) browser = await puppeteer.launch(puppeteerOptions)
@ -154,8 +151,6 @@ export function list(): string[] {
return Object.keys(sessionCache) return Object.keys(sessionCache)
} }
// todo: create a sessions.close that doesn't rm the userDataDir
export async function destroy(id: string): Promise<boolean>{ export async function destroy(id: string): Promise<boolean>{
if (id && sessionCache.hasOwnProperty(id)) { if (id && sessionCache.hasOwnProperty(id)) {
const { browser, userDataDir } = sessionCache[id] const { browser, userDataDir } = sessionCache[id]