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

Added Docker configuration + HTTPS #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

wackerl91
Copy link

@wackerl91 wackerl91 commented Jan 25, 2018

I've added a simple Docker configuration for easier setup (or for those who prefer running stuff in docker) and somewhat functional HTTPS (need this for my own reverse proxy setups as port 80 is blocked in my firewall).

bin/www is still somewhat hacked and it still requires you to run db-migrate up from outside the container, though. Rest should be functional enough.

Happy to fix any remaining issues with this :) (E: this also depends on if you have any interest in looking at PRs at all ;) )

@rhysgs
Copy link
Owner

rhysgs commented Feb 1, 2018

Thanks! Will have a proper look/test with this tonight. Didn't expect PRs to come in, but always open to improving to bringing in improvements :)

edit: might add a js file for docker to run that will test the database state and try to run db-migrate up, etc as a setup process

@wackerl91
Copy link
Author

might add a js file for docker to run that will test the database state and try to run db-migrate up, etc as a setup process

That's actually a good idea. Right now everything's pretty hacky (esp. the callbacks in bin/www as mentioned above). I'll see if I can clean that up tonight so it literally requires only a docker-compose up for starting it.

@wackerl91
Copy link
Author

wackerl91 commented Feb 1, 2018

Based on your recommendation I've added a preflight check to verify the database state. This is always executed when running the container.
Additionally - as I've had a lot of issues on initial creation - the strongbox container now requires the DB container to finish loading, which makes the startup a bit slower but it's also less prone to errors and docker doesn't try restarting the strongbox container until it can finally connect to the DB (this behaviour also messed with the currency pulls).
Abyss League has gotten its own migration which automatically disables Harbinger and activates both ASC and AHC. S / SHC still requires manual changes.
HTTPS configuration is not a requirement anymore and neither is HTTP, so one can run either on HTTP or HTTPS or both, depending on preferences.

Note:

  • you should change the docker-compose file, the config file and the database config file if you want to change the ports of the server and / or of the database respectively (e.g. if you're already running multiple DBs in docker).
  • the initial run requires docker-compose up --build -d, where (in case you're not familiar with docker) --build (re)builds the strongbox container and -d detaches so it runs in the background. All subsequent starts require only docker-compose up -d, unless there are either code changes or DB migrations (which obvs. need to be copied to the container image first)
  • database host can not be localhost, as each container has its own IP and so on ... (E: to clarify: use the IP of the machine that's running docker or fiddle with the docker-compose file and link the containers, was just too lazy for that and since some stuff still requires manual changes it has to be reachable from the host either way)

Let me know if you (or anyone else reading this, for that matter) have any further questions :)

(P.S.: The preflight script really won't win any prizes, I couldn't write three lines of proper JS for my life and I really don't care to learn it - I'm familiar with other languages though :) Another edit: this also means that if I want to fix any stuff or build new features, I'd probably port it to another language that I'm more comfortable with. But for now it's a really great tool and I'm very grateful that you chose to open-source it. I've used it a lot in Harbinger and was really sad when you took your server offline. I'm now hosting it on a private server for my guildmates. Not sure if I can bring back a completely public version in the future as it's a really low-end one. Bla bla ... enough chit-chat, bottom line is: thank you very much for your initial efforts in building a great tool <3 )

@jaywalkerr
Copy link

Hi,

I basically got no clue what all this means, but I want to get this running. If I download this, how do I run it? Basically explain it like I'm 5.

-Jay

@wackerl91
Copy link
Author

wackerl91 commented Feb 23, 2018

ELI5:

  • download Docker for your OS and install it
  • make sure it works, e.g. by running the 'hello-world' image (docker run hello-world)
  • if that works you're halfway there, if not you'll need to google for your specific error / problem. Especially, I won't be able to assist you with Docker for Windows (never used it and I intend to keep it that way). However, here's the Install Guide for Windows and the Getting Started Guide.
  • once Docker works, go into the poe-strongbox folder and adjust the settings in the config.json file. Choose the appropriate scheme (HTTP and / or HTTPS) and provide a port. If you intend to use it only locally, HTTP only should be perfectly find - in this case remove the entries https_port, key and cert from the config file. If you opt for HTTPS, you need to provide key and cert files.
  • edit the settings in the docker-compose.yml to reflect your changes done to config.json, especially the following: if you changed the HTTP port, change the 3000:3000 mapping (this one). If you removed the HTTPS configuration, delete this line (make sure that networks will be the new line 29)
  • edit database.json and change the host line to match the IP address of your host machine (here) (you shouldn't need to change the local configuration, as docker-compose is set up to use the production environment)
  • you should be good to go now. For the very first start use docker-compose up --build -d (for explanations on what that does see my previous comment; run it from the project root, i.e. where the docker-compose.yml is located) and let it do its thing. Once running, don't instantly reboot you host as this will mess with the pulling of currency
  • afterwards the containers will always start once Docker starts (i.e. if Docker is set to run on system startup, the poe-strongbox containers will start as well; otherwise they will start as soon as you run Docker manually)

This is pretty much the simplest explanation I can give. If you shouldn't be able to get it running, feel free to shoot me an email (can be found on my GitHub profile) and I'm happy to provide further support and / or give you the URL to my installation (can't guarantee 100% uptime for that one though, as the machine which is running all that stuff is currently undergoing a lot of maintenance work).

@jaywalkerr
Copy link

jaywalkerr commented Feb 23, 2018

I can't seem to find half the files you are talking about...
But after reading the first comment over again and some googling... this line is missing (if people are as new to this as I am):
npm install -g db-migrate (this line before the next)
db migrate up
And I can't sm to find the config.json in the root directory. /edit:
npm install config.json
npm install gulp app
aaand I'm stuck again

@wackerl91
Copy link
Author

I can't seem to find half the files you are talking about...

This might very well be the case because you asked for introductions in a PR which specifically targets a docker setup, so naturally I assumed you would have downloaded my fork.

If you're using @Exgaves master branch then his directions in the readme are correct. Only thing I stumbled upon was that npm install doesn't install stuff globally, so I had to use ./node_modules/.bin/db-migrate up (from the project root; same for gulp).

Since I don't really have the time to walk you through it I've deployed the current version on one of my servers: https://strongbox.exxe.space. Note that this is a very low power / high bandwidth machine, so response times can get quite high.

@jaywalkerr
Copy link

If you're using @Exgaves master branch then his directions in the readme are correct.

I was not aware until now that I could download another branch, so I deleted everything and started over. Now all your instructions from the first post worked like a charm, with the exception of
docker-compose up

Creating network "poestrongboxmaster_poe" with driver "bridge"
ERROR: plugin not found

Went to docker root and tried npm install bridge, but that got me an error message. I really appreciate you trying to help me out. Will ask for help on reddit and see if that gets me there :)

@akaAMAZING
Copy link

@wackerl91 Is the program still hosted on your server? It is asking me for a username and a password. Is there any way to gain access or perhaps an alternate way? Thank you so much.

Copy link

@rogueyoshi rogueyoshi left a comment

Choose a reason for hiding this comment

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

i thought that private leagues broke strongbox... i couldn't get them to work when i tried this league. i will give your request a try myself.

"host": "<live db host>",
"user": "root",
"password": "root",
"host": "192.168.2.101",
Copy link
Owner

Choose a reason for hiding this comment

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

If you can put these details back to placeholders so the source doesn't contain forms of credentials I'm happy to merge this in

(sorry about the huge delay I just got quite burnt out from work and didn't feel like working on this for a while)

Copy link
Author

Choose a reason for hiding this comment

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

No worries about the delay. Hope you're feeling better now!

I'd prefer to just delete the entire file and instead add a file containing the placeholders as 'database.json.dist' (similar to how I've handled the config.json file) and add the one without .dist to gitignore. This prevents commits containing credentials in the first place, while also making sure to never replace edited config / DB credentials when pulling the latest master from your repo.

If you're ok with this approach I am more than happy to do the necessary changes plus adjust the readme accordingly and get back to you once it's done (currently not at home, so might take a few days).

Copy link

@jmunson jmunson Mar 20, 2019

Choose a reason for hiding this comment

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

The best practice for handling stuff like this is generally environmental variables. Making that change to poestrongbox does seem out of scope for this PR though. If @Exgaves doesn't want to change how configuration is passed in, a common approach when dockerizing services that need config files is to have a startup script generate the config file with envsubst and a template file.

EDIT: let me know if you want me to submit a PR for either of these btw

Copy link

Choose a reason for hiding this comment

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

Also hardcoding the IP doesn't work, when I try to use it it gets connection timeout errors. Replacing the IP with poe-db fixes this.

@rogueyoshi
Copy link

Hey, is this good to go for Blight League? And can I trivially enable more currencies for scanning?

@rogueyoshi
Copy link

rogueyoshi commented Sep 13, 2019

I've tried running this and my poe-strongbox container keeps restarting. Ran with completely default settings besides the local IP address (in production).

EDIT: found a bug. Port 3000 is hardcoded into the poe-strongbox container. got around it with a workaround of port-forwarding on it.

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.

7 participants