-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from chensheng0/master
update to baetyl v2.0.0
- Loading branch information
Showing
28 changed files
with
1,225 additions
and
1,209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: image-develop | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
image: | ||
name: docker build images | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install deps | ||
run: sudo apt update -y && sudo apt install -y qemu qemu-user-static | ||
- name: Install Docker CE for buildx | ||
run: | | ||
sudo apt update | ||
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | ||
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | ||
sudo apt update | ||
sudo apt install docker-ce | ||
docker -v | ||
- name: Checkout code | ||
uses: actions/checkout@v1 | ||
- name: docker login | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_REGISTRY_ID }} -p ${{ secrets.DOCKER_REGISTRY_PASS }} | ||
- name: build and publish image | ||
run: | | ||
cd baetyl-remote-object && make image PLATFORMS=all XFLAGS='--push --cache-to=type=local,dest=/tmp/main' REGISTRY=baetyltechtest/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: image-release | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
image: | ||
name: docker build images | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install deps | ||
run: sudo apt update -y && sudo apt install -y qemu qemu-user-static | ||
- name: Install Docker CE for buildx | ||
run: | | ||
sudo apt update | ||
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | ||
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | ||
sudo apt update | ||
sudo apt install docker-ce | ||
docker -v | ||
- name: Checkout code | ||
uses: actions/checkout@v1 | ||
- name: docker login | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_REGISTRY_ID }} -p ${{ secrets.DOCKER_REGISTRY_PASS }} | ||
- name: build and publish image | ||
run: | | ||
cd baetyl-remote-object && make image PLATFORMS=all XFLAGS='--push --cache-to=type=local,dest=/tmp/main' REGISTRY=baetyltech/ | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# Code generated by github.com/baetyl/baetyl/sdk/baetyl-go/generate.go. DO NOT EDIT. | ||
# source: github.com/baetyl/baetyl/sdk/baetyl-go/templates/Dockerfile-go | ||
FROM --platform=$TARGETPLATFORM golang:1.13.5-stretch as devel | ||
ARG BUILD_ARGS | ||
COPY / /go/src/ | ||
RUN cd /go/src/baetyl-remote-object && make build-local BUILD_ARGS=$BUILD_ARGS | ||
|
||
FROM --platform=$TARGETPLATFORM busybox | ||
ARG TARGETPLATFORM | ||
ARG MODULE=baetyl-remote-object | ||
COPY $TARGETPLATFORM/$MODULE/*.pem /etc/ssl/certs/ | ||
COPY $TARGETPLATFORM/$MODULE/bin/$MODULE /bin/ | ||
COPY --from=devel /go/src/baetyl-remote-object/pem/*.pem /etc/ssl/certs/ | ||
COPY --from=devel /go/src/baetyl-remote-object/baetyl-remote-object /bin/ | ||
ENTRYPOINT ["baetyl-remote-object"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM busybox | ||
COPY baetyl-remote-object /bin/ | ||
ENTRYPOINT ["baetyl-remote-object"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,97 @@ | ||
# Code generated by github.com/baetyl/baetyl/sdk/baetyl-go/generate.go. DO NOT EDIT. | ||
# source: github.com/baetyl/baetyl/sdk/baetyl-go/templates/Makefile-go | ||
|
||
MODULE:=baetyl-remote-object | ||
MODULE:=remote-object | ||
BIN:=baetyl-$(MODULE) | ||
SRC_FILES:=$(shell find . -type f -name '*.go') | ||
PEM_FILES:=$(shell find pem -type f -name '*.pem' | sed 's/ /\\ /g') | ||
BIN_FILE:=baetyl-remote-object | ||
BIN_CMD=$(shell echo $(@:$(OUTPUT)/%/$(MODULE)/bin/$(BIN_FILE)=%) | sed 's:/v:/:g' | awk -F '/' '{print "CGO_ENABLED=0 GOOS="$$1" GOARCH="$$2" GOARM="$$3" go build"}') -o $@ ${GO_FLAGS} . | ||
COPY_DIR:=../output | ||
PLATFORM_ALL:=darwin/amd64 linux/amd64 linux/arm64 linux/386 linux/arm/v7 linux/arm/v6 linux/arm/v5 linux/ppc64le linux/s390x | ||
PLATFORM_ALL:=darwin/amd64 linux/amd64 linux/arm64 linux/arm/v7 | ||
|
||
export DOCKER_CLI_EXPERIMENTAL=enabled | ||
|
||
GIT_TAG:=$(shell git tag --contains HEAD) | ||
GIT_TAG:=$(shell git tag --contains HEAD|awk 'END {print}') | ||
GIT_REV:=git-$(shell git rev-parse --short HEAD) | ||
VERSION:=$(if $(GIT_TAG),$(GIT_TAG),$(GIT_REV)) | ||
GO_TEST_FLAGS?= | ||
GO_TEST_PKGS?=$(shell go list ./...) | ||
ifeq ($(findstring race,$(BUILD_ARGS)),race) | ||
VERSION:=$(VERSION)-race | ||
endif | ||
|
||
GO_OS:=$(shell go env GOOS) | ||
GO_ARCH:=$(shell go env GOARCH) | ||
GO_ARM:=$(shell go env GOARM) | ||
|
||
ifndef PLATFORMS | ||
GO_OS:=$(shell go env GOOS) | ||
GO_ARCH:=$(shell go env GOARCH) | ||
GO_ARM:=$(shell go env GOARM) | ||
PLATFORMS:=$(if $(GO_ARM),$(GO_OS)/$(GO_ARCH)/$(GO_ARM),$(GO_OS)/$(GO_ARCH)) | ||
ifeq ($(GO_OS),darwin) | ||
PLATFORMS+=linux/amd64 | ||
endif | ||
PLATFORMS:=$(if $(GO_ARM),$(GO_OS)/$(GO_ARCH)/$(GO_ARM),$(GO_OS)/$(GO_ARCH)) | ||
ifeq ($(GO_OS),darwin) | ||
PLATFORMS+=linux/amd64 | ||
endif | ||
else ifeq ($(PLATFORMS),all) | ||
override PLATFORMS:=$(PLATFORM_ALL) | ||
override PLATFORMS:=$(PLATFORM_ALL) | ||
endif | ||
|
||
REGISTRY?= | ||
XFLAGS?=--load | ||
XPLATFORMS:=$(shell echo $(filter-out darwin/amd64,$(PLATFORMS)) | sed 's: :,:g') | ||
|
||
YML_FILE=$(wildcard *.yml) | ||
GO := go | ||
GO_MOD := $(GO) mod | ||
GO_ENV := env GO111MODULE=on GOPROXY=https://goproxy.cn CGO_ENABLED=0 | ||
GO_FLAGS := $(BUILD_ARGS) -ldflags '-X "github.com/baetyl/baetyl-go/v2/utils.REVISION=$(GIT_REV)" -X "github.com/baetyl/baetyl-go/v2/utils.VERSION=$(VERSION)"' | ||
ifeq ($(findstring race,$(BUILD_ARGS)),race) | ||
GO_ENV := env GO111MODULE=on GOPROXY=https://goproxy.cn CGO_ENABLED=1 | ||
GO_FLAGS := $(BUILD_ARGS) -ldflags '-s -w -X "github.com/baetyl/baetyl-go/v2/utils.REVISION=$(GIT_REV)" -X "github.com/baetyl/baetyl-go/v2/utils.VERSION=$(VERSION)" -linkmode external -w -extldflags "-static"' | ||
override PLATFORMS:= $(filter-out linux/arm/v7,$(PLATFORMS)) | ||
endif | ||
GO_BUILD := $(GO_ENV) $(GO) build $(GO_FLAGS) | ||
GOTEST := $(GO) test | ||
GOPKGS := $$($(GO) list ./... | grep -vE "vendor") | ||
|
||
REGISTRY:= | ||
XFLAGS:=--load | ||
XPLATFORMS:=$(shell echo $(filter-out darwin/amd64,$(PLATFORMS)) | sed 's: :,:g') | ||
|
||
OUTPUT:=../output | ||
OUTPUT_MODS:=$(PLATFORMS:%=$(OUTPUT)/%/$(MODULE)) | ||
OUTPUT_BINS:=$(OUTPUT_MODS:%=%/bin/$(BIN_FILE)) | ||
OUTPUT_PKGS:=$(OUTPUT_MODS:%=%/$(MODULE)-$(VERSION).zip) # TODO: switch to tar | ||
OUTPUT :=output | ||
OUTPUT_DIRS:=$(PLATFORMS:%=$(OUTPUT)/%/$(BIN)) | ||
OUTPUT_BINS:=$(OUTPUT_DIRS:%=%/$(BIN)) | ||
PKG_PLATFORMS := $(shell echo $(PLATFORMS) | sed 's:/:-:g') | ||
OUTPUT_PKGS:=$(PKG_PLATFORMS:%=$(OUTPUT)/$(BIN)_%_$(VERSION).zip) | ||
|
||
.PHONY: all | ||
all: $(OUTPUT_BINS) $(OUTPUT_PKGS) | ||
all: build test | ||
|
||
.PHONY: build | ||
build: $(OUTPUT_BINS) | ||
|
||
$(OUTPUT_BINS): $(SRC_FILES) | ||
@echo "BUILD $@" | ||
@install -d -m 0755 $(dir $@) | ||
$(BIN_CMD) | ||
@mkdir -p $(dir $@) | ||
@cp program.yml $(dir $@) | ||
@$(shell echo $(@:$(OUTPUT)/%/$(BIN)/$(BIN)=%) | sed 's:/v:/:g' | awk -F '/' '{print "GOOS="$$1" GOARCH="$$2" GOARM="$$3""}') $(GO_BUILD) -o $@ . | ||
|
||
$(OUTPUT_PKGS): $(OUTPUT_BINS) $(YML_FILE) $(PEM_FILES) | ||
@echo "PACKAGE $@" | ||
@install -m 0755 $(YML_FILE) $(dir $@) | ||
@install -m 0755 $(PEM_FILES) $(dir $@) | ||
@cd $(dir $@) && zip -q -r $(notdir $@) bin $(YML_FILE) | ||
.PHONY: build-local | ||
build-local: $(SRC_FILES) | ||
@echo "BUILD $(BIN)" | ||
$(GO_BUILD) -o $(BIN) . | ||
@chmod +x $(BIN) | ||
|
||
.PHONY: image | ||
image: $(OUTPUT_BINS) | ||
image: | ||
@echo "BUILDX: $(REGISTRY)$(MODULE):$(VERSION)" | ||
@-docker buildx create --name baetyl | ||
@docker buildx use baetyl | ||
docker buildx build $(XFLAGS) --platform $(XPLATFORMS) -t $(REGISTRY)$(MODULE):$(VERSION) -f Dockerfile $(COPY_DIR) | ||
@docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | ||
docker buildx build $(XFLAGS) --platform $(XPLATFORMS) -t $(REGISTRY)$(MODULE):$(VERSION) --build-arg BUILD_ARGS=$(BUILD_ARGS) -f Dockerfile .. | ||
|
||
.PHONY: test | ||
test: fmt | ||
$(GOTEST) -race -short -covermode=atomic -coverprofile=coverage.txt $(GOPKGS) | ||
@go tool cover -func=coverage.txt | grep total | ||
|
||
.PHONY: rebuild | ||
rebuild: clean all | ||
.PHONY: fmt | ||
fmt: | ||
$(GO_MOD) tidy | ||
@go fmt ./... | ||
|
||
.PHONY: clean | ||
clean: | ||
@find $(OUTPUT) -type d -name $(MODULE) | xargs rm -rf | ||
@rm -rf $(OUTPUT) $(BIN) | ||
|
||
.PHONY: test | ||
test: | ||
@go test ${GO_TEST_FLAGS} -coverprofile=coverage.out ${GO_TEST_PKGS} | ||
@go tool cover -func=coverage.out | grep total | ||
@go tool cover -html=coverage.out -o coverage.html | ||
.PHONY: package | ||
package: build $(OUTPUT_PKGS) | ||
|
||
$(OUTPUT_PKGS): | ||
@echo "PACKAGE $@" | ||
@cd $(OUTPUT)/$(shell echo $(@:$(OUTPUT)/$(BIN)_%_$(VERSION).zip=%) | sed 's:-:/:g')/$(BIN) && zip -q -r $(notdir $@) $(BIN) program.yml |
Oops, something went wrong.