There are two ways to run the application. The first is to setup all dependencies manually. The second is to use docker image and docker compose.
-
Create
.env
fileYou can copy the
env.example
and change its values accordingly$ cp env.example .env
-
Fill all env variables with prefix
POSTGRES_
according to your PostgreSQL settings -
Run or start PostgreSQL
-
Fill the
REDIS_*
envsREDIS_TTL
is a Time to Live for a key-value in redis.REDIS_TTL=5
means its TTL is 5 minutes -
Run or start Redis
-
Fill
PORT_GRPC
andPORT_GRPC_GATEWAY
value as you wish. We use8080
as default value forPORT_GRPC
and8081
forPORT_GRPC_GATEWAY
.PORT_GRPC
is a port for HTTP/2 gRPC.PORT_GRPC_GATEWAY
is port for HTTP/1.1. We encourage to let both values as default -
Run or start Kafka
-
Download the dependencies
$ make tidy
-
It is always good to have your database migration up-to-date. Run the following command to make your database stays up-to-date with the current migrations.
$ make migrate url=<postgres url>
e.g:
$ make migrate url="postgres://user:password@host:port/dbname?sslmode=disable"
DON'T FORGET to supply/change the
user
,password
,host
,port
,dbname
, andsslmode
according to your database settings. -
Run the application
$ go run cmd/server/main.go
-
Install Docker Compose.
-
Run docker compose
$ docker-compose up
-
In another terminal window, download the dependencies for the application
$ make tidy
-
Create
.env
fileYou can copy the
env.example
and change its values accordingly$ cp env.example .env
-
Run the application
$ go run cmd/server/main.go