tdmalone / slackemon

Inspired by Pokémon Go, now you can catch and battle Pokémon with your teammates on Slack!
GNU General Public License v3.0
10 stars 3 forks source link

Docker support #3

Closed Naramsim closed 7 years ago

Naramsim commented 7 years ago

Hi, in this PR you'll find a Dockerfile, which basically sets up Apache2 with PHP 7 and copies repository´s files on the image.

In order to run slackemon with Docker ones should:

git clone https://github.com/tdmalone/slackemon.git
docker build -t slackemon .
# copy .env.example to .env 
# and edit it with correct variables or load the variables in memory
# or modify your config file(not recommended)

# if env vars are in .env
docker run -p 80:80 -it --rm --env-file ./.env --name slackemonInstance slackemon

# if env vars are loaded in memory
docker run -p 80:80 -it --rm -e SLACKEMON_SLACK_TOKEN -e SLACKEMON_SLACK_TEAM_ID -e SLACKEMON_SLACK_GLOBAL_MAINTAINER -e SLACKEMON_CRON_TOKEN -e SLACKEMON_AWS_ID -e SLACKEMON_AWS_SECRET --name slackemonInstance slackemon

I strongly suggest recommending to use a .env file or load Env var in memory, this is the correct way. I suggest you to use this dotenvlibrary to load the vars in your config.php

In order to stop the instance, one has to CTRL-C it. To create a new instance just run the last command. Alternatively, one can remove -it and --rm flags and put -d, this configuration starts slackemon in the background and keeps it alive.

tdmalone commented 7 years ago

Thanks so much for this @Naramsim! I will have a go at running this. Might take me a bit because I'll be learning Docker at the same time.

I had also started integrating env vars as an alternative to the config.php so your suggestion comes at the right time.

@juz501 I believe absence of slashes in .gitignore just means a file can be matched as well rather than only a directory (the trailing slashes, anyway). Much of a muchness, probably. Leading slashes will only match files in the same directory as the .gitignore; absence of leading slash will match items any number of directories down.

juz501 commented 7 years ago

It will also match any file that has the extension .data now for example and also .data.template

Naramsim commented 7 years ago

Hi, I just removed the slashes because I like more the syntax. I will revert it

tdmalone commented 7 years ago

Update - looking good, did have issues (apache SIGWINCH error) starting in the foreground which I need to look into, but it runs in the background fine.

Todo:

Naramsim commented 7 years ago

Hi, I don't know why the error is triggered(i will investigate), for sure this is an official image, if the problem persists we can switch from Apache2 to Nginx, what do you think?

tdmalone commented 7 years ago

This is now in master - thanks so much @Naramsim!

Btw we could look at moving to nginx, yes. I have much less experience with it than Apache so let's hold off a little so I can focus on getting my head around things like Docker and Heroku first, and then when I'm ready for another stretch we could look at that ;)

juz501 commented 7 years ago

good job guys!

Naramsim commented 7 years ago

Ok, Nginx rocks!