Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

1. Open your mac...

2. Install some software

  • Chrome / Chromium
  • Git
  • Slack
  • Brew

3. Install Scoir back-end dependencies

$ mkdir ~/opt
$ mkdir ~/dev && cd ~/dev

These instructions presume you have git set up and you have your keys in github

Redis
$ brew install redis@4.0
$ echo 'export PATH="/usr/local/opt/redis@4.0/bin:$PATH"' >> ~/.bash_profile
$ . ~/.bash_profile
$ brew services start redis@4.0
Elasticsearch

Do a brew search first, you want a ~6.x version

$ brew install elasticsearch

Mac's suck generally, and add the hidden .DS_store files everywhere for no good reason, as a result elasticsearch won't start, as the data dir created by the install isn't empty

$ rm -rf /usr/local/var/lib/elasticsearch/elasticsearch_`whoami`
$ brew services start elasticsearch
Kibana

A nice to have, you do not need it to run scoir

$ brew install kibana
$ brew services start kibana
Mongo
$ brew install mongodb@3.6
$ echo 'export PATH="/usr/local/opt/mongodb@3.6/bin:$PATH"' >> ~/.bash_profile
$ . ~/.bash_profile
$ brew services start mongodb@3.6
gnatsd
$ brew install gnatsd
$ brew services start gnatsd
nats-streaming-server
$ brew install nats-streaming-server

Edit the nats-streaming-server launch config to use a different port, otherwise it will clash with gnatsd

vi /usr/local/Cellar/nats-streaming-server/x.x.x/hombrew.mxcl.nats-streaming-server.plist

with

<key>ProgramArguments</key>
   <array>
     <string>/usr/local/opt/nats-streaming-server/bin/nats-streaming-server</string>
     <string>--port</string>
     <string>4223</string>
     <string>-cid</string>
     <string>Nidavellir</string>
   </array>

then

$ brew services start nats-streaming-server
postgres
$ brew install postgresql@9.6
$ echo 'export PATH="/usr/local/opt/postgresql@9.6/bin:$PATH"' >> /.bash_profile
$ brew services start postgresql@9.6
$ . ~/.bash_profile
$ createdb `whoami`
$ psql
# CREATE USER kong; CREATE DATABASE kong OWNER kong; ALTER USER kong WITH password 'kong';
# \q
kong

Make sure your xcode is up to date first (App Store)

 $ brew tap kong/kong
 $ brew install kong
 $ kong migrations bootstrap

add kong to launchctl

Create a file /Library/LaunchAgents/scoir.mxcl.kong.plist with the contents

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>scoir.mxcl.kong</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/kong</string>
        <string>start</string>
        <string>-c</string>
        <string>/etc/kong/kong.conf</string>
        <string>--nginx-conf</string>
        <string>/etc/kong/scoir-nginx.template</string>
    </array>
    <key>KeepAlive</key>
    <true/>
</dict>
</plist>

run

$ sudo chown root:wheel /Library/LaunchAgents/scoir.mxcl.kong.plist
$ sudo launchctl load /Library/LaunchAgents/scoir.mxcl.kong.plist
configure kong with the frontend configs
$ cd ~/dev && git clone git@github.com:scoir/frontend.git && cd -
$ sudo mkdir /etc/kong
$ sudo mkdir /etc/shared
$ sudo cp -r ~/dev/frontend/k8s/config/shared/ /etc/shared/
$ sudo cp -r ~/dev/frontend/k8s/config/local/ /etc/kong/

Check to see if everything is OK

$ sudo kong start -c /etc/kong/kong.conf --nginx-conf /etc/kong/scoir-nginx.template

If you restart, all services including kong should come back, verify with brew services list should look like

Name                  Status  User Plist
elasticsearch         started dev  /Users/dev/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
gnatsd                started dev  /Users/dev/Library/LaunchAgents/homebrew.mxcl.gnatsd.plist
kibana                started dev  /Users/dev/Library/LaunchAgents/homebrew.mxcl.kibana.plist
mongodb@3.6           started dev  /Users/dev/Library/LaunchAgents/homebrew.mxcl.mongodb@3.6.plist
nats-streaming-server started dev  /Users/dev/Library/LaunchAgents/homebrew.mxcl.nats-streaming-server.plist
postgresql@9.6        started dev  /Users/dev/Library/LaunchAgents/homebrew.mxcl.postgresql@9.6.plist
redis@4.0             started dev  /Users/dev/Library/LaunchAgents/homebrew.mxcl.redis@4.0.plist

4. Download and install latest version of Go 1.10 to ~/opt

Go 1.10

$ cp ~/Downloads/go1.10.8.darwin-amd64.tar.gz ~/opt
$ cd ~/opt
$ tar -xf go1.10.8.darwin-amd64.tar.gz
$ mv go go1.10
$ ln -s go1.10 go

to install multiple go's you can just switch your symlink.

Set $GOBIN, $GOROOT, update $PATH environment vars in .bash_profile:

export GOBIN="$HOME/opt/gobin"
export GOROOT="$HOME/opt/go"
export PATH="$GOBIN:$GOROOT:$GOROOT/bin:PATH"

Create the ~/opt/gobin

mkdir ~/opt/gobin

finally

 $ source .bashrc

5. Install Scoir API specification

install node version manager (nvm)
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
$ nvm install v8.9.3
$ nvm use v8.9.3
run the api spec "seed" to register routes with scoir
$ git clone git@github.com:scoir/api-spec.git
$ cd api-spec
$ . api-spec.sh
$ make bin/registrar
$ npm i -g multi-file-swagger
$ npm i -g swagger-cli
$ ./gen-and-validate.sh

If I haven't fixed the script get, open paths/paths.yml and search for occurrences of "Generated code. DO NOT EDIT." There should be one at the top of the file, and one around ~970 remove the block that looks like

Generated code. DO NOT EDIT.
    $ref: /paths.yml
$ ./bin/registrar public/api-spec.json

6. Install Scoir and its dependencies

Install Go Dep dependency management tool via curl:

$ curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh

Clone main scoir repo into ~/dev

$ cd ~/dev
$ git clone git@github.com:scoir/scoir.git
$ cd ~/dev/scoir/src/github.com/scoir
$ . scoir.sh
$ . scoir_dev.sh
$ dep ensure
$ cd ~/dev/scoir

Install additional libs

Install Rice (for email templates)

$ go get github.com/GeertJohan/go.rice
$ go get github.com/GeertJohan/go.rice/rice

Clean up after rice

$ rm -rf src/github.com/GeertJohan/
$ rm -rf src/github.com/akavel/
$ rm -rf src/github.com/daaku/
$ rm -rf src/github.com/jessevdk/
$ rm -rf src/github.com/nkovacs/
$ rm -rf src/github.com/valyala/

Install Mockery

$ go get github.com/vektra/mockery/.../

Clean up after mockery

$ rm -rf src/github.com/stretchr/
$ rm -rf src/github.com/vektra/
$ rm -rf src/golang.org/

Finally...

$ make run

7. Run the frontend

Clone repos:

$ cd ~/dev
$ git clone git@github.com:scoir/counselor-web.git
$ git clone git@github.com:scoir/admissions-web.git
$ git clone git@github.com:scoir/scoir_public.git
$ git clone git@github.com:scoir/student-web.git
$ git clone git@github.com:scoir/parent-web.git
$ git clone git@github.com:scoir/teacher-web.git

Now clone slartibartfast as it contains helper scripts

$ git clone git@github.com:scoir/slartibartfast.git

Copy helper scripts

$ cp run-fe.sh switch-fe-branch.sh ~/dev

Install tmux

$ brew install tmux
$ tmux

Login to npm

export NPM_TOKEN=71f34c2f-d6c0-4480-bfad-6828710d75e5 
npm login

Run

$ cd ~/dev
$ ./switch-fe-branch.sh develop
$ ./run-fe.sh

To kill all fe windows hit ctrl+b then shift+7 then at the prompt hit y

Rinse and repeat to run a different branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment