CI/CD: Permitindo que o docker instale o chromium em qualquer ambiente
Some checks failed
Deploy Dev / deploy (push) Has been cancelled
Some checks failed
Deploy Dev / deploy (push) Has been cancelled
This commit is contained in:
parent
590748c0d9
commit
779d64b2f0
@ -1,5 +1,7 @@
|
||||
FROM node:20-alpine
|
||||
WORKDIR /app
|
||||
RUN apk add --no-cache chromium nss freetype harfbuzz ca-certificates ttf-freefont
|
||||
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
|
||||
@ -7,6 +7,18 @@ import { WhatsappTemplateService } from './whatsapp-template.service';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
function getBrowserExecutablePath() {
|
||||
if (process.env.PUPPETEER_EXECUTABLE_PATH) {
|
||||
return process.env.PUPPETEER_EXECUTABLE_PATH;
|
||||
}
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
return 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe';
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class WhatsappService implements OnModuleInit {
|
||||
private client: Client;
|
||||
@ -31,7 +43,7 @@ export class WhatsappService implements OnModuleInit {
|
||||
authStrategy: new LocalAuth({ dataPath: './whatsapp-session' }),
|
||||
puppeteer: {
|
||||
headless: true,
|
||||
executablePath: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
|
||||
executablePath: getBrowserExecutablePath(),
|
||||
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage', '--disable-accelerated-2d-canvas', '--no-first-run', '--disable-gpu']
|
||||
},
|
||||
webVersionCache: {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user