The MOTKI application server.
This repository contains the motkid
source code, including dependency source code (stored in vendor/
).
- A recent Go compiler
- go-bindata
go get -u github.com/jteeuwen/go-bindata/...
- postgres9 client (psql and pg_restore)
- protoc and proto-gen-go
- cat, awk, sed, grep, curl, bunzip2, unzip, git
- An available PostgreSQL database.
- A SMTP provider.
- A machine to run motkid on.
Download a copy of this repository and verify that the Makefile works.
curl -L -o motkid-master.tar.gz https://github.com/motki/motki-server/archive/master.tar.gz
tar xzf motkid-master.tar.gz
cd motkid-master
make debug
Assuming you haven't copied config.toml.dist
to config.toml
, you will be greeted with an error.
Makefile:61: *** config.toml does not exist. Copy config.toml.dist and edit appropriately, then try again.. Stop.
Once you've copied config.toml
, you can actually build the program. The simplest way is make
.
Target | Description |
---|---|
build | Build the motkid binary. |
install | Installs database schemas and EVE static dump data. |
uninstall | Drop created database schemas and EVE static dump data. |
clean | Delete all build files. |
generate | Runs go generate . |
matrix | Build a matrix of arches and OSes, see below. |
download | Download EVE static dump data. |
assets | Installs EVE static dump data. |
db | Install the required schema definitions into the database. |
schema_evesde | Installs the EVE static dump schema definitions. |
schema_app | Installs the app schema definitions. |
Note that Makefile targets that deal with the database connect to the server defined in
config.toml
Build for a specific OS and arch
make build GOOS=linux GOARCH=arm7
Cross-compile the binaries for many platforms at once
make matrix ARCHES="amd64 arm6 arm7 386" OSES="windows linux darwin"
Clone or download the repository.
This application does not rely on $GOPATH
, but if you are planning on making changes, it may help to put it there.
Below is an example of one way to get the code.
This assumes you have a simple
$GOPATH
with only one value (and no colons in it)
mkdir -p $GOPATH/src/github.com/motki
git clone [email protected]:motki/motki-server $GOPATH/src/github.com/motki/motki-server
cd $GOPATH/src/github.com/motki/motki-server
Load the data in the resources
folder.
- Un-bzip the
evesde-*-postgres.dmp.bz2
. - Use
pg_restore
to load the EVE static dump.Warnings abouts a missing "yaml" role can be ignored.
- Extract the Icons and Types zips to
public/images
(creatingpublic/images/Icons
andpublic/images/Types
)
Copy config.toml.dist
to config.toml
and edit appropriately.
To use the EVE API you need to set up an Application at the EVE Developer Portal. You'll need to select appropriate roles (all of them is fine) and then set a correct Return URL for your setup.
Note: the Return URL can include a port specification.
Once you have created your application on the developer portal, put the Client ID, Secret, and Return URL in the corresponding section in config.toml
.
You need to generate a certificate and private key to properly set up SSL. During development, a self-signed certificate is recommended. For production deployments, the process is made simpler by using Let's Encrypt to automatically generate a valid certificate.
Using Let's Encrypt is highly recommended. See this section for more information on setting up Let's Encrypt.
- Configure the SSL section in
config.toml
- Set
autocert=true
in config.toml. - Set
certfile=""
andkeyfile=""
in config.toml - Set the SSL
listen
parameter to a valid public hostname.
- Set
- ...
- Profit
- Copy the source code from this stdlib utility: generate_cert.go.
- Put it inside its own package (something like
./cmd/gencert/
in the project directory). - Compile and run it:
go run ./cmd/gencert/generate_cert.go --host localhost
- There should now be a
key.pem
andcert.pem
file in the current working directory. Updateconfig.toml
with the path to these. - Start motkid
Don't commit the
gencert
utility or the generated keys to the source code repository.
Build the motkid
command using make, then run the resulting executable.
$ make clean build
$ build/motkid -h
Usage of build/motkid:
-conf string
Path to configuration file. (default "config.toml")
-version
Display the application version.