Skip to main content

Setup Environment

For Backend Service (Go)

Setup git

Install git

For MacOS input command below to check git version

git --version

Configure Gitlab Credentials, go to any git repository and input below command:

git config --global user.name "gitlab_username"
git config --global user.email "email_address"

Export BOT_USER, BOT_PRIVATE_TOKEN

You can use bash or zsh to set up variable environment default. But suggested for you is zsh.

Install Oh-my-zsh

Check zsh version first

zsh --version

if zsh don't exist, try install zsh: Install zsh

Open zshrc file, ex:

code ~/.zshrc

Add these lines into zshrc file:

export BOT_USER=<gitlab_user_name>
export BOT_PRIVATE_TOKEN=<personal_access_token>

Note: Create person access token to get gitlab_user_name, personal_access_token

Setup Go-private

Setup Go-private can help download go private module.

Authenticate Go requests to private projects

Prerequisites

To authenticate Go requests, create a .netrc file with the following information:

machine gitlab.nautilusgames.tech
login <gitlab_user_name>
password <personal_access_token>

On Windows, Go reads ~/_netrc instead of ~/.netrc

The go command does not transmit credentials over insecure connections. It authenticates HTTPS requests made by Go, but does not authenticate requests made through Git.

Authenticate Git requests

If Go cannot fetch a module from a proxy, it uses Git. Git uses a .netrc file to authenticate requests, but you can configure other authentication methods.

Need setup GOPRIVATE, open .zshrc and add this line:

export GOPRIVATE=gitlab.nautilusgames.tech

if still error, try it

git config --global url."https://${BOT_USER}:${BOT_PRIVATE_TOKEN}@gitlab.nautilusgames.tech/".insteadOf https://gitlab.nautilusgames.tech/

Setup ENV for Mac

Install Golang (go)

  1. Install Go package
  1. Update environment’s path variable, change GOPATH to ~/go-workspace
  • Open terminal, input command below:
echo '# Golang Binaries' >> ~/.zshrc
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.zshrc

# Default GOPATH
echo 'export GOPATH=~/go' >> ~/.zshrc

# Change GOPATH to ~/go-workspace
echo 'export GOPATH=~/go-workspace' >> ~/.zshrc
echo 'export PATH=$PATH:$GOPATH/bin' >> ~/.zshrc
source ~/.zshrc
  • Then input this command to check GOPATH
vim ~/.zshrc

Install my-kit

# clone source
cd go-workspace/src/
mkdir gitlab.nautilusgames.tech
cd gitlab.nautilusgames.tech
mkdir marketplace
cd marketplace
git clone https://gitlab.nautilusgames.tech/marketplace/mykit.git

# open
code .

# open terminal
go mod tidy
go mod vendor
go install

# check command
mykit help

Setup protobuf

Manual setup

Note: Need to align version with mykit setup.

Install Protocol Compiler (protoc)

Check protoc version at protobuf

Example:

# download package
PB_REL="https://github.com/protocolbuffers/protobuf/releases/tag/v3.19.4"
curl -LO $PB_REL/download/v3.19.4/protoc-3.19.4-osx-x86_64.zip

# unzip
unzip protoc-3.19.4-osx-x86_64.zip -d $HOME/.local

cp bin/protoc $GOPATH/bin

Note: Based on your os, choose correct variant.

Install Go plugins (protoc-gen-go, protoc-gen-go-grpc) for the protocol compiler (protoc)

Install protoc-gen-go binary, protoc-gen-go-grpc binary with Go

go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2

Install gRPC Web protoc plugin (protoc-gen-grpc-web)

Install protoc-gen-grpc-web binary

curl -LO $PROTOC_GEN_GRPC_WEB_RL/download/v1.3.1/protoc-gen-grpc-web-1.3.1-linux-x86_64

cp ./protoc-gen-grpc-web-1.3.1-linux-x86_64 \
$GOPATH/bin/protoc-gen-grpc-web
chmod +x $GOPATH/bin/protoc-gen-grpc-web
Install gRPC-Gateway (protoc-gen-grpc-gateway, protoc-gen-openapiv2)

Install protoc-gen-grpc-gateway, protoc-gen-openapiv2 binaries with Go

go install \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v2.14.0 \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@v2.14.0
Install protoc-gen-validate

Install protoc-gen-validate binary with Go

go install github.com/envoyproxy/protoc-gen-validate@v0.10.1
Setup using Mykit

After install Mykit, using below command to setup protobuf:

mykit setup

Install Ent

go install entgo.io/ent/cmd/ent@latest

Install Docker

Install docker desktop for MacOS at: Install Docker Desktop on Mac

Setup build docker local

Open terminal and run command

docker login registry.nautilusgames.tech --username $BOT_USER --password $BOT_PRIVATE_TOKEN

On Ubuntu, before build image local by Makefile

docker run --privileged --rm tonistiigi/binfmt --install all

This terminal help push new image to registry

Setup AWS SSO account

Configure AWS CLI

Install AWS CLI: Install or update the latest version of the AWS CLI - AWS Command Line Interface

Choose the local profile name that you want. Example: gameloot-carem-engineer

Run command aws configure sso --profile <profile_name> and fill parameters if required:

SSO start URL: https://nautilusgames.awsapps.com/start
SSO Region : ap-southeast-1
CLI default client Region : ap-southeast-1
CLI default output format : json

Ex: aws configure sso --profile nautilus-engineer

Login AWS CLI with AWS SSO account

Run command aws sso login --profile <profile_name> to login to AWS CLI with config above.

Ex: aws sso login --profile nautilus-engineer

Using AWS SSO account to access K8S

Prerequisites

  1. Complete Setup AWS SSO Account
  2. Kubectl(for Kubernetes CLI access) Install Tools
  3. Lens(Kubernetes GUI access) Lens | The Kubernetes IDE
  4. Helm (for deploy backend service) Helm | Installing Helm

Update Kubeconfig

After login to AWS CLI, run following command to update kubeconfig:

aws eks update-kubeconfig --name <cluster_name> --alias <cluster_name> --profile <profile_name>

Ex: aws eks update-kubeconfig --cluster nautilus-eks-stg --alias nautilus-eks-stg -profile nautilus-engineer

To verify, run command kubectl get pods --context <cluster_name>

To run helm with specific cluster, add --kube-context <cluster_name> parameter.

Ex: helm list --kube-context <cluster_name>

For Game Client (Cocos Creator)

TODO: guide on how to setup environment to handle cocos's tasks

For Frontend

Prerequisites

  1. Install NodeJS: Use Volta to manage NodeJS version. (You can use NVM)

    Note We use NodeJs version: ^20

  2. Install Packages: Use PNPM to do it.

  3. Install VS Code

Create new source code

To make it easier, we use Vite to generate a folder structure with various templates.

pnpm create vite my-react-app --template react-ts

Extension for VS Code

NameLink
Prettierhttps://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
Auto Rename Taghttps://marketplace.visualstudio.com/items?itemName=formulahendry.auto-rename-tag
Code Spell Checkerhttps://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker
Auto Importhttps://marketplace.visualstudio.com/items?itemName=steoates.autoimport
ESLinthttps://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint