open-wa / wa-automate-docker

💬 🤖 The easiest way to turn your WhatsApp into an API. Be sure to 🌟 this repository for updates!
110 stars 31 forks source link

Spawn Google Chrome ENOENT->docker #3

Closed ranggaaprilio closed 3 years ago

ranggaaprilio commented 4 years ago

Describe the bug i got this error when i run in docker. i want to see the QR code in my browser so i set the popup configObject if I running In windows this script is working perfectly,but if i deploy using docker i got this ERROR image

Thanks for a help

create() code This is the code Iuse to create the client. e.g


create({
    sessionId: 'customer-support',
    executablePath: '/usr/bin/chromium-browser',
    useChrome: true,
    restartOnCrash: start,
    headless: true,
    throwErrorOnTosBlock: true,
    qrTimeout: 0,   //set to 0 to wait forever for a qr scan
    authTimeout: 0, //set to 0 to wait forever for connection to phone
    killProcessOnBrowserClose: true,
    autoRefresh: true, //default to true
    safeMode: true,
    disableSpins: true,
    hostNotificationLang: NotificationLanguage.PTBR,
    viewport: {
        // width: 1920,
        height: 1200
    },
    popup: 3000,
    defaultViewport: null,
    // cacheEnabled:false,
    // devtools:true,
    //OR
    // devtools:{
    //   user:'admin',
    //   pass:'root'
    // },
    //example chrome args. THIS MAY BREAK YOUR APP !!!ONLY FOR TESTING FOR NOW!!!.
    // chromiumArgs:[
    //   '--aggressive-cache-discard',
    //   '--disable-cache',
    //   '--disable-application-cache',
    //   '--disable-offline-load-stale-cache',
    //   '--disk-cache-size=0'
    // ]
})
    .then(async client => await start(client))
    .catch(e => {
        console.log('Error', e.message);
        // process.exit();
    });```

**this Is my DockerFile**
FROM node:current-alpine

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

# Uncomment the next line to use this Dockerfile on your own app
#run npm install
RUN npm install --only=dev --ignore-scripts
RUN apk --no-cache add g++ gcc libgcc libstdc++ linux-headers make python
RUN \
    echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
    && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \
    && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
    && apk --no-cache  update \
    && apk --no-cache  upgrade \
    && apk add --no-cache --virtual .build-deps \
    gifsicle pngquant optipng libjpeg-turbo-utils \
    udev ttf-opensans chromium \
    && rm -rf /var/cache/apk/* /tmp/*

ENV CHROME_BIN /usr/bin/chromium-browser
ENV LIGHTHOUSE_CHROMIUM_PATH /usr/bin/chromium-browser
RUN npm install --quiet node-gyp -g
RUN npm rebuild --verbose sharp

# Copy the session data over to the container
# Bundle app source
COPY . .

EXPOSE 8080

CMD ["npm", "run", "start"]

**Screenshots**
If applicable, add screenshots to help explain your problem. Use ```headless: false``` to get screenshots

**Host (please complete the following information):**
 - OS: Windows & Ubuntu

** this Is my Docker-compose.yml**

version: "3.8"
services:

  browser:
    image: browserless/chrome:1.22-chrome-stable
    hostname: browser
    ports:
      - "3000:3000"
    deploy:
      replicas: 1
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: on-failure
    environment:
      CONNECTION_TIMEOUT: -1
      KEEP_ALIVE: 'true'
      WORKSPACE_EXPIRE_DAYS: 1
      ENABLE_CORS: 'true'
      CHROME_REFRESH_TIME: 86400000
      DEFAULT_BLOCK_ADS: 'true'
      FUNCTION_ENABLE_INCOGNITO_MODE: 'true'
      ENABLE_XVBF: 'true'
      CHROME_PATH: '/usr/bin/google-chrome'
      USE_CHROME_STABLE: 'true'
      NODE_ENV: 'production'

  app:
    build: .
    restart: on-failure
    container_name: open_WA1
    depends_on:
      - browser
    ports:
      - "8080:8080"
    environment:
      WA_BROWSER_WS_ENDPOINT: 'http://browser:3000'
      WA_DISABLE_SPINS: 'true'

      # Uncomment next line and add the session data base64 string to authenticate the session without the need to scan it again
      # WA_SESSION_DATA: ''
smashah commented 4 years ago

Why isn't this issue in https://github.com/open-wa/wa-automate-docker ???

Set this to true

https://open-wa.github.io/wa-automate-nodejs/interfaces/configobject.html#indocker

smashah commented 3 years ago

This should be fixed by now, please use the new docker image, without docker-compose:

> docker run -e PORT=8080 -p 8080:8080 openwa/wa-automate:latest