-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
51 lines (41 loc) · 1.15 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
GOLANG_VERSION := 1.23.2
ALPINE_VERSION := 3.20
DOCKER_REPO := michalsw
APPNAME := https-web-server
LOCAL_PORT ?= 8443
SERVER_PORT ?= 443
APP_PATH ?= /app
.DEFAULT_GOAL := help
.PHONY: run build docker-build docker-run docker-stop
help:
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ \
{ printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
run: ## Run app
SERVER_PORT=$(LOCAL_PORT) \
go run .
build: ## Build bin
CGO_ENABLED=0 \
go build \
-v \
-o $(APPNAME) .
docker-build: ## Build docker image
docker build \
--pull \
--platform linux/amd64 \
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
--build-arg ALPINE_VERSION="$(ALPINE_VERSION)" \
--build-arg APPNAME="$(APPNAME)" \
--build-arg APP_PATH="$(APP_PATH)" \
--tag="$(DOCKER_REPO)/$(APPNAME):latest" \
.
docker-run: ## Run docker
docker run --rm -d \
--pull always \
--env SERVER_PORT=$(SERVER_PORT) \
-v $(realpath certs):"$(APP_PATH)/certs" \
-p $(SERVER_PORT):$(SERVER_PORT) \
--name $(APPNAME) \
$(DOCKER_REPO)/$(APPNAME):latest && \
docker ps
docker-stop: ## Stop docker
docker stop $(APPNAME)