PhlexPlexico / G5API

An express API for CS2 Servers using MatchZy and PugSharp to record and manage matches.
MIT License
98 stars 31 forks source link

Error execute with docker compose #232

Closed TOH2F closed 1 year ago

TOH2F commented 1 year ago

Hello !

I have download docker compile file here https://github.com/PhlexPlexico/G5API/blob/master/docker-compose.yml no modification

and lunch docker compose up for execution error show

G5API | $ MYSQL_FLAGS="-CONNECT_WITH_DB" db-migrate --env production --config config/production.json db:create get5 G5API | Ignoring invalid configuration option passed to Connection: driver. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection get5db | 2022-10-27 20:17:49 3 [Warning] Access denied for user 'get5'@'172.20.0.5' (using password: NO) G5API | [ERROR] AssertionError [ERR_ASSERTION]: ifError got unwanted exception: Access denied for user 'get5'@'172.20.0.5' (using password: NO) G5API | at /Get5API/node_modules/db-migrate/lib/commands/db.js:17:12 G5API | at /Get5API/node_modules/db-migrate/lib/driver/index.js:95:9 G5API | at /Get5API/node_modules/db-migrate-mysql/index.js:518:14 G5API | at Connection. (/Get5API/node_modules/mysql2/lib/connection.js:775:13) G5API | at Object.onceWrapper (node:events:628:26) G5API | at Connection.emit (node:events:513:28) G5API | at Connection._notifyError (/Get5API/node_modules/mysql2/lib/connection.js:236:12) G5API | at ClientHandshake. (/Get5API/node_modules/mysql2/lib/connection.js:125:14) G5API | at ClientHandshake.emit (node:events:525:35) G5API | at ClientHandshake.execute (/Get5API/node_modules/mysql2/lib/commands/command.js:39:14) G5API | at Packet.asError (/Get5API/node_modules/mysql2/lib/packets/packet.js:728:17) G5API | at ClientHandshake.execute (/Get5API/node_modules/mysql2/lib/commands/command.js:29:26) G5API | at Connection.handlePacket (/Get5API/node_modules/mysql2/lib/connection.js:456:32) G5API | at PacketParser.onPacket (/Get5API/node_modules/mysql2/lib/connection.js:85:12) G5API | at PacketParser.executeStart (/Get5API/node_modules/mysql2/lib/packet_parser.js:75:16) G5API | at Socket. (/Get5API/node_modules/mysql2/lib/connection.js:92:25) G5API | at Socket.emit (node:events:513:28) G5API | at addChunk (node:internal/streams/readable:315:12) G5API | at readableAddChunk (node:internal/streams/readable:289:9) G5API | at Socket.Readable.push (node:internal/streams/readable:228:10) G5API | at TCP.onStreamRead (node:internal/stream_base_commons:190:23) G5API | error Command failed with exit code 1. G5API | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Thank you :)

PhlexPlexico commented 1 year ago

The docker compose is a basic file to get you started. It will not work if you just copy it and run docker-compose up -d. Please follow the instructions on the README. You need to set your host, passwords, and any required information that is laid out there in order for it to run.

Thanks!

PhlexPlexico commented 1 year ago

Closing as I haven't heard back anything for about 4 days. If you need help, feel free to re-open this issue. Thanks!

tech62 commented 1 year ago

I've got this error too and was able to fix the problem partially:

It probably missing a step in the docker-compose.yml to grant access get5 user on the get5api database I'm not a docker expert, at this point, the containers are started but i've got an ssl error when going in https with my browser.

PhlexPlexico commented 1 year ago

I don't seem to ever have these issues with the docker containers, so I'm unsure as to why they are happening. There shouldn't be a need to grant privs to the database since it's get5_user or whatever you specify in the compose file to login with.

The SSL issues may be if you don't have a domain. If you wish to disable SSL, you can remove port 443 and ensure that all your addresses (even the ones without https:// just have http:// in them, and that should disable SSL if you're running into issues.

Thanks!

tech62 commented 1 year ago

I've remove the 443 port and https replaced by http in production.conf, Dockerfile, docker-compose and it seems ignored by Caddy:

caddy-reverse-proxy  | {"level":"info","ts":1667317586.2380884,"logger":"http","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"srv0","https_port":443}
caddy-reverse-proxy  | {"level":"info","ts":1667317586.2381601,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}

Error in cert generation ? caddy-reverse-proxy | {"level":"info","ts":1667317586.2894156,"msg":"Warning: \"certutil\" is not available, install \"certutil\" with \"apt install libnss3-tools\" or \"yum install nss-tools\" and try again"}

caddy-reverse-proxy  | {"level":"info","ts":1667317586.5178862,"logger":"admin","msg":"stopped previous server","address":"localhost:2019"}
PhlexPlexico commented 1 year ago

I believe this comment may be able to help you :)

tech62 commented 1 year ago

Already try... the containers are started but not reachable from outside of my VM

PhlexPlexico commented 1 year ago

Did you create the network?

docker network create -d bridge get5

tech62 commented 1 year ago

Yes, network is ok, i search how to disable https redirect throught the docker-compose file.

I've had caddy.reverse_proxy.transport: "http" caddy.reverse_proxy.transport.tls_insecure_skip_verify: in label section - no effect

I'm actually investigating https://caddyserver.com/docs/json/apps/http/servers/automatic_https/

And for hazardous reason, if i don't change the redis password in the docker-compose each time before starting a docker compose up, redis wasn't able to connect

tech62 commented 1 year ago

We really need an update of the install documentation or more details about using G5API/G5V with docker. I've spent a lot of time on this manner to install G5API for finally abandon and go back to manually install the packages :

After of all of that, everything works globally

PhlexPlexico commented 1 year ago

How exactly is it not working? Currently I'm using the docker images with caddy configuration (I also have a reverse proxy one level above, so it just sits on a different port) on my docker-compose file and it seems to be running just smoothly. It sounds like you may have some network configuration issues or you're not assigning IPs to the Docker images, which may get reset each time you create the containers. Here's mine, with information removed of course that seems to be working, as well as my reverse proxy for the API and front end.

Here is my docker compose

And here is my reverse proxy

The install instructions 99% of the time is fill in the values and you're good to go. It's all in the README. If you need some more info (albeit, a bit outdated I believe) of the config values, that can be found here.

It's totally up to you on how you wish to run the configuration. I have two systems running both (one done through cloning and following the guide, and one through docker-compose :) ), and I actually had more issues running the initial setup due to reverse proxy shenanigans with NGINX. That's why I've swapped the docker files to use caddy, it's way easier to setup and just works (for most use cases).

tech62 commented 1 year ago

Thanks for your reply.

At the first look, you've set a static IP on each container in your docker-compose that's not the case in the original template causing an issue i was facing.

Without static IP, the containers boot up fine but change their IP when restarting causing "redis connection failed" because the IP isn't the same from the previous start, i was thinking Docker useing internal hostname to resolve the IP to join.

The caddy's port is also different from the production.json template (80:80 and 443:443). Our reverse proxy configuration file have globally the same effect. We search the same behaviour whether it be Caddy or Nginx.

When i've a little moment, i will retry the docker installation method adapting your configuration to mine, i'm not using containers habitually, so complicated for me to install on the first time.