topcoder-platform / forums

0 stars 0 forks source link

[$250] Deployment Docker #1

Closed rootelement closed 4 years ago

rootelement commented 4 years ago

Create a docker file to:

  1. Pull in the latest LTS minor revision of Vanilla Forums. The best example of format and process would possibly be https://github.com/topcoder-platform/av-scanner-service but don't be limited to this
  2. Set up a plugin structure for vanilla in this repo: https://github.com/topcoder-platform/forums-plugins This should be pulled in, installed and configured by docker (for now, cloning it into the plugins directory is fine)
jmgasper commented 4 years ago

Contest https://www.topcoder.com/challenges/30122181 has been created for this ticket.

This is an automated message for ghostar via Topcoder X

jmgasper commented 4 years ago

Contest https://www.topcoder.com/challenges/30122181 has been updated - it has been assigned to obog.

This is an automated message for ghostar via Topcoder X

atelomycterus commented 4 years ago

@jmgasper What default plugins should be enabled by default?

image

jmgasper commented 4 years ago
atelomycterus commented 4 years ago

@jmgasper Done. It's ready for your review. I think I should create a PR , not push it immediately. Sorry about that.

config-defaults.php.txt

atelomycterus commented 4 years ago
  • Topcoder plugin
  • Advanced Editor
  • Emoji Sets
  • OAuth2 SSO
  • Quotes
  • reCAPTCHA support
  • Rich editor
  • Syntax Prettifier

@jmgasper Oauth2 SSO don't have default settings. Enabling without settings doesn't make sense. image

atelomycterus commented 4 years ago

@jmgasper Implemented. Please apply PR (https://github.com/topcoder-platform/forums/pull/7). 1) All plugins except 'OAuth2 SSO' are enabled successfully. I tried to setup plugin settings with default values but it didn't work. So Admin/User has to configure them manually. image

2) Unfortunately we can't enable OAuth2 SSO by default because Vanilla Installer doesn't start: image

Thanks!

P.S. Known issue: if you enter a wrong email, click on "continue". Vanilla Installer displays an invalid email. After, fixing it, Vanilla Installer doesn't work. So with a docker we need to execute docker-compose down and run again. image

jmgasper commented 4 years ago

@atelomycterus - For the OAuth SSO, if we provide some details, can we use those details to auto-populate the database directly to try to work around the issue above?

atelomycterus commented 4 years ago

@atelomycterus - For the OAuth SSO, if we provide some details, can we use those details to auto-populate the database directly to try to work around the issue above?

@jmgasper Vanilla Forums Installer generates config.php from config-defaults.php during installation. All settings (connection db, plugins, and so on) are saved in config.php. Some details about Vanilla configuration files. I found in docs yesterday that there are hooks in bootstrap.

bootstrap.before is good for overriding functions or constants. Nothing is available. bootstrap.early is good for overriding config settings during initial install. Config values, functions, and constants are available. bootstrap.late has loaded the plugin, app, and theme managers, as well as loaded individual app configs. Validation functions are also loaded just before this. It's the last chance to turn on Debug via config. bootstrap.after has loaded the entire framework except the render functions. You could theoretically use all of Vanilla to do some logic on what render functions to use or do some prep before processing the user's request.

A file named conf/bootstrap.early.php can be created and used with the 'saveToConfig' function. Plan to implement today. Keep you updated. Don't close the ticket.

atelomycterus commented 4 years ago

@jmgasper bootstrap.early works for any plugins which keep all settings in config.php. So we can auto-populate with default values some plugins during initial install. It works for the next plugins:

OAuth2 SSO

All authentication providers save some parameters in the table 'UserAuthenticationProvider'. Enabling OAuth2 SSO alters the table 'UserAuthenticationProvider' by adding some columns. So I need to know what parameters/values will be used in OAuth2 SSO plugins. It'd be good if you provide it and I can test it.

atelomycterus commented 4 years ago

@jmgasper Implemented. Please apply PR. I couldn't check OAuth2 SSO Topcoder locally because I got "Callback URL mismatch.The provided redirect_uri is not in the list of allowed callback URLs.". So I tested with ngrok and configured google OAuth settings

The Vanilla url 'https:///entry/oauth2' should be added in Authorised redirect URIs.

What host should be used in /etc/hosts to get response from topcoder-dev.com? I tried topcoder-dev.com, dev.topcoder.com but it didn't work for me.

jmgasper commented 4 years ago

@atelomycterus - I think vanilla.topcoder-dev.com should work, but if not let me know.

atelomycterus commented 4 years ago

@jmgasper Yes, it works without any issues if it's deployed on vanilla.topcoder-dev.com and vanilla.topcoder-dev.com is added in Authorized redirect URIs. But using OAuth 2 SSO with docker on (127.0.0.1 or others) has an issue.
After getting a callback it redirects to the vanilla.topcoder-dev.com, not your docker vanilla host. if use a localhost or another URL not from a list of Authorized redirect URIs , then get "Callback URL mismatch.The provided redirect_uri is not in the list of allowed callback URLs."

jmgasper commented 4 years ago

@atelomycterus - I think that's fine. Normally, for other Topcoder services, we ask folks to add a local redirect to their hosts file for the targeted URL.

jmgasper commented 4 years ago

@atelomycterus - One question:

Can we move things from the bootstrap.early.php file into environmental variables please?

Things like:

The secret and attributes especially need to be moved because we can't keep those values in Git.

atelomycterus commented 4 years ago

@atelomycterus - One question:

Can we move things from the bootstrap.early.php file into environmental variables please?

Things like:

  • Plugins.Topcoder.BaseApiURL
  • Plugins.Topcoder.MemberApiURI
  • Plugins.Topcoder.MemberProfileURL
  • UserAuthenticationProvider / AssociationSecret
  • UserAuthenticationProvider / SignInUrl
  • UserAuthenticationProvider / Attributes

The secret and attributes especially need to be moved because we can't keep those values in Git.

@jmgasper Yes, I've checked Vanilla code, we can implement

 saveToConfig('<Key>', getenv('<Key>'), false);

If this is false then only the in-memory config is set.

Importanta Notes: After an admin makes a change in the dashboard, Vanilla will rewrite config.php and put the plaintext version of the env var.

After installation db settings as plaint text in config.php. I think the additional values should be fixed:

I'll add these params as env params in a docker-compose file

jmgasper commented 4 years ago

@atelomycterus - Yeah, we'll need to set those additional values from the environment those as well, thanks. I'm not too worried about having them in plaintext on the server, but I don't want them in plaintext in Git.

atelomycterus commented 4 years ago

@jmgasper Fixed. Please apply PR. I'll send mysql.env and vanilla.env with values by email. Thanks!

jmgasper commented 4 years ago

Payment task has been updated: https://software.topcoder.com/review/actions/ViewProjectDetails?pid=30122181

This is an automated message for ghostar via Topcoder X