Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deployment instructions #67

Open
LukeSchlangen opened this issue Apr 5, 2020 · 3 comments
Open

Add deployment instructions #67

LukeSchlangen opened this issue Apr 5, 2020 · 3 comments

Comments

@LukeSchlangen
Copy link

@jbowens This is awesome! I've tried playing the last two Friday nights, and the site has been down both times (I'm guessing because of the amount of traffic).

I tried deploying on Heroku and Netlify with no luck. Would you be able to share how you deploy (even if just where you deploy?) and I can attempt to deploy and then document that in the Readme?

Thank you!

@jbowens
Copy link
Owner

jbowens commented Apr 8, 2020

Hi @LukeSchlangen,

Thanks for the note! Yeah, there've been a couple problems in the last couple weeks. Some were bugs that only manifested under the higher load the site has been getting recently, and others were deployment issues under load (like the process's ulimit being too low). I do believe that I have horsepaste on a sufficiently resourced box now and these issues should be resolved.

That said, if you want to deploy it, here are some high-level notes:

  • The server side is written in Go, so you'll need a Go environment to compile (or cross compile) the codenames binary. Typically once you have the repo cloned into $GOPATH/src/github.com/jbowens/codenames, you go install github.com/jbowens/codenames/cmd/codenames to build the binary and have it deposited into $GOPATH/bin.
  • The frontend uses parcel. You'll need parcel installed, and I think probably a few related dependencies like node.js. The tiny bash script in frontend/build.sh will build the frontend, creating a frontend/dist directory with the resulting assets.
  • In addition to a frontend/dist directory, the codenames binary also expects an assets/ directory to be in the current working directory, containing the contents of this repo's assets/ directory. The easiest thing to do is just run the codenames binary w/ the current working directory set to the github repo's directory where you've already built the frontend.
  • Lastly, the codenames binary uses an embedded-kv store to persist games between process restarts. If I recall correctly, Heroku doesn't give you a persistent filesystem, so this probably precludes deploying to Heroku if you don't want to wipe all games on Heroku dyno restarts. There's an optional environment variable PEBBLE_DIR that can be set to tell the codenames process where on the filesystem it should write data. If you omit the environment variable, it'll default to (and create) a db directory within the current working directory.

When I deploy it horsepaste.com, I also setup a systemd service to restart the process if it crashes for some reason, and I also proxy all requests through nginx which handles TLS termination, gzip compression and sane request timeouts and the like. I run horsepaste on a DigitalOcean droplet running Ubuntu.

@zbennett
Copy link

zbennett commented Apr 9, 2020

I had issues with Heroku as well. The problem is that Heroku doesn't allow you to expose ports, they just assign you a port and you have to use that. So I made a couple changes and it was up and running. In the Dockerfile change EXPOSE 9091/tcp to CMD gunicorn --bind 0.0.0.0:$PORT wsgi and in main.go change const listenAddr=":9091" to var listenAddr = ":" + string(os.Getenv("PORT")) .

That is all I had to do and it booted up on Heroku.

@kaczmarj
Copy link
Contributor

kaczmarj commented May 9, 2020

@LukeSchlangen - I recommend deploying using the included Dockerfile. That file provides a standard method of installing this software, and you won't have to worry about the dependencies that @jbowens went through. Most cloud providers give access to Docker, which is all you would need to run the game.

Instructions are in the README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants