Skip to content

Commit

Permalink
ci: update build pattern
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin O'Donnell <[email protected]>
  • Loading branch information
scealiontach committed Jul 8, 2021
1 parent 57bbcdd commit 75c508c
Show file tree
Hide file tree
Showing 5 changed files with 244 additions and 191 deletions.
13 changes: 2 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
FROM golang:1.16-alpine as builder
RUN apk update && \
apk upgrade && \
apk add \
bash \
gcc
COPY . /tmp/catenasys/sxtctl
WORKDIR /tmp/catenasys/sxtctl
RUN bash ./scripts/build

FROM scratch
WORKDIR /
COPY --from=builder /tmp/catenasys/sxtctl/target /target

COPY ./target /target
ENTRYPOINT ["/target/sxtctl-linux-amd64"]
9 changes: 6 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,12 @@ pipeline {
expression { env.BRANCH_NAME == "master" }
}
steps {
sh '''
make clean publish
'''
withCredentials([string(credentialsId: 'btp-build-github-pat',
variable: 'GITHUB_TOKEN')]) {
sh '''
make clean publish
'''
}
}
}
}
Expand Down
30 changes: 15 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
MAKEFILE_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
include $(MAKEFILE_DIR)/standard_defs.mk

clean: clean_go
clean: clean_build_go

distclean: clean_docker

build: $(MARKERS)/build_docker
build: $(MARKERS)/build_go $(MARKERS)/build_docker

analyze: analyze_fossa
test: $(MARKERS)/test_go

.PHONY: build_dev
build_dev:
(cd ./cmd/sxtctl && go build .)
analyze: analyze_go analyze_fossa

$(MARKERS)/build_go: $(MARKERS)/build_toolchain_docker
$(TOOL) -w /project/cmd/sxtctl $(TOOLCHAIN_IMAGE) go build
publish: gh-create-draft-release
if [ "$(RELEASABLE)" = "yes" ]; then \
$(GH_RELEASE) upload $(VERSION) target/* ; \
fi

.PHONY: clean_go
clean_go: $(MARKERS)/build_toolchain_docker
$(TOOL) $(TOOLCHAIN_IMAGE) go clean
.PHONY: clean_docker
clean_docker: clean_toolchain_docker
docker rmi -f sxtctl:$(ISOLATION_ID)

$(MARKERS)/build_docker:
$(MARKERS)/build_docker: $(MARKERS)/build_go
docker build -t sxtctl:$(ISOLATION_ID) .
touch $@

.PHONY: clean_docker
clean_docker: clean_toolchain_docker
docker rmi -f sxtctl:$(ISOLATION_ID)
.PHONY: analyze_dive
analyze_dive:
$(DIVE_ANALYZE) sxtctl:$(ISOLATION_ID)
2 changes: 1 addition & 1 deletion scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export CGO_ENABLED=0
export GO111MODULE=on
rm -rf "$TARGETDIR"
mkdir -p "$TARGETDIR"
for ARCH in "darwin-amd64" "darwin-arm64" "linux-amd64" "windows-amd64"; do
for ARCH in "darwin-amd64" "linux-arm64" "darwin-arm64" "linux-amd64" "windows-amd64"; do
echo "building sxtctl-$ARCH"
IFS='-' read -r -a arArch <<<$ARCH
export GOOS=${arArch[0]}
Expand Down
Loading

0 comments on commit 75c508c

Please sign in to comment.