2024-11-09 07:29:47 +00:00
|
|
|
LOCAL_BIN := $(CURDIR)/bin
|
2024-11-09 10:26:59 +00:00
|
|
|
PATH := $(LOCAL_BIN):$(PATH)
|
2024-11-09 07:29:47 +00:00
|
|
|
|
2024-11-09 18:48:28 +00:00
|
|
|
ifeq (local-migrations-create,$(firstword $(MAKECMDGOALS)))
|
|
|
|
migrationName := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
|
|
|
|
$(eval $(migrationName):;@:)
|
|
|
|
endif
|
|
|
|
|
|
|
|
local-migrate-up:
|
2024-11-18 13:29:45 +00:00
|
|
|
@goose -allow-missing -dir ./migrations postgres "user=crab password=crab dbname=smm-core host=localhost port=5432 sslmode=disable" up
|
2024-11-09 18:48:28 +00:00
|
|
|
|
|
|
|
local-migrations-create:
|
|
|
|
@goose -dir ./migrations postgres "user=crab dbname=smm-core host=localhost port=5432 sslmode=disable" create "${migrationName}" sql
|
|
|
|
|
2024-11-18 13:29:45 +00:00
|
|
|
local-up:
|
|
|
|
docker-compose -f docker-compose-local.yml up -d --force-recreate --build
|
|
|
|
|
|
|
|
local-down:
|
|
|
|
docker-compose -f docker-compose-local.yml down
|
|
|
|
|
|
|
|
local-wait_db:
|
|
|
|
timeout 10s bash -c "until docker exec db pg_isready; do sleep 1; done"
|
|
|
|
|
|
|
|
local-restart: local-down local-up local-wait_db local-migrate-up
|
|
|
|
|
2024-11-09 07:29:47 +00:00
|
|
|
local-go-init: export GOBIN := $(LOCAL_BIN)
|
|
|
|
local-go-init:
|
2024-11-09 10:26:59 +00:00
|
|
|
go get github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway
|
|
|
|
go get github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2
|
|
|
|
go get google.golang.org/protobuf/cmd/protoc-gen-go
|
|
|
|
go get google.golang.org/grpc/cmd/protoc-gen-go-grpc
|
2024-11-09 07:29:47 +00:00
|
|
|
go install \
|
|
|
|
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
|
|
|
|
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
|
|
|
|
google.golang.org/protobuf/cmd/protoc-gen-go \
|
|
|
|
google.golang.org/grpc/cmd/protoc-gen-go-grpc
|
2024-11-18 13:29:45 +00:00
|
|
|
go install github.com/pressly/goose/v3/cmd/goose@latest
|
2024-11-09 07:29:47 +00:00
|
|
|
|
|
|
|
generate:
|
2024-11-09 10:26:59 +00:00
|
|
|
rm -rf proto resources
|
|
|
|
mkdir -p proto resources
|
2024-11-09 07:29:47 +00:00
|
|
|
protoc \
|
|
|
|
-I ./api \
|
|
|
|
-I ./third_party \
|
|
|
|
--go_out ./proto --go_opt paths=source_relative \
|
|
|
|
--go-grpc_out ./proto --go-grpc_opt paths=source_relative \
|
|
|
|
--grpc-gateway_out ./proto --grpc-gateway_opt paths=source_relative \
|
|
|
|
--openapiv2_out=./resources \
|
|
|
|
./api/smm_core.proto
|
|
|
|
|
|
|
|
run:
|
|
|
|
go run ./cmd/smm_core/main.go
|