-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
144 lines (105 loc) · 3.75 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
## template Makefile:
## service example
#:
SHELL = /bin/sh
CFG ?= .env
PRG ?= $(shell basename $$PWD)
# -----------------------------------------------------------------------------
# Docker image config
#- App name
APP_NAME ?= $(PRG)
#- Docker-compose project name (container name prefix)
PROJECT_NAME ?= $(PRG)
# Hardcoded in docker-compose.yml service name
DC_SERVICE ?= app
#- Docker image name
IMAGE ?= $(DOCKER_IMAGE)
#- Docker image tag
IMAGE_VER ?= latest
# -----------------------------------------------------------------------------
# App config
#- Docker container addr:port
LISTEN ?= :8080
#- Public GRPC service addr:port
LISTEN_GRPC ?= :8081
#- Auth service type
AS_TYPE ?= gitea
#- Auth service URL
AS_HOST ?= https://git.dev.test
#- Auth service org
AS_TEAM ?= dcape
#- Auth service client_id
AS_CLIENT_ID ?= you_should_get_id_from_as
#- Auth service client key
AS_CLIENT_KEY ?= you_should_get_key_from_as
#- Auth service cookie sign key
AS_COOKIE_SIGN_KEY ?= $(shell < /dev/urandom tr -dc A-Za-z0-9 | head -c32; echo)
#- Auth service cookie crypt key
AS_COOKIE_CRYPT_KEY ?= $(shell < /dev/urandom tr -dc A-Za-z0-9 | head -c32; echo)
# used in URL generation
ifeq ($(USE_TLS),false)
#- app url prefix
HTTP_PROTO ?= http
else
HTTP_PROTO ?= https
endif
# ------------------------------------------------------------------------------
-include $(CFG).bak
-include $(CFG)
export
include Makefile.golang
# Find and include DCAPE/apps/drone/dcape-app/Makefile
DCAPE_COMPOSE ?= dcape-compose
DCAPE_ROOT ?= $(shell docker inspect -f "{{.Config.Labels.dcape_root}}" $(DCAPE_COMPOSE))
ifeq ($(shell test -e $(DCAPE_ROOT)/Makefile.app && echo -n yes),yes)
include $(DCAPE_ROOT)/Makefile.app
endif
.PHONY: buildall dist clean docker docker-multi use-own-hub godoc ghcr
# ------------------------------------------------------------------------------
# GRPC testing
GRPC_HOST ?= grpc.showonce.dev.test:443
grpc-test-list:
docker run --rm -v /etc/ssl/certs:/etc/ssl/certs -t fullstorydev/grpcurl $(GRPC_HOST) list
grpc-test-desc:
docker run --rm -v /etc/ssl/certs:/etc/ssl/certs -t fullstorydev/grpcurl \
$(GRPC_HOST) describe api.showonce.v1.PublicService
ID ?= 01H6DWS3VFV0YXEG0B25BSQ0R9
grpc-test-data:
docker run --rm -v /etc/ssl/certs:/etc/ssl/certs -t fullstorydev/grpcurl \
-d '{"id": "$(ID)"}' \
$(GRPC_HOST) api.showonce.v1.PublicService.GetMetadata
# ------------------------------------------------------------------------------
## Docker build operations
#:
# build docker image directly
docker: $(PRG)
docker build -t $(PRG) .
ALLARCH_DOCKER ?= "linux/amd64,linux/arm/v7,linux/arm64"
# build multiarch docker images via buildx
docker-multi:
time docker buildx build --platform $(ALLARCH_DOCKER) -t $(DOCKER_IMAGE):$(APP_VERSION) --push .
OWN_HUB ?= it.elfire.ru
buildkit.toml:
@echo [registry."$(OWN_HUB)"] > $@
@echo ca=["/etc/docker/certs.d/$(OWN_HUB)/ca.crt"] >> $@
use-own-hub: buildkit.toml
@docker buildx create --use --config $<
# ------------------------------------------------------------------------------
## Other
#:
## update docs at pkg.go.dev
godoc:
vf=$(APP_VERSION) ; v=$${vf%%-*} ; echo "Update for $$v..." ; \
curl 'https://proxy.golang.org/$(GODOC_REPO)/@v/'$$v'.info'
## update latest docker image tag at ghcr.io
ghcr:
v=$(APP_VERSION) ; echo "Update for $$v..." ; \
docker pull $(DOCKER_IMAGE):$$v && \
docker tag $(DOCKER_IMAGE):$$v $(DOCKER_IMAGE):latest && \
docker push $(DOCKER_IMAGE):latest
# ------------------------------------------------------------------------------
# Load AUTH_TOKEN
-include $(DCAPE_ROOT)/var/oauth2-token
# create OAuth application credentials
oauth2-create:
$(MAKE) -s oauth2-app-create HOST=$(AS_HOST) URL=/login PREFIX=AS