Ki-er / Clarence-Bot

A multipurpose discord bot with admin, fun and information commands
MIT License
31 stars 16 forks source link

/r6stats - Doesnt work on deployed docker #5

Open Ki-er opened 2 years ago

Ki-er commented 2 years ago

Ref: https://github.com/hmes98318/r6s-stats-api/issues/1#issuecomment-1234520102

R6 stats api doesnt work within deployed docker

More research needs to be carried out for this

G0maa commented 2 years ago

It works for this input waifu_-. pc and null for type

G0maa commented 2 years ago

I think it's more like the user has to be registered here: https://r6.tracker.network/

Ki-er commented 2 years ago

Doing the inputs above I get image

It works in my local development of nodejs, it may work for yours due to the dev.docker but im not sure why it doesnt work for the deployed docker

G0maa commented 2 years ago

No worries, fix on the way 😬

Ki-er commented 2 years ago

Still getting undefined

G0maa commented 2 years ago

Huh... how did you test it? i.e. How did you start docker image?

G0maa commented 2 years ago

Here's what I tested: docker compose up This one worked normally.

2nd option: docker build . then:

docker run -d \
--name=clarence \
-p 6002:6002 \
-e DISCORD_TOKEN='INSERT DISCORD TOKEN' \
-e MONGOOSE='INSERT MONGODB URL' \
-e PREFIX='-' \
--restart unless-stopped \
8b020cbc738b (image id)

This also worked normally.

Have you tried rebuilding the image?

Ki-er commented 2 years ago

I ran the docker command seen in the README pulling the latest image. Ill try setting it up using the docker compose and giving it ago

G0maa commented 2 years ago

Weird... I just tried the one in README it still worked I guess we need some third person to verify.

Ki-er commented 2 years ago

@CrimsonTome, we request your assistance 😆

Ki-er commented 2 years ago

Weird... I just tried the one in README it still worked I guess we need some third person to verify.

What inputs did you try. ill try the same ones

G0maa commented 2 years ago

Similar to the one in the docs waifu_-., you can try the bot here: https://discord.gg/BfSVskDN

CrimsonTome commented 2 years ago

@CrimsonTome, we request your assistance 😆

If you don't mind waiting til this evening/tomorrow as I'm out most of today

CrimsonTome commented 2 years ago

It's looking like it doesn't want to work when being ran in Docker in a VM

CrimsonTome commented 2 years ago

correction: doesnt like being ran in a VM at all, node or docker os: Ubuntu 22.04 apologies I have no idea how this would be resolved

hmes98318 commented 2 years ago

try to install curl in the docker image may can get some help https://github.com/hmes98318/r6s-stats-api/issues/1#issuecomment-1280021572

G0maa commented 2 years ago

Mhm... this might be actually it, because curl doesn't exist on my WSL2 Ubuntu 20.04...

I can't remember if dockerfile can have 2 images i.e. two FROM, but the second option is to have a multi-stage dockerfile.

edit, forgot to link

Ki-er commented 2 years ago

https://www.howtogeek.com/devops/what-are-multi-stage-docker-builds/#:~:text=Multi-stage%20Docker%20builds%20let%20you%20write%20Dockerfiles%20with,that%20image%20by%20adding%20commands%20to%20your%20Dockerfile.

Apparently theres multistage

edit: You said that 😆

G0maa commented 2 years ago

gg, I'll try to do it soonish.

hmes98318 commented 2 years ago

Mhm... this might be actually it, because curl doesn't exist on my WSL2 Ubuntu 20.04...

I can't remember if dockerfile can have 2 images i.e. two FROM, but the second option is to have a multi-stage dockerfile.

edit, forgot to link

Add RUN apt-get update -y && apt-get install --no-install-recommends -y curl to your Dockerfile

Ki-er commented 2 years ago

Mhm... this might be actually it, because curl doesn't exist on my WSL2 Ubuntu 20.04... I can't remember if dockerfile can have 2 images i.e. two FROM, but the second option is to have a multi-stage dockerfile. edit, forgot to link

Add RUN apt-get update -y && apt-get install --no-install-recommends -y curl to your Dockerfile

This did not fix it

hmes98318 commented 2 years ago

This did not fix it

Where is not solved? I did not understand. 😕

Ki-er commented 2 years ago

Doing the inputs above I get image

It outputs the above and in console, nothing appears when doing console.log(profile)

hmes98318 commented 2 years ago

It outputs the above and in console, nothing appears when doing console.log(profile)

umm... Using same Dockerfile to build image is available.

FROM node:16.17.1

WORKDIR /usr/clarence/

COPY --chown=node:node . .

RUN npm --verbose install

RUN apt-get update -y && apt-get install --no-install-recommends -y curl

CMD ["node", "src/index.js"]

image

CrimsonTome commented 2 years ago

this is not a docker issue, this is most likely an issue with it being ran in a VM

G0maa commented 2 years ago

Hmm... 👀

Just use Axios instead of exec in r6stats... this solves basically everything 😬

If curl is actually the culprit causing this problem

G0maa commented 2 years ago

Could anyone try r6stats now after this.