generated from cisco-ospo/oss-template
-
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.
- Loading branch information
Showing
10 changed files
with
131 additions
and
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,26 @@ | ||
default: all | ||
GOFLAGS=-ldflags=-w -ldflags=-s | ||
SYNTEST_PLUGIN_SUBDIRS = $(notdir $(wildcard ./agent/plugins/syntests/*)) | ||
|
||
LOCAL_BUILD_PATH=./bin | ||
|
||
## Proto | ||
build-go-proto: | ||
@echo Building Golang proto files... | ||
protoc --go_out=plugins=grpc:common/proto/ common/proto/syntest.proto --proto_path=common/proto/ | ||
|
||
## Agent | ||
build-go-syntest-plugins: | ||
@echo "Building Go syntest plugins" | ||
cd agent && \ | ||
for dir in $(SYNTEST_PLUGIN_SUBDIRS); do \ | ||
echo "Building plugin: $$dir" && \ | ||
CGO_ENABLED=0 go build $(GOFLAGS) -o $(LOCAL_BUILD_PATH)/plugins/test-$$dir ./plugins/syntests/$$dir/ && \ | ||
echo "$$dir compiled!" || { echo "$$dir failed!"; exit 1; }; \ | ||
done | ||
|
||
build-agent-only: | ||
@echo "Building agent" | ||
cd agent && CGO_ENABLED=0 go build $(GOFLAGS) -o $(LOCAL_BUILD_PATH)/agent . | ||
|
||
.PHONY: build-agent | ||
build-agent: build-agent-only build-go-syntest-plugins | ||
default: docker-all | ||
|
||
docker-agent: | ||
@echo "Building agent container image" | ||
cd agent && podman build -f Dockerfile -t synheart-agent:dev_latest .. | ||
|
||
## Rest Api | ||
build-restapi: | ||
@echo "Building restapi binary" | ||
cd restapi && CGO_ENABLED=0 go build $(GOFLAGS) -o $(LOCAL_BUILD_PATH)/restapi . | ||
cd agent && podman build -f Dockerfile-NoPlugins -t synheart-agent:dev-latest-no-plugins .. | ||
cd agent && podman build -f Dockerfile -t synheart-agent:dev-latest .. | ||
|
||
.PHONY: docker-restapi | ||
docker-restapi: | ||
@echo "Building restapi container image" | ||
cd restapi && podman build -f Dockerfile -t synheart-restapi:dev_latest .. | ||
cd restapi && podman build -f Dockerfile -t synheart-restapi:dev-latest .. | ||
|
||
## Controller | ||
.PHONY: docker-controller | ||
docker-controller: | ||
@echo "Building controller container image" | ||
cd controller && podman build -f Dockerfile -t synheart-controller:dev_latest .. | ||
cd controller && podman build -f Dockerfile -t synheart-controller:dev-latest .. | ||
|
||
.PHONY : docker-all | ||
docker-all: docker-agent docker-restapi docker-controller | ||
|
||
#.PHONY : test | ||
#test: build-dummy-test-plugins build-syn-heart | ||
# go test -race -v synthetic-heart/agent | ||
# go test -race -v synthetic-heart/broadcaster | ||
|
||
|
||
## SDK - Creating new syntest plugin | ||
.PHONY : new-go-test | ||
new-go-test: | ||
@echo Creating Directory plugins/syntests/$(name) | ||
mkdir agent/plugins/syntests/$(name) | ||
|
||
@echo Creating file plugins/syntests/$(name)/$(name).go | ||
cp agent/plugins/templates/go/test.tpl.go plugins/syntests/$(name)/$(name).go | ||
|
||
sed -i .backup s/{{TestName}}/$(call capitalize,$(name))/g plugins/syntests/$(name)/$(name).go | ||
rm agent/plugins/syntests/$(name)/$(name).go.backup | ||
|
||
|
||
.PHONY : clean | ||
clean: | ||
rm -rf agent/bin | ||
rm -rf controller/bin | ||
rm -rf restapi/bin | ||
|
||
define capitalize | ||
$(shell echo $(1) | awk '{$$1=toupper(substr($$1,0,1))substr($$1,2); print $$0}') | ||
endef | ||
rm -rf restapi/bin |
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,56 @@ | ||
############################ | ||
# STEP 1 build the image for creating the executable | ||
############################ | ||
FROM docker.io/library/golang:1.22-alpine3.19 as builder | ||
|
||
# Install git + SSL ca certificates + make | ||
RUN apk update && apk upgrade && apk add --no-cache git ca-certificates make unzip g++ && update-ca-certificates && apk --no-cache add openssl wget && rm -rf /var/cache/apk/* | ||
|
||
# Create appuser | ||
RUN adduser -D -g '' appuser | ||
|
||
# Install protoc | ||
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.20.1/protoc-3.20.1-linux-x86_64.zip | ||
RUN unzip protoc-3.20.1-linux-x86_64.zip | ||
RUN cp ./bin/protoc /usr/local/bin/protoc | ||
RUN cp -a ./include/. /usr/local/include/ | ||
|
||
# Install GRPC golang-plugin for protoc | ||
RUN go install github.com/golang/protobuf/[email protected] | ||
|
||
WORKDIR /app | ||
|
||
COPY agent/go.mod agent/. | ||
COPY agent/go.sum agent/. | ||
COPY common/go.mod common/. | ||
COPY common/go.sum common/. | ||
RUN cd agent && go mod download | ||
|
||
COPY . . | ||
|
||
# Build the binary | ||
RUN mkdir -p /app/synthetic-heart/ | ||
RUN touch /app/synthetic-heart/.emptyfile | ||
|
||
# Compile the binary | ||
RUN cd agent/ && make build-agent-only | ||
|
||
RUN mv agent/bin/* /app/synthetic-heart | ||
RUN mkdir /app/synthetic-heart/plugins | ||
|
||
############################ | ||
# STEP 2 build a small image with only the executable | ||
############################ | ||
FROM docker.io/library/alpine:3.19 | ||
|
||
# Copy our static executables | ||
COPY --from=builder /app/synthetic-heart /app/synthetic-heart | ||
|
||
# Create a /tmp/ diretctory (required for go plugin for Unix Domain Socket) | ||
COPY --from=builder /app/synthetic-heart/.emptyfile /tmp/.emptyfile | ||
|
||
WORKDIR /app/synthetic-heart | ||
|
||
# Run the hello binary. | ||
ENTRYPOINT ["./agent"] | ||
|
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
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,8 +1,24 @@ | ||
export TAG=$(date +%s) | ||
podman tag localhost/synheart-controller:dev_latest bakshi41c/synheart-controller:$TAG | ||
podman tag localhost/synheart-restapi:dev_latest bakshi41c/synheart-restapi:$TAG | ||
podman tag localhost/synheart-agent:dev_latest bakshi41c/synheart-agent:$TAG | ||
echo $1 | ||
export TAG=$1 | ||
|
||
podman tag localhost/synheart-controller:dev-latest bakshi41c/synheart-controller:$TAG | ||
podman tag localhost/synheart-restapi:dev-latest bakshi41c/synheart-restapi:$TAG | ||
podman tag localhost/synheart-agent:dev-latest bakshi41c/synheart-agent:$TAG | ||
podman tag localhost/synheart-agent:dev-latest-no-plugins bakshi41c/synheart-agent:$TAG-no-plugins | ||
|
||
podman tag localhost/synheart-controller:dev-latest containers.cisco.com/synthetic-heart/controller:$TAG | ||
podman tag localhost/synheart-restapi:dev-latest containers.cisco.com/synthetic-heart/restapi:$TAG | ||
podman tag localhost/synheart-agent:dev-latest containers.cisco.com/synthetic-heart/agent:$TAG | ||
podman tag localhost/synheart-agent:dev-latest-no-plugins containers.cisco.com/synthetic-heart/agent:$TAG-no-plugins | ||
|
||
podman push bakshi41c/synheart-controller:$TAG | ||
podman push bakshi41c/synheart-restapi:$TAG | ||
podman push bakshi41c/synheart-agent:$TAG | ||
echo $TAG | ||
podman push bakshi41c/synheart-agent:$TAG-no-plugins | ||
|
||
podman push containers.cisco.com/synthetic-heart/controller:$TAG | ||
podman push containers.cisco.com/synthetic-heart/restapi:$TAG | ||
podman push containers.cisco.com/synthetic-heart/agent:$TAG | ||
podman push containers.cisco.com/synthetic-heart/agent:$TAG-no-plugins | ||
|
||
echo $1 |
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,7 @@ | ||
GOFLAGS=-ldflags=-w -ldflags=-s | ||
LOCAL_BUILD_PATH=./bin | ||
|
||
## Rest Api | ||
build-restapi: | ||
@echo "Building restapi binary" | ||
CGO_ENABLED=0 go build $(GOFLAGS) -o $(LOCAL_BUILD_PATH)/restapi . |