"Where I go to do battlesnake." - @bvanvugt
This is the platform that allows users to sign up, register snakes, and run games.
- On a mac? If you haven't already, install brew
- A Github OAuth App
- Postgres 10.4
-
Clone the repo to your machine:
git clone git@github.com:battlesnakeio:play -
Install python3.x
- on a Mac:
brew install python3- Alternatively, use
pyenvandpyenv-virtualenvto manage your python installations
- Alternatively, use
- on Linux:
apt-get install python3
- on a Mac:
-
Install the project dependencies:
pip3 install -r requirements.txt
- Using pyenv? Use
pipsupplied by your virtualenv instead ofpip3 - optionally install via pyenv
pyenv install 3.7 pyenv virtualenv 3.7 play pyenv activate play
- Using pyenv? Use
-
From inside the project
playfolder, run the migrations:ENV=local \ PYTHONPATH=~/path/to/play/play \ ./manage.py migrate -
Start the server with:
ENV=local \ PYTHONPATH=~/path/to/play/play \ ./manage.py runserver -
Visit the app running at http://localhost:8000
To run tests:
cd play
ENV=local pytestGo here: https://github.com/settings/applications/new
Fill in the following:
- Name = whatever you want
- URL = http://localhost:8000
- Callback = http://localhost:8000/oauth/complete/github
Copy the generated secrets in to your .env (described below)
Your .env file should contain the following:
ENV=local
BATTLESNAKEIO_SECRET=battlesnakeio
BATTLESNAKEIO_GITHUB_CLIENT_ID=...
BATTLESNAKEIO_GITHUB_CLIENT_SECRET=...If using postgres locally (instead of SQLite), you'll also need:
POSTGRES_HOST=...
POSTGRES_PORT=...
POSTGRES_DB=...
POSTGRES_USER=...
POSTGRES_PASSWORD=...Docker is used to build the production image that gets deployed. You can also use it to build an image you can run yourself:
- Build the image:
docker build -t battlesnakeio/play . - Run databases:
docker run -it -d --env-file=.env -p 5432:5432 --name=battlesnakeio.play.pg postgres:10.4 - Run server:
docker run -it -d --env-file=.env -p 8000:8000 --name=battlesnakeio.play battlesnakeio/play