-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
118 lines (84 loc) · 2.95 KB
/
makefile
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
################# TODO: CONSTANTS #################
#* GET FILE ENV
include .env
export $(shell sed 's/=.*//' .env)
# * FILE RUN GO
GO_SERVER_PRO := ./cmd/server/main.go
GO_SERVER_DEV:= ./fsnotify.go
GO_SERVER_CRON := ./cmd/cronjob/main.go
GO_CONSUMER := ./cmd/queue/main.go
# * DOCKER COMPOSE
DOCKER_COMPOSE_DEV := docker-compose.dev.yml
DOCKER_COMPOSE_PRO := docker-compose.pro.yml
# * DOCKER HUB
SERVER_IMAGE_NAME := nguyentientai/go-secure-auth-pro:lastest
CRON_IMAGE_NAME := nguyentientai/go_cronjob_auth:lastest
QUEUE_IMAGE_NAME := nguyentientai/go_message_queue_auth:lastest
# * DOCKER FILE
DOCKER_FILE_PATH := ./third_party/docker/go/Dockerfile
DOCKER_FILE_CRON_PATH := ./third_party/docker/go/Dockerfile-cron
DOCKER_FILE_QUEUE_PATH := ./third_party/docker/go/Dockerfile-queue
#* DOCKER CONTAINER
CONTAINER_SERVICE_AUTH := service_auth
CONTAINER_SERVICE_CRON := service_cron
CONTAINER_SERVICE_QUEUE := service_queue
# * FOLDER
SWAGGER_DIR=./docs/swagger
################# TODO: GO #################
start:
go run $(GO_SERVER_PRO)
dev:
go run $(GO_SERVER_DEV)
air:
air
cron:
go run $(GO_SERVER_CRON)
consumer:
go run $(GO_CONSUMER)
################# TODO: DOCKER #################
build-pro:
docker-compose -f $(DOCKER_COMPOSE_PRO) up -d --build
down-pro:
docker-compose -f $(DOCKER_COMPOSE_PRO) down
build-dev:
docker-compose -f $(DOCKER_COMPOSE_DEV) up -d --build
down-dev:
docker-compose -f $(DOCKER_COMPOSE_DEV) down
update-server:
docker-compose -f $(DOCKER_COMPOSE_PRO) pull $(CONTAINER_SERVICE_AUTH)
docker-compose -f $(DOCKER_COMPOSE_PRO) up -d --no-deps $(CONTAINER_SERVICE_AUTH)
update-cron:
docker-compose -f $(DOCKER_COMPOSE_PRO) pull $(CONTAINER_SERVICE_QUEUE)
docker-compose -f $(DOCKER_COMPOSE_PRO) up -d --no-deps $(CONTAINER_SERVICE_QUEUE)
update-image: update-server update-cron
@echo "Both server and cron images updated successfully."
################# TODO: DOCKER HUB #################
# Build and tag the server image
server-image-tag:
docker build -t $(SERVER_IMAGE_NAME) -f $(DOCKER_FILE_PATH) .
# Build and tag the cron image
cron-image-tag:
docker build -t $(CRON_IMAGE_NAME) -f $(DOCKER_FILE_CRON_PATH) .
# Build and tag the cron image
queue-image-tag:
docker build -t $(QUEUE_IMAGE_NAME) -f $(DOCKER_FILE_QUEUE_PATH) .
# Push the server image to the registry
push-server: server-image-tag
docker push $(SERVER_IMAGE_NAME)
# Push the cron image to the registry
push-cron: cron-image-tag
docker push $(CRON_IMAGE_NAME)
# Push the cron image to the registry
push-queue: queue-image-tag
docker push $(QUEUE_IMAGE_NAME)
# Combined target to build and push both images
build-and-push-all: push-server push-cron
@echo "Both server and cron images have been built and pushed successfully."
################# TODO: SQLC #################
# Generate SQLC code
sqlc:
sqlc generate
# Generate Swagger documentation
swagger:
@echo "Generating Swagger documentation..."
swag init --parseDependency -g $(GO_SERVER_PRO) -o $(SWAGGER_DIR)