mifi / instauto

Instagram bot / automation library written in Javascript for Node.js
797 stars 145 forks source link

Fix the Docker support #145

Open thegreenmilecornant opened 1 year ago

thegreenmilecornant commented 1 year ago

To Reproduce I have cloned the repository, changed the docker-compose.yaml with my username and password and run the command docker-compose --profile instauto up -d.

I then check the logs in Portainer and see this log;

No followed database found
No unfollowed database found
No likes database found
2023-05-03T07:36:25.749Z No cookies found
2023-05-03T07:36:25.749Z Setting language to English (en)
2023-05-03T07:36:25.750Z Waiting 1.29 sec
2023-05-03T07:36:57.244Z Failed to set language, trying fallback (cookie) TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded
    at /app/instauto/node_modules/puppeteer/lib/LifecycleWatcher.js:142:21
  -- ASYNC --
    at Frame.<anonymous> (/app/instauto/node_modules/puppeteer/lib/helper.js:111:15)
    at Page.goto (/app/instauto/node_modules/puppeteer/lib/Page.js:674:49)
    at Page.<anonymous> (/app/instauto/node_modules/puppeteer/lib/helper.js:112:23)
    at gotoUrl (/app/instauto/src/index.js:186:39)
    at goHome (/app/instauto/src/index.js:919:30)
    at setLang (/app/instauto/src/index.js:933:15)
    at async Instauto (/app/instauto/src/index.js:1009:3)
    at async /app/instauto/example.js:103:22
TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded
    at /app/instauto/node_modules/puppeteer/lib/LifecycleWatcher.js:142:21
  -- ASYNC --
    at Frame.<anonymous> (/app/instauto/node_modules/puppeteer/lib/helper.js:111:15)
    at Page.goto (/app/instauto/node_modules/puppeteer/lib/Page.js:674:49)
    at Page.<anonymous> (/app/instauto/node_modules/puppeteer/lib/helper.js:112:23)
    at gotoUrl (/app/instauto/src/index.js:186:39)
Closing browser
    at goHome (/app/instauto/src/index.js:919:30)
    at setLang (/app/instauto/src/index.js:967:13)
    at async Instauto (/app/instauto/src/index.js:1009:3)
    at async /app/instauto/example.js:103:22

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context This is related to the ground work made by @maxxxdj in PR #141 . Feels as if we're close to getting there and having a working image. Would you please look at this again @maxxxdj ?

Also, the timezone is off. Can we add that as an env variable?

Provide me with HTML

Did you receive an error while the bot is running?

To make it easier for me to understand why it's failing, please copy and share with me the HTML of the button (or even better the whole page) and share it, by following these instructions:

Use Option + + J (on macOS), or Shift + CTRL + J (on Windows/Linux) to open devtools.

Using the Web Inspector (F12), go to the Elements tab, right click on the tag in your code and select Copy->Copy outerHTML. Then paste that here

If you feel it's private information you can instead email to simpleinstabot@yankee.no

thefakewater commented 1 year ago

Sometimes this issue throw randomly on my container too when I start it . What I do is that I set my docker container restart policies to "on failure" and i set max-retry to 10 so that when it throws this error it immediately restarts and the error is gone and the bot doesn't fail after that.

thefakewater commented 1 year ago

To avoid this error I suggest that you create a docker volume and put the cookies.json,+ (all the data .json files) into a separate folder that you bind with that volume. The cookies.json validity last 1 year I think but it's better to login with cookies than username and password because it's faster.

thegreenmilecornant commented 1 year ago

Thanks. I tried the Restart Policy without luck.

I've created a volume now. To which path do I mount it? And how would I obtain the cookies.json and the rest of the .json files? I have never had a successful run in Docker.

Can I use the equivalent from SimpleInstaBot? Those files I can reach and have successful runs with.

thefakewater commented 1 year ago

I've created a volume now. To which path do I mount it?

I would recommend creating a managed volume because its easier. You could create a ./data folder at the root of your project. But you need to specify in your code to write the json files inside that folder.

Screenshot 2023-05-05 120416

Then with this data folder you can mount it like this in docker-compose.yml

version: '3'
services:
  myinstabot:
    volumes:
      - instabot:/app/data/
volumes:
  instabot: