Skip to content

Commit

Permalink
Update README.md with clearer instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpillbox committed Jan 24, 2022
1 parent 243872a commit bed879b
Showing 1 changed file with 74 additions and 30 deletions.
104 changes: 74 additions & 30 deletions README.md
Expand Up @@ -2,46 +2,90 @@

A node.js port of [Isaac Lewis' Ruby version of Shintolin](https://github.com/IsaacLewis/Shintolin) - a persistent multiplayer browser game, set in the stone age.

## Running Locally (Docker Compose)
Forked from https://github.com/troygoode/shintolin

* Download the code via [git](http://git-scm.com/): `git clone https://github.com/troygoode/shintolin`
## Running Locally (Docker Compose) - UPDATED INSTRUCTIONS

* Download the code via [git](http://git-scm.com/): `git clone https://github.com/tmpillbox/shintolin`
* Install [docker](https://www.docker.com/)

### Prepare directory. In this case, I am deploying into a subdirectory of /opt/game on my linux host. Replace `/opt/game` with the appropriate substitution for your environment.

I will be storing my MongoDB database data in a host-mapped subdirectory rather than in a docker volume. By default, this will be called `mongodb` in the parent directory of the application/docker-compose

```bash
├── mongodb <------ database data path
└── shintolin
├── apps
├── bin
├── commands
├── data
├── node_modules
├── queries
└── test
```

```bash
# on host
docker-compose up shintolin3-mongo # start mongo in background
docker-compose run shintolin3-mongo bash # bash into mongo server

# TODO: describe how to bootstrap new database
mkdir /opt/game/shintolin
cd /opt/game/shintolin
mkdir /opt/game/shintolin/mongodb

git clone https://github.com/tmpillbox/shintolin
cd shintolin
```

### Run Docker-Compose to build the stack

```bash
docker-compose up -d
```

### Verify Docker containers are running. There are 3 expected

```bash
$ docker-compose ps

pillbox@host:/opt/game/shintolin/shintolin$ docker-compose ps
Name Command State Ports
------------------------------------------------------------------------------------------------
shintolin_shintolin3-clock_1 docker-entrypoint.sh node ... Up
shintolin_shintolin3-mongo_1 docker-entrypoint.sh mongod Up 0.0.0.0:27017->27017/tcp
shintolin_shintolin3_1 docker-entrypoint.sh bin/d ... Up 0.0.0.0:3000->3000/tcp
```

`shintolin_` is the name of the Docker-Compose stack. If the directory the docker-compose.yml file was in was called 'irregularwalrus', then the containers would be prefixed with `irregularwalrus_`. `shintolin3`, `shintolin3-clock`, and `shintolin3-mongo` are the names of the services/containers in the docker-compose.yml file. The trailing `_1` means it is the first instance of that container (docker-compose has built-in auto-scaling functionality, which will not be used)

### FIRST TIME ONLY -- INITIALIZE DATABASE

The previous steps can be used to re-build a pre-existing instance, such as after a reboot of the host. However, out of the box, there is no data in the database and the app will not function properly. To bootstrap the production data, use the following command:

```bash
pillbox@host:/opt/game/shintolin/shintolin$ docker exec -it shintolin_shintolin3_1 bash

#################
#### CAUTION ####
#################

# within mongo container
DIR=/host/... # tab complete the path to the Heroku mongo backup
mongorestore --db heroku_8xb5fctf $DIR
exit
root@f53cedf1dfb2:/usr/src/app# bin/dev/bootstrap-production shintolin.tsv

# back on host
npm install
npm start
```

## Deploying to Heroku

* Create an account on [Heroku.com](http://heroku.com/)
* Install the [Heroku Toolbelt](https://toolbelt.heroku.com/)
* From the Shintolin directory, create a new Heroku app: `$ heroku create`
* Add the [MongoLab add-on](https://addons.heroku.com/mongolab): `$ heroku addons:add mongolab`
* Add the [Heroku Scheduler add-on](https://addons.heroku.com/scheduler): `$ heroku addons:add scheduler:standard`
* Open the Heroku Scheduler configuration screen: `$ heroku addons:open scheduler`
* Add an hourly task that runs at `:00`, pointing to: `$ ./bin/tick_ap/_tick`
* Add a daily task that runs at `00:00`, pointing to: `$ ./bin/tick_day/_tick`
* Add three more daily tasks that run at `00:00`, `08:00`, and `16:00` - each pointing to: `$ ./bin/tick_hunger/_tick`
* Turn on production mode: `heroku config:add NODE_ENV=production`
* Use a safe session secret: `heroku config:add SESSION_SECRET=<YOUR_SECRET_HERE>`
* Push your code to Heroku: `git push heroku master`
* Start your free instance: `heroku ps:scale web=1`
* Log in to your game: `heroku open`

## License
This will populate the database with the default terrain/map and developer/admin users, Ecce.

### Logging in

By default, there is an admin user created called Ecce. You can log into this account by browsing to http://<hostip>:3000/, clicking "Log In", and then enterring username: `ecce@example.com`, password: `password`. I recommend changing the password for this user before opening access to the server to the internet.

### Port-Forwarding and Internet Hosting

(outside of the scope of this document)

Note that the web server will be listening on port 3000. IT IS NOT RECOMMENDED TO MAKE A PORT FORWARD FOR PORT 27017, there is no need for outside access directly to the database.


# License

Shintolin: a persistent multiplayer browser game, set in the stone age.
Copyright (C) 2013 Troy Goode
Expand Down

0 comments on commit bed879b

Please sign in to comment.