A self-hosted sport betting game for me an my friends, written in Go.
- Install Go
- Install MySQL
- Create user and database (suggested: db name
gotipp
and user namegotipp
). - Run database setup (see below)
- Setup a local certificate for https (see below)
- Add the database connection string to your environment variables
export DATABASE_URL="mysql://DB_USER:DB_PASSWORD@HOST:PORT/DB_NAME"
export DATABASE_URL_GO="DB_USER:DB_PASSWORD/DB_NAME?parseTime=true"
Note: Replace DB_USER, DB_PASSWORD and DB_NAME with the values for your system.
- Install dbmate for database migrations: https://github.com/amacneil/dbmate
- (optional) Run
dbmate create
to create a new database (if you haven't done that manually) - Run
dbmate up
to run the migrations which create the schema and insert initial data
For local development, create a self-signed certificate.
mkdir tls && cd tls
go run /usr/local//Cellar/go/1.22.3/libexec/src/crypto/tls/generate_cert.go --rsa-bits=2048 --host=localhost
Note: The path to generate_cert.go
may be different on your system, but it should come included with your Go installation.
Note: Replace db name, user name and password with your own names in the following statement:
Run with https enabled (using local self-signed certificate)
sh runhttps.sh
Run with http disabled (for example in production: using the https of a production server, behind a reverse proxy)
sh run.sh
In your browser, open:
https://localhost:8090/
Run this script to fetch results from
Set up cronjob (configured to run on Uberspace):
MAILTO=""
# disable emails of crontab output (errors will still be mailed)
*/2 17-23 * * * export DATABASE_URL_GO="<syntax see above>"; cd /path/to/go-tipp; /bin/bash fetch_results.sh
(Runs every two minutes between 17:00 to 23:59)
- Favicon source (licensed under CC-BY 4.0): https://favicon.io/emoji-favicons/soccer-ball
All code that is not included from a third party is licensed under the MIT License.