42 lines
1.6 KiB
Makefile
Executable File
42 lines
1.6 KiB
Makefile
Executable File
# Dependencies
|
|
dependencies:
|
|
docker-compose -f ./deployment/dependencies/docker-compose.yaml up -d
|
|
|
|
# Database
|
|
create-migration:
|
|
migrate create -ext sql -dir db/migrations -tz Local init
|
|
|
|
# --- for Macos
|
|
migrate:
|
|
migrate -database 'postgres://bank_admin:bank%40%2323%23%40_password@localhost:5424/bank_db?sslmode=disable' -path db/migrations up
|
|
migrate-rollback:
|
|
migrate -database 'postgres://bank_admin:bank%40%2323%23%40_password@localhost:5424/bank_db?sslmode=disable' -path db/migrations down
|
|
seed:
|
|
docker exec -i main-db psql -U bank_admin -d bank_db -f - < db/seed.sql
|
|
|
|
# ---- for linux
|
|
# migrate:
|
|
# migrate -database 'postgresql://bank_admin:bank%40%2323%23%40_password@localhost:5454/bank_db?sslmode=disable' -path db/migrations up
|
|
# migrate-rollback:
|
|
# migrate -database 'postgresql://bank_admin:bank%40%2323%23%40_password@localhost:5454/bank_db?sslmode=disable' -path db/migrations down
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Deploy: build + upload only (PM2-ni serwerde özüň restart et)
|
|
# ---------------------------------------------------------------------------
|
|
DEPLOY_HOST ?= ubuntu@216.250.10.141
|
|
DEPLOY_DIR ?= /home/ubuntu
|
|
BINARY ?= myapp
|
|
|
|
.PHONY: build-linux deploy swagger
|
|
|
|
swagger:
|
|
swag init -g app.go
|
|
|
|
build-linux:
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o $(BINARY) ./app.go
|
|
|
|
deploy: build-linux
|
|
ssh $(DEPLOY_HOST) 'mkdir -p $(DEPLOY_DIR)'
|
|
scp ./$(BINARY) $(DEPLOY_HOST):$(DEPLOY_DIR)/$(BINARY).new
|
|
ssh $(DEPLOY_HOST) 'cd $(DEPLOY_DIR) && chmod +x $(BINARY).new && mv $(BINARY).new $(BINARY)'
|