File tree Expand file tree Collapse file tree 2 files changed +27
-11
lines changed Expand file tree Collapse file tree 2 files changed +27
-11
lines changed Original file line number Diff line number Diff line change 1
- FROM golang:1.18-alpine as build
1
+ # ############################################
2
+ # Build
3
+ # ############################################
4
+ FROM --platform=$BUILDPLATFORM golang:1.18-alpine as build
2
5
3
6
RUN apk upgrade --no-cache --force
4
7
RUN apk add --update build-base make git
5
8
6
9
WORKDIR /go/src/github.com/webdevops/azure-auditor
7
10
11
+ # Dependencies
12
+ COPY go.mod go.sum .
13
+ RUN go mod download
14
+
8
15
# Compile
9
- COPY ./ /go/src/github.com/webdevops/azure-auditor
10
- RUN make dependencies
11
- # RUN make test
12
- RUN make build
13
- RUN ./azure-auditor --help
16
+ COPY . .
17
+ RUN make test
18
+ ARG TARGETOS TARGETARCH
19
+ RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build
14
20
15
21
# ############################################
16
- # FINAL IMAGE
22
+ # Test
17
23
# ############################################
18
- FROM gcr.io/distroless/static
24
+ FROM gcr.io/distroless/static as test
19
25
ENV LOG_JSON=1
20
26
COPY --from=build /go/src/github.com/webdevops/azure-auditor/azure-auditor /
21
27
COPY --from=build /go/src/github.com/webdevops/azure-auditor/templates/ /templates/
28
+ RUN ["/azure-auditor" , "--help" ]
29
+
30
+ # ############################################
31
+ # Final
32
+ # ############################################
33
+ FROM gcr.io/distroless/static
34
+ ENV LOG_JSON=1
35
+ COPY --from=test /azure-auditor /
36
+ COPY --from=test /go/src/github.com/webdevops/azure-auditor/templates/ /templates/
22
37
USER 1000:1000
23
38
ENTRYPOINT ["/azure-auditor" ]
Original file line number Diff line number Diff line change 1
1
PROJECT_NAME := $(shell basename $(CURDIR ) )
2
2
GIT_TAG := $(shell git describe --dirty --tags --always)
3
3
GIT_COMMIT := $(shell git rev-parse --short HEAD)
4
- LDFLAGS := -X "main.gitTag=$(GIT_TAG ) " -X "main.gitCommit=$(GIT_COMMIT ) " -linkmode external - extldflags "-static" -s -w
4
+ LDFLAGS := -X "main.gitTag=$(GIT_TAG ) " -X "main.gitCommit=$(GIT_COMMIT ) " -extldflags "-static" -s -w
5
5
6
6
FIRST_GOPATH := $(firstword $(subst :, ,$(shell go env GOPATH) ) )
7
7
GOLANGCI_LINT_BIN := $(FIRST_GOPATH ) /bin/golangci-lint
16
16
17
17
.PHONY : build
18
18
build :
19
- CGO_ENABLED=0 go build -a -ldflags ' $(LDFLAGS)' -o $(PROJECT_NAME ) .
19
+ GOOS= ${GOOS} GOARCH= ${GOARCH} CGO_ENABLED=0 go build -a -ldflags ' $(LDFLAGS)' -o $(PROJECT_NAME ) .
20
20
21
21
.PHONY : vendor
22
22
vendor :
@@ -29,7 +29,8 @@ image: build
29
29
docker build -t $(PROJECT_NAME ) :$(GIT_TAG ) .
30
30
31
31
build-push-development :
32
- docker build -t webdevops/$(PROJECT_NAME ) :development . && docker push webdevops/$(PROJECT_NAME ) :development
32
+ docker buildx create --use
33
+ docker buildx build -t webdevops/$(PROJECT_NAME ) :development --platform linux/amd64,linux/arm,linux/arm64 --push .
33
34
34
35
.PHONY : test
35
36
test :
You can’t perform that action at this time.
0 commit comments