-
Notifications
You must be signed in to change notification settings - Fork 3
Installing on Docker
In this wiki page you will find the instructions to set up a working Slackémon server using Docker Compose.
First, Docker (and Docker Compose on Linux) needs to be installed if it isn't already. Slackémon has been tested with Docker version 17.
Once the installation is complete, download the latest Slackémon release from GitHub:
git clone https://github.com/tdmalone/slackemon.git
cd slackemon
Now you have to define some environment variables, by editing the .env file, or by loading them in memory (if you load them in memory, be sure to store them so they're still there next time).
cp .env.example .env
nano .env
Full instructions are available inline in the .env.example
file - read them carefully, and be sure to at the very minimum set the required variables - we do need to connect to your Slack organisation, after all.
Now it is time to start slackemon
!
./scripts/start
Wait for the download and the build - this will take some time the first time you do it.
Then, your server will be up at localhost
- you can view it at http://localhost and probably also at http://YOUR.LOCAL.IP.ADDRESS/
(you should get a message saying you're not authorised - that's good, that means it's working! Only calls sent by Slack will be allowed all the way through).
Now, to allow Slack to access your installation, you can install ngrok (or localtunnel.me) to make it accessible to the Internet (always use an https URL):
ngrok http 80
To take the server down, run ./scripts/stop
. You can start it again at any time with ./scripts/start
.
Also available is ./scripts/restart
, and ./scripts/reset
which will do a full cycling of the containers and refresh the database storage (if you're using that storage method).
These scripts simply run docker-compose
with various arguments. You can view the files to see exactly what they're doing.
By default your player and battle data will be stored in the filesystem. Our Docker Compose setup comes with a Postgres container, and you can use it as your data store by setting SLACKEMON_DATA_STORE_METHOD
to postgres
in your .env
file. This mimics how Slackémon will run on a platform-as-a-service host such as Heroku.
If you're making changes to your .env
file or changing your environment variables in memory, run ./scripts/restart
to refresh the environment and bring the containers up again.
If you want to view and even edit the database fields live, try downloading pgAdmin 3 (not pgAdmin 4 - you could, but it's not as easy to use!). You then just need to publish your Postgres ports by creating docker-compose.override.yml
with the following configuration:
version: "2"
services:
database:
ports:
- "5432:5432"
Your database will then be available on port 5432 on your localhost, with the username, password and database name you have set in your .env
file. You'll need to run ./scripts/reset
for the above changes to take effect.
For security reasons, binding your database ports is not recommended in a production environment.
If you've already got something else running on port 80, you may want to run Slackémon on an alternative port. Unlike above, unfortunately the override file will not let you remove the default ports we've set, so you'll need to edit the real docker-compose.yml
and change the webserver ports configuration like this:
...
webserver:
...
ports:
- "8080:80"
...
In this example, Slackémon will then be available at http://localhost:8080. You'll need to run ./scripts/reset
for the above changes to take effect.
If you're helping to develop Slackémon, please take care not to commit this change back into git.
If you make changes to the Dockerfile included with Slackémon, note that our docker-compose.yml
automatically pulls the latest official image from Docker Hub, which will mean that by default any changes you make will not be built.
If you wish to rebuild the slackemon_php
image from your local Dockerfile, you will need to edit docker-compose.yml
(this can't be done in the override file) and replace:
image: tdmalone/slackemon
with:
build: .
If you're helping to develop Slackémon, please take care not to commit this change back into git.
If you're using the scripts in the ./scripts
folder to start and stop Slackémon, you may also have other tasks you'd like to perform at the same time. You can do this by creating custom start.local
and stop.local
files within the ./scripts
folder.
For example, you may like to automatically start ngrok in the background everytime you start Slackémon...
./scripts/start.local
#!/usr/bin/env bash
# Start ngrok in the background with a reserved subdomain.
# If you don't have a paid ngrok account, leave off the -subdomain argument and run http://localhost:4040
# after you start to find out what your randomly assigned URL is.
# Also, you should set the region to the one closest to you (https://ngrok.com/docs#global-locations).
ngrok http -subdomain=YOUR_RESERVED_NAME -region=au 80 > /dev/null &
...and then kill ngrok everytime you stop:
./scripts/stop.local
#!/usr/bin/env bash
# Kill an ngrok process running in the background.
kill `ps aux | grep ngrok | grep -v grep | awk '{print $2}'`
If they exist, these scripts will automatically be invoked whenever you run ./scripts/start
and ./scripts/stop
, respectively.