-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
52 lines (41 loc) · 981 Bytes
/
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
.PHONY: run build swagger docker up down clean
# export CGO_ENABLED=0
# export GOOS=linux
# export GOARCH=amd64
GO ?= GO111MODULE=on go
APP_NAME = exchange-diary
BIN_DIR = ./bin
BUILD_DIR = ./application/cmd
BUILD_FILE = $(addprefix $(BUILD_DIR)/, main.go)
# local run
run:
make swagger
$(GO) run $(BUILD_FILE)
# build binary
build:
$(GO) build -ldflags="-s -w" -o $(BIN_DIR)/$(APP_NAME) $(BUILD_FILE)
# generate swagger
swagger:
echo "Update swagger to /docs"
swag init -g ./application/cmd/main.go
docker:
make dbuild && make drun
# docker build
dbuild:
docker build \
-t $(APP_NAME):latest \
-f Dockerfile --no-cache .
# docker local run
drun:
docker run --rm -p 8080:8080 --name exchange-diary exchange-diary
# docker compose up
up:
docker compose up -d --build --remove-orphans
docker compose logs -f
# docker compose down
down:
docker compose down --rmi local
# rm binary
clean:
echo "remove bin exe"
rm -f $(addprefix $(BIN_DIR)/, $(APP_NAME))