shibdib / Firetail

An EVE Online Discord Bot (Continuation of Dramiel)
MIT License
23 stars 22 forks source link

CONFIG and LOG environmental variables (And Docker stuff) #102

Closed karbowiak closed 6 years ago

karbowiak commented 6 years ago

Basically you can now define the config path and logFile path at runtime.

Example: CONFIG=/config LOG=/config/bot.log python3 firetail If they are not set - it will default to use the config.py located inside ./firetail/

If the CONFIG= environmental variable is set, it will check if the file exists - and if not, copy the example_config.py to the config.py path specified, and exit.

And yes, the copyfile path is hardcoded - because os.getcwd() doesn't work inside a docker container, and i assume docker containers is the only place where it'll see any use :P

Will look into a fix for it if need be

karbowiak commented 6 years ago

Manual build

If you need to manually build the container, either because of development - or because you can't use the public docker hub (or because the container doesn't exist) then just do the following steps

  1. Clone the repo
  2. Go to the directory where the repo was cloned to
  3. run docker build --no-cache -t shibdib/firetail .

Installation

To install the container, you either need to build it manually, or rely on the images built by docker hub. To install and run the container simply do the following

  1. run docker run -it --rm -v /etc/firetail:/config shibdib/firetail
  2. On first run, it will create the config file if it doesn't exist in the /etc/firetail directory - edit it with your token and run the bot again with the docker run -it --rm -v /etc/firetail:/config shibdib/firetail command - then you will see the invite url, save this so you can invite the bot to your server(s)
  3. ctrl-c out of the container, and run docker create --name firetail -v /etc/firetail:/config --restart always shibdib/firetail and then docker start firetail - now you have a working container, that is always running

Manual update

You can manually update the container - albeit it's a bit cumbersome

  1. docker stop firetail
  2. docker rm firetail
  3. docker pull shibdib/firetail THIS STEP CAN BE REPLACED WITH THE MANUAL BUILD IF YOU WANT
  4. docker create --name firetail -v /etc/firetail:/config --restart always shibdib/firetail
  5. docker start firetail

Automatic update

However if you just want it to automatically update as soon as there is a new build on docker hub - you can use Watchtower (It also updates all your other containers - so beware of this

  1. docker create --name watchtower --restart=always -v /var/run/docker.sock:/var/run/docker.sock -e WATCHTOWER_CLEANUP=true v2tec/watchtower
  2. docker start watchtower

And that's it :)

karbowiak commented 6 years ago

@shibdib just beware that the whole docker hub stuff hinges on you setting it up - otherwise users can only do manual builds :(