-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
61 lines (53 loc) · 1.3 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
override APP_NAME=rmod-reg
override GO_VERSION=1.19
override DOCKER_IMAGE=resourcemod/rmod-registry
override DOCKER_TAG=current
GOOS?=$(shell go env GOOS || echo linux)
GOARCH?=$(shell go env GOARCH || echo amd64)
CGO_ENABLED?=0
ifeq (, $(shell which docker))
$(error "Binary docker not found in $(PATH)")
endif
.PHONY: all
all: cleanup vendor
.PHONY: cleanup
cleanup:
@rm ${PWD}/bin/${APP_NAME} || true
@rm -r ${PWD}/vendor || true
@rm -r ${PWD}/pkg/api/*
.PHONY: vendor
vendor:
@rm -r ${PWD}/vendor || true
@docker run --rm \
-v ${PWD}:/project \
-w /project \
golang:${GO_VERSION} \
go mod tidy
@docker run --rm \
-v ${PWD}:/project \
-w /project \
golang:${GO_VERSION} \
go mod vendor
.PHONY: build
build:
@rm ${PWD}/bin/${APP_NAME} || true
@docker run --rm \
-v ${PWD}:/project \
-w /project \
-e GOOS=${GOOS} \
-e GOARCH=${GOARCH} \
-e CGO_ENABLED=${CGO_ENABLED} \
-e GO111MODULE=on \
golang:${GO_VERSION} \
go build \
-mod vendor \
-o /project/bin/${APP_NAME} \
-v /project/cmd/${APP_NAME}
.PHONY: generate-api
generate-api:
@go run github.com/ogen-go/ogen/cmd/ogen@latest --target pkg/api --clean api/openapi/spec.yml
.PHONY: docker-build
docker-build:
@docker build \
-f ${PWD}/build/docker/${APP_NAME}.Dockerfile \
-t ${DOCKER_IMAGE}:${DOCKER_TAG} .