-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathMakefile
More file actions
56 lines (45 loc) · 1.31 KB
/
Makefile
File metadata and controls
56 lines (45 loc) · 1.31 KB
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
CWD := $(shell pwd)
GO_VERSION := $(shell grep '^go ' go.mod | awk '{print $$2}')
IMAGE_NAME := yc-360-script-base:alpine
CONTAINER_NAME := yc-360-script-base-alpine
.PHONY: _ alpine base shell build build-all clean
_:
echo "default"
alpine:
docker build --build-arg GO_VERSION=$(GO_VERSION) -f Dockerfile.base.alpine --target builder -t $(IMAGE_NAME) .
base: alpine
docker rm -f $(CONTAINER_NAME) || true
docker run --init -d -ti --rm \
--name $(CONTAINER_NAME) \
-v $(CWD):/opt/workspace/yc-360-script \
$(IMAGE_NAME)
shell:
docker exec -it $(CONTAINER_NAME) /bin/sh
build:
docker exec -it $(CONTAINER_NAME) /bin/sh -c \
"cd cmd/yc && \
go build -o yc -ldflags='-s -w' -buildvcs=false && \
mkdir -p ../../bin/ && \
mv yc ../../bin/"
# Multi-arch build (exports ONLY yc binary)
build-all:
rm -rf bin/linux
mkdir -p bin/linux/amd64 bin/linux/arm64
# linux/amd64
docker buildx build \
--build-arg GO_VERSION=$(GO_VERSION) \
--platform linux/amd64 \
-f Dockerfile.base.alpine \
--target export \
--output type=local,dest=bin/linux/amd64 \
.
# linux/arm64
docker buildx build \
--build-arg GO_VERSION=$(GO_VERSION) \
--platform linux/arm64 \
-f Dockerfile.base.alpine \
--target export \
--output type=local,dest=bin/linux/arm64 \
.
clean:
docker rm -f $(CONTAINER_NAME) || true