- Go 1.16
- Protocol buffers
- MySQL
- Setting up server
Refer Setup Wiki for setting up Dalal-Street-Server
- Setup submodules
git submodule init
git submodule update --recursive
- Create databases and run migrations
mysql -u root -p -e "CREATE DATABASE dalalstreet_dev; CREATE DATABASE dalalstreet_test;"
migrate -path "./migrations" -database "mysql://root:YOUR_MYSQL_PASSWORD@/dalalstreet_dev" up
- Generate proto files
./scripts/build_proto.sh
- Run
cp config.json.example config.json
- Fill in the database credentials in the
Dev
section of config.json. - Run the server
- development - Install air for live reload
air
- production
go run main.go
- development - Install air for live reload
migrate create -ext sql -dir ./migrations MIGRATION_NAME
- Run the test script locally before pushing commits.
./scripts/test.sh
-
Install docker and docker-compose.
-
Run
cp .env.example .env
andcp config.json.example config.json
. -
Fill in the DB_PASS in .env and make any additional changes if necessary.
-
Use the same credentials in Docker section config.json (DbPassword)
-
Running server
docker-compose up
- Once the containers are up, you can get shell access by using
docker exec -it <CONTAINER_NAME> bash
-
To access phpMyAdmin, visit http://localhost:{PMA_PORT}/ (or http://localhost:9040/ by default)
-
If changes are made to the server files, rebuild image and run server with
docker-compose build
docker-compose up
(might require sudo, depending on permissions of volume mount './docker/' )
- To view all running docker containers:
docker ps
- Server logs are present in ./docker/logs/
- To generate mock for a file using mockgen, place this comment after import statement
//go:generate mockgen -source {YOUR_FILE_NAME}.go -destination ../mocks/{YOUR_FILE_NAME}.go -package mocks
- To generate mocks for all packages that has above comment
go generate ./...
- To manually generate a mock package
mockgen -destination=mocks/{YOUR_FILE_NAME}.go -package=mocks {PATH_TO_YOUR_FILE}