Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a docker-compose configuration #22

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

ylambda
Copy link

@ylambda ylambda commented Jun 14, 2024

This is functional, but still a work in progress.

Features:

  • REON web (php-fpm)
  • Node.js Mailer
  • NGINX proxy to REON web
  • Persistent MySQL database with autoloaded tables.sql
  • REON web has sendmail (see email section)
  • Supports account creation without need for email
  • Documentation in README
  • Crystal Trade Corner supported
  • Pokemon Battle supported
  • Pokemon Exchange supported
  • Logging ?

Email

The REON web service is configured to use sendmail, and it will emit emails. However getting deliverable with SPF and DKIM can be quite complicated. Even more so if this is running on Home computer. For that reason a simple script is included to create an account without using the email flow.

Already using mysql2 in smtp.js and this supports newer auth
Without this, I was seeing an error:

(POP3) Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
@@ -264,6 +264,20 @@ public function verifySignupRequest($id, $key) {

public function completeSignupAction($id, $key, $reonEmail, $password, $passwordConfirm) {
$email = self::$instance->verifySignupRequest($id, $key);

$result = self::$instance->createUser($email, $reonEmail, $password, $passwodConfirm);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the parts specific to creating a user to a function called createUser so I can call from a script

@@ -273,14 +287,10 @@ public function completeSignupAction($id, $key, $reonEmail, $password, $password
$dion_ppp_id = self::$instance->generatePPPId();
$log_in_password = self::$instance->generateLogInPassword();
$db = DBUtil::getInstance()->getDB();
$stmt = $db->prepare("insert into sys_users (email, password, dion_ppp_id, dion_email_local, log_in_password) values (?)");
$stmt = $db->prepare("insert into sys_users (email, password, dion_ppp_id, dion_email_local, log_in_password, money_spent) values (?, ?, ?, ?, ?, 0)");
Copy link
Author

@ylambda ylambda Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bug I ran into, the params were missing in the values(). Also the money column does not have a default so it's now specified here.

@@ -1,5 +1,5 @@
const net = require("net");
const mysql = require("mysql");
const mysql = require("mysql2");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran into some errors about unsupported authentication when using mysql. I dropped in mysql2 which was already used in smtp.js and it worked great.

Comment on lines +46 to +49
- MYSQL_ROOT_PASSWORD=password
- MYSQL_USER=reon
- MYSQL_PASSWORD=password
- MYSQL_DATABASE=db
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on something to move these out. Most docker setups use a .env file, I'd like to look into using that and possibly creating a config.json from the values in .env or removing config.json. Ideally there's just one configuration file.

@kabili207
Copy link
Contributor

kabili207 commented Jul 25, 2024

I refactored my docker branch on top of yours, and ended up making a few changes

  • Switch to Alpine based images
    • They're usually smaller and rarely any harder to work with
  • Split dependency fetching and building to separate images
    • While probably not very important for REON, it can help reduce the number of layers and result in smaller images
    • Also has the benefit of allowing more things to be parallelized if using docker buildx
  • Allow specifying location of config.json in node programs via a new -c argument
  • Partial support for setting config options via environment variables
    • Only works with the mail and mysql containers right now, but it's a start
    • An example.env was added with the mysql options
    • See mail/entrypoint.sh for a full set of options
  • Adds image to handle processing of cron jobs

https://github.com/kabili207/reon/commits/docker

@kabili207
Copy link
Contributor

Oh, you'll probably notice that the Crystal Trade Corner application is not included in the cron jobs. I'm not sure why it's still in the repo, but it was replaced by the Pokemon Exchange quite a while ago, so you can remove it from your list.

@ylambda
Copy link
Author

ylambda commented Jul 25, 2024

Awesome! Commenting to show I have seen this and briefly looked it over. I should have some time later today, or possibly tomorrow to play around with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants