Merge pull request '[DO-169] add makefile and change golang version' (#1) from feature/DO-169/add_build into master
Reviewed-on: https://git.avroid.tech/Tools/Addlicense/pulls/1
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
FROM golang:1.16 AS build
|
FROM golang:1.22 AS build
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|||||||
38
Makefile
Normal file
38
Makefile
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
.PHONY: all build push
|
||||||
|
|
||||||
|
APP=addlicense
|
||||||
|
GROUP=devops
|
||||||
|
REVISION=""
|
||||||
|
VERSION=1.1.1$(REVISION)
|
||||||
|
DOCKER_REGISTRY=harbor.avroid.tech
|
||||||
|
|
||||||
|
all:
|
||||||
|
@echo 'DEFAULT: '
|
||||||
|
@echo ' make build_image - Build docker image'
|
||||||
|
@echo ' make push_image - Push docker image to registry'
|
||||||
|
@echo ' make build - Build application'
|
||||||
|
@echo ' make archive - Add application to archive'
|
||||||
|
@echo ' make clean - Remove all builds'
|
||||||
|
|
||||||
|
build:
|
||||||
|
mkdir -p dist/{linux,windows,darwin}
|
||||||
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o dist/linux/addlicense
|
||||||
|
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o dist/darwin/addlicense
|
||||||
|
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o dist/windows/addlicense.exe
|
||||||
|
@echo "See 'addlicense' in dist directory"
|
||||||
|
|
||||||
|
archive:
|
||||||
|
zip dist/linux/addlicense_$(VERSION)_linux_amd64.zip -j dist/linux/addlicense
|
||||||
|
zip dist/darwin/addlicense_$(VERSION)_darwin_arm64.zip -j dist/darwin/addlicense
|
||||||
|
zip dist/windows/addlicense_$(VERSION)_windows_amd64.zip -j dist/windows/addlicense.exe
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf dist
|
||||||
|
|
||||||
|
build_image:
|
||||||
|
DOCKER_BUILDKIT=1 docker build --no-cache --platform linux/amd64 -t $(DOCKER_REGISTRY)/$(GROUP)/$(APP):$(VERSION) .
|
||||||
|
docker tag $(DOCKER_REGISTRY)/$(GROUP)/$(APP):$(VERSION) $(DOCKER_REGISTRY)/$(GROUP)/$(APP):latest
|
||||||
|
|
||||||
|
push_image:
|
||||||
|
docker push $(DOCKER_REGISTRY)/$(GROUP)/$(APP):$(VERSION)
|
||||||
|
docker push $(DOCKER_REGISTRY)/$(GROUP)/$(APP):latest
|
||||||
Reference in New Issue
Block a user