Skip to content

Setup Docs

Ajitha Prasad Y edited this page Feb 5, 2022 · 7 revisions

Wiki for setting up Dalal Street Server locally.

Installing Go

Dala Street Server currently uses Golang 1.16. Download the same from this link.

Follow this link to setup Golang. After this you should get go version go1.16.9 upon running go version.

Golang needs 2 path variables for it to locate and store dependencies and executables

$GOPATH: Directory where all packages and modules for Go projects are located.

$GOBIN: Directory where binary executables of Go projects are located.

Create a directory go/ wherever you want and setup $GOPATH and $GOBIN paths in .bashrc file.$GOBIN also need to be appended to $PATH variable

export PATH=$PATH:`$OTHER_STUFF`:$GOBIN
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin

All Go packages will be stored under $GOPATH/src and modules under $GOPATH/pkg/mod and executables under $GOBIN

Installing Protocol Buffer

Protocol buffers Download link

Follow this link for setting up Protobuf.

To check if protobuf is installed properly run the following command.

protoc --version

Setting up Server Repo

go get github.com/delta/dalal-street-server

Binary executables

go install -tags 'mysql' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/[email protected]

Required Modules

cd $GOPATH/src/github.com/delta/dalal-street-server/
go get ./...

Setup submodules

git submodule init
git submodule update --recursive

Building Proto files

Proto files have to be built and converted to .pb.go files so that it can be used imported and used in our .go files

Go to dalal-street-server root directory and run this command

./scripts/build_proto.sh

Migrations

To run all the migrations

migrate -path "./migrations" -database "mysql://root:YOUR_MYSQL_PASSWORD@/dalalstreet_dev" up

Create Migrations

migrate create -ext sql -dir ./migrations MIGRATION_NAME

TLS keys

To create TLS keys for docker

mkdir tls_keys/docker/
cd tls_keys/docker/
openssl req -x509 -out server.crt -keyout server.key   -newkey rsa:2048 -nodes -sha256   -subj '/CN=localhost' -extensions EXT -config <( \
   printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
cd ../../