This guide assumes you are on a UNIX based environment. Also make sure you're in the root of project.
# make
make postgres
# no make
docker run -e "POSTGRES_USER=vedia" -e "POSTGRES_PASSWORD=123" -e "POSTGRES_DB=vediagames" -p 5432:5432 -d postgres:15.0-alpine
# make
make redis
# no make
docker run -p 6379:6379 -d redis
# make
make gqlgen/bff
# no make
cd bff && go get github.com/99designs/gqlgen && go run github.com/99designs/gqlgen generate
You can pretty much copy the content from config.example.yml to config.yml
cp config.example.yml config.yml
go run . migrate
go run . stub
go run . refresh
go run . server
Quick explanations regarding some decisions and patterns established.
We have a single main.go, which is made with cobra framework. This ensures that the whole app is pretty much a single binary that can be created and deployed as a single container image. This makes things very manageable.
There are some helper modules that are also used, but for the bigger part, everything is pretty much here build and run as a single binary.
I'll explain what each package contains and what is it's meaning of existence.
Short for backend-for-frontend. Basically, a gateway that exposes backend services through GraphQL API. Uses gqlgen for GraphQL code generation. Also code for retrieving data for specific pages on vediagames.com lives here. (Let's call it page service)
S3 and GCS (Google Cloud Storage) client implementations for providing S3 storage functionality to vediagames. We use it for uploading images and videos when publishing new games.
Services.
Cobra commands (migrate, server, stub)
Config package.
Client implementations for game distribution and game monetize. These provide games for us and these implementations fetch them.
Schema and migrations for the database. Also includes some stub data for stubbing local DB for development.
Search service that provides search functionality for the website. This service connects all other services that support search and adds business logic on top of them.
https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key
A little advice here, use different keys for different services/accounts. Prefix them with the service/account name. For
example id_rsa.github
Simply run this command:
git config --global --add url."ssh://[email protected]/".insteadOf "https://github.com/"
Append this two lines to the end of the document:
[url "ssh://[email protected]/"]
insteadOf = https://github.com/
Add these 5 lines:
Host github.com
User git
Hostname github.com
IdentitiesOnly yes
IdentityFile ~/.ssh/id_rsa_github `**<- MAKE SURE THAT THIS POINTS TO YOUR SSH KEY THAT YOU GENERATED IN STEP #1**
This should now allow you to freely clone repos from github.com/vediagames
You can check whether everything went well by running this command (this clones vediagames.com/category repo)
git clone [email protected]:vediagames/vediagames.com.git
After you've done setting up your SSH authentication which allows you to freely clone repos from GH, you still need to
do something else to make everything run smoothly on your development machine (as far as Go
development goes)
Luckily this is very simple, you can just run:
go env -w GOPRIVATE="github.com/vediagames"
To test, you can try running this inside any folder that has go.mod file:
go get github.com/vediagames/zeroerror
You can also use GoLand to set it up by editing the Environment input box in File/Settings/Go Modules.
But that will
only work in the directory you're currently in.