1# Codies
  2
  3This is a fork of [eltmon/codies](https://github.com/eltmon/codies) from GitHub.
  4I run my own instance of it but, it's just for friends; the old one run by the
  5original creator, [codies.xyz](https://codies.xyz), was taken down due to
  6copyright issues and I would prefer to avoid the same thing happening to mine.
  7If you would like to host this yourself, please follow the included
  8instructions.
  9
 10*From the original README:*
 11
 12Yet another Codenames webapp. Featuring:
 13
 14- Custom word packs
 15- Timed mode
 16- Quick room joining
 17- Dark/light mode
 18- Responsiveness for mobile play
 19- And more!
 20
 21This is entirely inspired by the wonderful
 22[codenames.plus](https://github.com/Joooop/codenames.plus), which works very
 23well, but hasn't been scaling too well recently. I wanted an opportunity to
 24learn TypeScript and React, and figured I could make something that worked just
 25as well with a few extra niceties (and a more stable backend).
 26
 27
 28
 29# Manual installation
 30
 31## Prerequisites
 32
 33First, you'll need Golang 1.15 and Node 14 for building codies. Take a look at
 34golang's [download](https://golang.org/dl/) page and follow the related
 35documentation for [installing with the binary](https://golang.org/doc/install)
 36or [from source](https://golang.org/doc/install/source), then for Node, try
 37[NodeSource](https://github.com/nodesource/distributions).
 38
 39## Creating users
 40Running codies as root is not recommended. Please run the following commands to
 41create a new unprivileged user and execute all of the commands in the following
 42section as that user.
 43
 44``` shell
 45useradd -Ums /bin/bash codies
 46su -c /bin/bash - codies
 47git clone https://git.sr.ht/~amolith/codies
 48cd codies
 49```
 50
 51
 52## Building the frontend
 53
 54``` shell
 55cd frontend
 56yarn install --frozen-lockfile
 57yarn build
 58```
 59
 60## Building the backend
 61
 62``` shell
 63go mod download
 64go run github.com/markbates/pkger/cmd/pkger
 65go run github.com/markbates/pkger/cmd/pkger -o internal/pkger
 66go build -ldflags="-X github.com/zikaeroh/codies/internal/version.version=1.15" .
 67```
 68
 69## Running
 70Execute the binary to ensure it all works properly:
 71
 72``` shell
 73./codies --debug
 74```
 75
 76## Daemonizing
 77If you want it to start as soon as your machine boots and that it restarts on
 78crash, you'll need to run it with a supervisor like OpenRC, runit, or systemd.
 79
 80Below is a service file for systemd. If you want to use it, paste the contents
 81into ~/etc/systemd/system/codies.service~.
 82
 83``` shell
 84[Unit]
 85Description=Codies
 86After=network.target network-online.target
 87Requires=network-online.target
 88
 89[Service]
 90Type=simple
 91User=codies
 92Group=codies
 93WorkingDirectory=/home/codies/codies
 94ExecStart=/home/codies/codies/codies --debug
 95TimeoutStopSec=5s
 96PrivateTmp=true
 97ProtectSystem=full
 98
 99[Install]
100WantedBy=multi-user.target
101```
102
103## Reverse proxy
104Runing codies behind a reverse proxy is recommended. With
105[Caddy](https://caddyserver.com/), this is as simple as
106
107``` shell
108example.com {
109    encode zstd gzip
110    reverse_proxy localhost:5000
111}
112```
113
114For NGINX, the vhost could look something like this
115
116``` shell
117server {
118listen 443 ssl http2;
119listen [::]:443 ssl http2;
120
121      server_name example.com;
122
123      ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
124      ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
125
126      location /
127          proxy_pass http://localhost:5000;
128          proxy_http_version 1.1;
129          proxy_set_header Upgrade $http_upgrade;
130          proxy_set_header Connection "Upgrade";
131          proxy_set_header Host $host;
132      }
133}
134```
135
136# Docker installation
137The Dockerfile will only be kept as long as it continues working. My goal in
138forking the app is to rip Docker out and package the entire thing up in a single
139statically-linked binary.
140
141I don't know whether this will actually succeed, but here you go!
142
143``` shell
144docker build -t codies .
145docker run -p 5000:5000 codies
146```