title: How to run a Puppeteer App/Script on a docker instance?
body: <p>My goal is to have a Puppeteer Application deployed onto opeNode cloud hosting platform. The puppeteer application is to run once a day, using a scheduling system which they seem to provide, my problem is that locally the puppeteer script works fine, running it in a local docker container also works fine, but once deployed to the docker container on the cloud it just hangs and then times out.</p>
  <p>I have reached out to support and they have said that I ned to listen on Port 80 otherwise I cannot make any HTTP requests.</p>
  <pre><code>const puppeteer = require(&quot;puppeteer&quot;);
  require(&quot;dotenv&quot;).config();
  const fetch = require(&quot;node-fetch&quot;);
  
  const username = process.env.LOGINUSERNAME;
  const password = process.env.PASSWORD;
  
  
  // Boot up this bad boi
  (async () =&gt; {
    // Fetch Quotes
    const res = await fetch(&quot;https://type.fit/api/quotes&quot;);
    let data2 = await res.json();
  
    // Data manipulation
    let randomNumber = Math.floor(Math.random() * data2.length) + 1;
    let textOfDay = data2[randomNumber].text;
    let authorOfDay = data2[randomNumber].author;
    let quoteOfDay = `&quot;${textOfDay}&quot; - ${authorOfDay}`;
  
    // Let the beast loose!
    const browser = await puppeteer.launch({
      args: [&quot;--no-sandbox&quot;, &quot;--disable-setuid-sandbox&quot;, &quot;--headless&quot;, &quot;--disable-dev-shm-usage&quot;],
      //headless: false,
      executablePath: process.env.CHROMIUM_PATH,
    });
    const page = await browser.newPage();
    await page.goto(&quot;https://twitter.com/login&quot;);
    console.log(&quot;Navigated to Twitter.com&quot;)
    await page.waitForSelector(&quot;input&quot;);
    // In puppeteer - querySelectorAll is $$
    const inputs = await page.$$(&quot;input&quot;);
    await inputs[5].type(username);
    await inputs[6].type(password);
    // What URL are we currently on?
    console.log(page.url());
  
    console.log(&quot;Finding login button&quot;);
    const loginButton = await page.$$('[role=&quot;button&quot;]');
  
    await Promise.all([loginButton[0].click(), page.waitForNavigation({ waitUntil: 'networkidle2' })])
    console.log(page.url());
    await page.waitForTimeout(4000).then(async () =&gt; {
      console.log(&quot;Waited 4 seconds!&quot;);
      // What URL are we currently on?
      console.log(page.url());
      await page.waitForSelector('[aria-label=&quot;Tweet text&quot;]');
      const tweetInputField = await page.$$('[aria-label=&quot;Tweet text&quot;]');
      //tweetInputField[0].click();
  
      await tweetInputField[0].type(quoteOfDay);
      //await tweetInputField[0].type(&quot;Hello World, Online&quot;);
  
      const tweetButton = await page.$$('[data-testid=&quot;tweetButtonInline&quot;]');
      tweetButton[0].click();
    }).catch((error) =&gt; {
      console.error(error);
    });;
    await page.waitForTimeout(4000);
    await browser.close();
  })();
  </code></pre>
  <p>And here is what is currently in my docker file:</p>
  <pre><code>FROM node:lts-alpine
  
  WORKDIR /opt/app
  
  ENV PORT=80
  ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
  
  //daemon for cron jobs
  RUN echo 'crond' &gt; /boot.sh
  
  //Chrome and Puppeteer
  ENV CHROME_BIN=&quot;/usr/bin/chromium-browser&quot; \
      PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=&quot;true&quot;
  
  ENV CHROMIUM_PATH=&quot;/usr/bin/chromium-browser&quot;
  
  RUN set -x \
      &amp;&amp; apk update \
      &amp;&amp; apk upgrade \
      &amp;&amp; apk add --no-cache \
      udev \
      ttf-freefont \
      chromium
  
  
  COPY package*.json ./
  
  RUN npm install --production
  
  # Bundle app source
  COPY . .
  
  CMD sh /boot.sh &amp;&amp; npm start
  </code></pre>
  <p>If there is any resources or extra information you could point me towards it would be much appreciated.
  I assume that once the application has done its job, we want the node service to terminate?
  This is my first time using Docker and Docker containers so extra information will be much appreciated.</p>