generated from VLADIMIR/template
51 lines
1.7 KiB
Makefile
51 lines
1.7 KiB
Makefile
# Local development user. Override DATABASE_URL/DEV_USER_* when needed.
|
|
DATABASE_URL ?= postgresql://postgres:postgres@localhost:5432/evening_detective_server?sslmode=disable
|
|
DEV_USER_USERNAME ?= dev
|
|
DEV_USER_EMAIL ?= dev@example.com
|
|
DEV_USER_PASSWORD ?= dev123456
|
|
|
|
.PHONY: dev-user
|
|
|
|
dev-user:
|
|
psql "$(DATABASE_URL)" \
|
|
-v ON_ERROR_STOP=1 \
|
|
-v dev_username="$(DEV_USER_USERNAME)" \
|
|
-v dev_email="$(DEV_USER_EMAIL)" \
|
|
-v dev_password="$(DEV_USER_PASSWORD)" \
|
|
-f scripts/dev-user.sql
|
|
|
|
# Protobuf generation (tool versions are documented in README.md).
|
|
# Install the pinned plugins before running: make install-generate-tools.
|
|
generate:
|
|
rm -rf proto
|
|
mkdir -p proto
|
|
|
|
protoc -I ./api \
|
|
--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,generate_unbound_methods=true \
|
|
--openapiv2_out=./cmd/evening_detective_server --openapiv2_opt allow_merge=true,merge_file_name=main \
|
|
./api/main.proto
|
|
|
|
install-generate-tools:
|
|
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.11
|
|
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.6.2
|
|
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v2.30.0
|
|
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@v2.30.0
|
|
|
|
run:
|
|
go run ./cmd/evening_detective_server
|
|
|
|
build-builder:
|
|
docker build -f Dockerfile.builder -t my-go-builder .
|
|
|
|
build-linux:
|
|
docker run --rm \
|
|
-v "$$PWD":/app \
|
|
-w /app \
|
|
my-go-builder sh -c \
|
|
"CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) go build -o bin/evening_detective_server ./cmd/evening_detective_server"
|
|
|
|
test:
|
|
go test -count=1 ./...
|