diff --git a/.gitmodules b/.gitmodules index 0f9962a..9d8134b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,16 +1,12 @@ -[submodule "ggpyjobs"] - path = ggpyjobs - url = git@github.com:nickelsen/ggpyjobs.git - branch = vagrant [submodule "ggtracker"] path = ggtracker - url = git@github.com:nickelsen/ggtracker.git - branch = vagrant + url = git@github.com:dsjoerg/ggtracker.git + branch = master [submodule "esdb"] path = esdb - url = git@github.com:nickelsen/esdb.git - branch = vagrant + url = git@github.com:dsjoerg/esdb.git + branch = master [submodule "sc2reader"] path = sc2reader - url = git@github.com:nickelsen/sc2reader.git - branch = vagrant + url = git@github.com:ggtracker/sc2reader.git + branch = upstream diff --git a/README.md b/README.md index 4c29665..ec02f65 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,46 @@ # ggtrackerstack Project to run the whole ggtracker stack in vagrant + +### Running + * Make sure you have vagrant+virtualbox installed on your computer + * Run `git submodule update --init --remote --recursive` to pull the latest version of each submodule + * Run `vagrant up` to create the virtual box. This will download all required packages and go through the installation process for ggtracker and ESDB (~15 minutes; go make yourself a sandwich) + * Run `vagrant ssh` to ssh into the vagrant box + * Make a note of your vagrant IP: In the text it prints out upon login it says IP address for eth1: 172.28.128.3 (potentially some other ip) + * Find code in /vagrant `cd /vagrant` + * Start the application (requires 2 ssh sessions, or run them as background jobs) + * ESDB: `(cd esdb && foreman start)` + * ggtracker: `(cd ggtracker && ESDB_HOST=172.28.128.3:9292 foreman start)` (change IP accordingly) + * Set up Amazon AWS S3 buckets for development as described in [esdb/config/s3.yml.example](https://github.com/dsjoerg/esdb/blob/master/config/s3.yml.example) (only dev and test are needed) and set up buckets and credentials accordingly in `esdb/config/s3.yml` and `ggtracker/config/s3.yml`. All buckets need to be [publicly readable](https://ariejan.net/2010/12/24/public-readable-amazon-s3-bucket-policy/) and the replay bucket needs to have [CORS enabled for GET, PUT and POST](http://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html). + * Open your browser to 172.28.128.3:3000 (or whatever your vagrant IP is from the previous step) + * The app will be on the ip of the vagrant box and uploading a replay should work - otherwise please raise an issue here, so it can be fixed. + +### Making changes to components +The components needed to run ggtracker.com are included in this project as submodules. We generally track the `master` branch of the official repos, except for sc2reader, which tracks the `upstream` branch. + +##### Making changes to `ggtracker`, `esdb` and `ggpyjobs` +To make a change to `ggtracker`, `esdb` or `ggpyjobs` and testing that they work in your local setup, we recommended that you fork the component to your own github account and add the fork to your working copy of ggtrackerstack like this (using `esdb` forked to `nickelsen` as example): + * Fork the component on github (e.g. nickelsen/esdb). + * Go to the ggtrackerstack directory of the component (e.g. ggtracker, esdb or esdb/vendor/ggpyjobs). + * Set your fork ssh url as the origin remote: `git remote set-url origin git@github.com:nickelsen/esdb.git`. + * Add the official repo ssh url as the upstream remote: `git remote add upstream git@github.com:dsjoerg/esdb.git`. + * Check your setup with `git remote -v` - should look like this (with your account instead of nickelsen). +``` +origin git@github.com:nickelsen/esdb.git (fetch) +origin git@github.com:nickelsen/esdb.git (push) +upstream git@github.com:dsjoerg/esdb.git (fetch) +upstream git@github.com:dsjoerg/esdb.git (push) +``` + * Once your remotes are set up, you can branch off master of your fork (`git checkout -b `), make your application changes, commit and push to your remote and create a pull-request against the official repo. + * **Note:** If you work on `ggpyjobs`, you need to also make a pull-request to `esdb` to make `esdb` actually use your new and improved version of `ggpyjobs` (we'll hopefully automate this remote tracking at some point). + * When the official repo changes (e.g. your pull-request is merged), you can update your working copy like this: + * `git fetch upstream` + * `git merge upstream/master` + * You can sync your `master` branch to the `master` branch of the `upstream` like this: + * `git checkout master` + * `git fetch upstream` + * `git merge upstream/master` + * `git push origin master` + +##### Making changes to `sc2reader` +Per default, `sc2reader` is managed by [requirements.txt](https://github.com/dsjoerg/ggpyjobs/blob/master/requirements.txt) in `ggpyjobs`. To work on `sc2reader` it is recommended to use the cloned submodule at the root of `ggtrackerstack` and install that in development mode on the vagrant box by issuing `python setup.py develop` in `/vagrant/sc2reader` after ssh'ing into the vagrant box. Forks and branches are managed as described above. diff --git a/Vagrantfile b/Vagrantfile index b43a061..189da35 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -4,6 +4,7 @@ Vagrant.configure("2") do |config| config.vm.hostname = "ggtrackerstack" config.vm.provision "shell", path: "setup-vagrantbox.sh" + config.vm.provision "shell", path: "install-ggtrackerstack.sh", privileged: false config.vm.provider :virtualbox do |vb| vb.memory = 1536 diff --git a/esdb b/esdb index e1baa3c..34a12a0 160000 --- a/esdb +++ b/esdb @@ -1 +1 @@ -Subproject commit e1baa3ccc01517773aef624b2164812150328760 +Subproject commit 34a12a09156f4a3e437a70abcb579c2a8325bef1 diff --git a/ggpyjobs b/ggpyjobs deleted file mode 160000 index 6bfa545..0000000 --- a/ggpyjobs +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6bfa5452ab15ceb5db6c8c9bd819a58685aee3a3 diff --git a/ggtracker b/ggtracker index 669b958..e81860a 160000 --- a/ggtracker +++ b/ggtracker @@ -1 +1 @@ -Subproject commit 669b9580a78b18594f63e6bcbdd91bbd3f4e4702 +Subproject commit e81860a887dfe814b0d24ab540291dae47eb58fc diff --git a/install-ggtrackerstack.sh b/install-ggtrackerstack.sh new file mode 100644 index 0000000..f15b83b --- /dev/null +++ b/install-ggtrackerstack.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +set -e + +cd /vagrant + + +echo INSTALLING GGTRACKER +# install ggtracker +(cd ggtracker && \ + bundle && \ + cp -np config/secrets.yml{.example,} && \ + cp -np config/s3.yml{.example,} && \ + rake db:create && \ + bundle exec rake db:schema:load) + +echo INSTALLING ESDB +(cd esdb && \ + cp -np config/database.yml{.example,} && \ + bundle && \ + (mysql -u root <<-"EOF" + create database if not exists esdb_development; + create database if not exists esdb_test; +EOF +) && \ + cp -np config/s3.yml{.example,} && \ + cp -np config/fog.rb{.example,} && \ + cp -np config/redis.yml{.example,} && \ + cp -np config/esdb.yml{.example,} && \ + cp -np config/tokens.yml{.example,} && \ + bundle exec sequel -m db/migrations -e development config/database.yml && \ + cat db/league_tables.sql | mysql -u root -D esdb_development && \ + cat db/ggtracker_provider.sql | mysql -u root -D esdb_development && \ + cat db/add_ai_identities.sql | mysql -u root -D esdb_development && \ + bundle exec rake py:init && \ + bundle exec sequel -m db/migrations -e test config/database.yml && \ + echo RUNNING TESTS && \ + bundle exec rspec) + +echo DONE install-ggtrackerstack.sh diff --git a/sc2reader b/sc2reader index 5e6e235..a131d50 160000 --- a/sc2reader +++ b/sc2reader @@ -1 +1 @@ -Subproject commit 5e6e235fa399dc691519d38faa11d71667b69002 +Subproject commit a131d50f31bf30d431157c8670d51b1e492ae9ea diff --git a/setup-vagrantbox.sh b/setup-vagrantbox.sh index 3547b84..ebfd38c 100644 --- a/setup-vagrantbox.sh +++ b/setup-vagrantbox.sh @@ -1,15 +1,27 @@ #!/bin/bash +set -e + export DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:chris-lea/redis-server -y apt-get update -apt-get install -y ruby redis-server nodejs npm mysql-server git-core ruby-dev libcurl4-openssl-dev libmysqlclient-dev build-essential libxml2-dev libxslt-dev memcached imagemagick libsasl2-dev python-pip python-dev libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk +# GGTRACKER dependencies +apt-get install -y \ + ruby redis-server nodejs npm mysql-server git-core ruby-dev \ + libcurl4-openssl-dev libmysqlclient-dev build-essential libxml2-dev \ + libxslt-dev + +# ESDB dependencies +apt-get install -y \ + memcached imagemagick libsasl2-dev python-pip python-dev libtiff5-dev \ + libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev \ + tk8.6-dev python-tk gem install bundler npm install -g juggernaut -# Juggetnaut looks for `node` instead of `nodejs` +# Juggernaut looks for `node` instead of `nodejs` sudo ln -s /usr/bin/nodejs /usr/bin/node