-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (57 loc) · 1.74 KB
/
Makefile
File metadata and controls
70 lines (57 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Add this at the top of your Makefile
ifneq (,$(wildcard .env))
include .env
export
endif
.PHONY: all build run test clean docker swagger mock lint migrate-create
# Variables
APP_NAME=echo-starter
MAIN_PATH=cmd/main.go
BUILD_DIR=build
DOCKER_IMAGE=$(APP_NAME)
MIGRATION_PATH=internal/db/migration
MIGRATE_TZ ?= UTC
DATABASE_URL = postgres://$(DB_USER):$(DB_PASSWORD)@$(DB_HOST):$(DB_PORT)/$(DB_NAME)?sslmode=$(DB_SSL_MODE)
build:
@echo "Building $(APP_NAME)..."
@go build -o $(BUILD_DIR)/$(APP_NAME) $(MAIN_PATH)
run:
@air
test:
@echo "Running tests for $(APP_NAME)..."
@go test -v ./...
clean:
@echo "Cleaning up..."
@rm -rf $(BUILD_DIR)
@rm -rf tmp
docker:
@echo "Building Docker image..."
@docker build -t $(DOCKER_IMAGE) .
@echo "Running Docker container..."
@docker run -p 1323:1323 $(DOCKER_IMAGE)
generate-docs:
@echo "Generating Swagger docs..."
@swag init -g $(MAIN_PATH)
@swag fmt
mock:
@echo "Generating mocks..."
@mockgen -source=internal/db/sqlc/query.go -destination=internal/db/sqlc/mock/query.go -package=mock
lint:
@echo "Running lint..."
@golangci-lint run
setup-dev:
@echo "Setting up development environment..."
@go install github.com/conventionalcommit/commitlint@latest
@brew install dbmate
# Decrypt (using git-crypt) the .env.staging.gpg and run dbmate command
# - gpg -d .env.staging.gpg > .env.staging
# - dbmate --env-file ".env.staging" (dbmate command e.g. up, down, etc.)
# - rm .env.staging after use
dbmate-staging:
@gpg -d .env.staging.gpg > .env.staging
@dbmate --env-file ".env.staging" $(filter-out $@,$(MAKECMDGOALS))
@rm .env.staging
dbmate-production:
@gpg -d .env.production.gpg > .env.production
@dbmate --env-file ".env.production" $(filter-out $@,$(MAKECMDGOALS))
@rm .env.production