Skip to content
This repository has been archived by the owner on Jan 16, 2019. It is now read-only.

Building

Darwin Froese edited this page Oct 25, 2017 · 5 revisions

Building Hacksite

Hacksite can be built using the supplied scripts that will make everything much easier or manually using the same steps.

Pre-Requisites

  1. Verify that you have the latest Go version installed and it's accessible from where you cloned Hacksite
  2. Verify that you have Yarn installed and that it's accessible from where you cloned Hacksite
  3. Verify that you have the environment variable GOROOT set (This is needed to generate the certificates for SSL)

Environment Configuration

Hacksite uses environment configuration files to configure different information for the server.

{
  // These options configure information for the server
  "Server": {
    // These are the certificate files for HTTPS
    "KeyLocation": "certs/key.pem",
    "CertLocation": "certs/cert.pem",
    // This is the port that the HTTPS server will listen on
    // The HTTP to HTTPS redirect always listens on :80
    "Port": ":5000",
    // This is the relative path to your compiled web client
    "WebFileLocation": "./webdist"
  },
  // These options configure the logger
  "Logger": {
    "LogFileLocation": "./logs"
  },
  // These options configure the database
  "Database": {
    // "bolt" will use boltDB (preferred method for locally running Hacksite)
    // which will create a database on disk (database.db)
    // "dynamodb" will use Amazons DynamoDB and will
    // require the AWS section to be configured
    "System": "bolt"
  },
  // These options configure AWS access settings
  "Aws": {
    // These are the IAM settings needed for the user that
    // will be used to connect to AWS
    "AccessKey": "",
    "SecretKey": "",
    "Token": "",
    "Region": ""
  }
}

Windows

To build Hacksite on Windows you need to do the following

  1. If you want to use a different environment config than environments/dev.env.json specify it as a temporary environment variable SET enviroment_file=path/to/file
  2. Run make.bat -- make.bat will start by grabbing all of the Go and Web dependencies and generate certs prior to running the command specified

make.bat

The make.bat file has an optional command that you can pass to perform certain actions:

  • default - This will build both the web client and the server (this is the default command if you don't pass any in)
  • test - This will run tests on both the web client and the server
  • buildServer - This will build just the server
  • buildWeb - This will build just the web client
  • testServer - This will test just the server
  • testClient - This will test just the client

Mac OS X and Linux

To build Hacksite on OS X and Linux you just need to use the makefile supplied

  1. If you want to use a different environment config file than environments/dev.env.json, specify it by overriding the value in the makefile make [command] ENVIRONMENT_FILE=/path/to/envfile
  2. Run make with an optional parameter

Makefile

  • all - This will call setup server and web (this is the default action if no optional command is specified)
    • all will not generate local certificates, you need to use the command local or buildLocal for that
  • local - This will call setup buildLocal and web
  • setup - This will call both setup-go and setup-web
  • setup-go - This will get all of the go dependencies
  • setup-web - This will get all of the web dependencies
  • buildLocal - This will generate local certificates and build the server
  • server - This will build the go server
  • web - This will build the web client
  • serverTests - This will build the server and run the server test (This also clears out the local database to make sure there is no conflicting data)

Manually

Building

  1. Get the go dependencies:
    • run go get -t -v -d ./...
  2. Get the web dependencies: (in the webclient directory)
    • run yarn
  3. Generate the certificates: (pass in the goroot environment variable for your system)
    • run go run {goroot}/src/crypto/tls/generate_cert.go --host localhost
  4. Build the server:
    • run go build server/cmd/server.go
  5. Build the web client:
    • run yarn run build

Testing

  1. Testing the server: (this only tests the pkg folder where all the tests are)
    • run go test -v ./server/pkg/...
  2. Testing the webclient:
    • run yarn run test