Skip to content

Commit

Permalink
make changes to build and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
bhuvanessr committed May 28, 2020
1 parent 976e307 commit 23c1c21
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ jobs:
- hack/verify-gofmt.sh
- hack/verify-golint.sh
- hack/verify-govet.sh
- make fledged-amd64
- travis_wait 30 make BUILD_OUTPUT= install-buildx fledged-amd64 webhook-server-amd64
- make test
- $(go env GOPATH | awk 'BEGIN{FS=":"} {print $1}')/bin/goveralls -coverprofile=coverage.out -service=travis-ci
- stage: build_multiarch
script:
# BUILD_OUTPUT is left empty to indicate buildx to leave the built images in it's cache
- travis_wait 60 make GIT_BRANCH=${TRAVIS_BRANCH} BUILD_OUTPUT= release
- travis_wait 60 make BUILD_OUTPUT= release
- stage: build_release
script:
- docker login -u ${DOCKERHUB_USER} -p ${DOCKERHUB_PSWD}
Expand Down
32 changes: 6 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ ifndef OPERATORSDK_VERSION
OPERATORSDK_VERSION=v0.17.0
endif

ifndef GIT_BRANCH
GIT_BRANCH=master
endif

ifndef TARGET_PLATFORMS
TARGET_PLATFORMS=linux/amd64,linux/arm/v7,linux/arm64/v8
endif
Expand Down Expand Up @@ -114,32 +110,22 @@ clean-operator:
-docker image rm ${OPERATOR_IMAGE_REPO}:${RELEASE_VERSION}
-docker image rm `docker image ls -f dangling=true -q`

fledged-amd64: clean-fledged
CGO_ENABLED=0 go build -o build/fledged -ldflags '-s -w -extldflags "-static"' cmd/fledged/main.go && \
cd build && docker build -t ${FLEDGED_IMAGE_REPO}:${RELEASE_VERSION} -f Dockerfile.fledged_dev \
--build-arg ALPINE_VERSION=${ALPINE_VERSION} .

fledged-dev: fledged-amd64
docker push ${FLEDGED_IMAGE_REPO}:${RELEASE_VERSION}

webhook-server-amd64: clean-webhook-server
CGO_ENABLED=0 go build -o build/fledged-webhook-server -ldflags '-s -w -extldflags "-static"' cmd/webhook-server/main.go && \
cd build && docker build -t ${FLEDGED_WEBHOOK_SERVER_IMAGE_REPO}:${RELEASE_VERSION} -f Dockerfile.webhook_server_dev \
--build-arg ALPINE_VERSION=${ALPINE_VERSION} .

webhook-server-dev: webhook-server-amd64
docker push ${FLEDGED_WEBHOOK_SERVER_IMAGE_REPO}:${RELEASE_VERSION}

fledged-image: clean-fledged
cd build && docker buildx build --platform=${TARGET_PLATFORMS} -t ${FLEDGED_IMAGE_REPO}:${RELEASE_VERSION} \
-f Dockerfile.fledged ${HTTP_PROXY_CONFIG} ${HTTPS_PROXY_CONFIG} --build-arg GIT_BRANCH=${GIT_BRANCH} \
--build-arg GOLANG_VERSION=${GOLANG_VERSION} --build-arg ALPINE_VERSION=${ALPINE_VERSION} --progress=plain ${BUILD_OUTPUT} .

fledged-amd64: TARGET_PLATFORMS=linux/amd64
fledged-amd64: fledged-image

webhook-server-image: clean-webhook-server
cd build && docker buildx build --platform=${TARGET_PLATFORMS} -t ${FLEDGED_WEBHOOK_SERVER_IMAGE_REPO}:${RELEASE_VERSION} \
-f Dockerfile.webhook_server ${HTTP_PROXY_CONFIG} ${HTTPS_PROXY_CONFIG} --build-arg GIT_BRANCH=${GIT_BRANCH} \
--build-arg GOLANG_VERSION=${GOLANG_VERSION} --build-arg ALPINE_VERSION=${ALPINE_VERSION} --progress=plain ${BUILD_OUTPUT} .

webhook-server-amd64: TARGET_PLATFORMS=linux/amd64
webhook-server-amd64: webhook-server-image

client-image: clean-client
cd build && docker buildx build --platform=${TARGET_PLATFORMS} -t ${FLEDGED_DOCKER_CLIENT_IMAGE_REPO}:${RELEASE_VERSION} \
-f Dockerfile.docker_client ${HTTP_PROXY_CONFIG} ${HTTPS_PROXY_CONFIG} \
Expand All @@ -151,12 +137,6 @@ operator-image: clean-operator
docker buildx build --platform=${OPERATOR_TARGET_PLATFORMS} -t ${OPERATOR_IMAGE_REPO}:${RELEASE_VERSION} \
-f ./build/Dockerfile --build-arg OPERATORSDK_VERSION=${OPERATORSDK_VERSION} --progress=plain ${BUILD_OUTPUT} .

push-images:
-docker push ${FLEDGED_IMAGE_REPO}:${RELEASE_VERSION}
-docker push ${FLEDGED_WEBHOOK_SERVER_IMAGE_REPO}:${RELEASE_VERSION}
-docker push ${FLEDGED_DOCKER_CLIENT_IMAGE_REPO}:${RELEASE_VERSION}
-docker push ${OPERATOR_IMAGE_REPO}:${RELEASE_VERSION}

release: install-buildx fledged-image webhook-server-image client-image operator-image

install-buildx:
Expand Down
9 changes: 4 additions & 5 deletions build/Dockerfile.fledged
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ ARG ALPINE_VERSION

FROM golang:$GOLANG_VERSION AS builder
LABEL stage=builder
ARG GIT_BRANCH
RUN mkdir -p /go/src/github.com/senthilrch && \
git clone --depth=1 --single-branch --branch=$GIT_BRANCH https://github.com/senthilrch/kube-fledged.git /go/src/github.com/senthilrch/kube-fledged && \
cd /go/src/github.com/senthilrch/kube-fledged && \
CGO_ENABLED=0 go build -o build/fledged -ldflags '-s -w -extldflags "-static"' cmd/fledged/main.go
RUN mkdir -p /go/src/github.com/senthilrch/kube-fledged
COPY . /go/src/github.com/senthilrch/kube-fledged
WORKDIR /go/src/github.com/senthilrch/kube-fledged
RUN CGO_ENABLED=0 go build -o build/fledged -ldflags '-s -w -extldflags "-static"' cmd/fledged/main.go

FROM alpine:$ALPINE_VERSION
LABEL maintainer="senthilrch <senthilrch@gmail.com>"
Expand Down
9 changes: 4 additions & 5 deletions build/Dockerfile.webhook_server
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ ARG ALPINE_VERSION

FROM golang:$GOLANG_VERSION AS builder
LABEL stage=builder
ARG GIT_BRANCH
RUN mkdir -p /go/src/github.com/senthilrch && \
git clone --depth=1 --single-branch --branch=$GIT_BRANCH https://github.com/senthilrch/kube-fledged.git /go/src/github.com/senthilrch/kube-fledged && \
cd /go/src/github.com/senthilrch/kube-fledged && \
CGO_ENABLED=0 go build -o build/fledged-webhook-server -ldflags '-s -w -extldflags "-static"' cmd/webhook-server/main.go
RUN mkdir -p /go/src/github.com/senthilrch/kube-fledged
COPY . /go/src/github.com/senthilrch/kube-fledged
WORKDIR /go/src/github.com/senthilrch/kube-fledged
RUN CGO_ENABLED=0 go build -o build/fledged-webhook-server -ldflags '-s -w -extldflags "-static"' cmd/fledged-webhook-server/main.go

FROM alpine:$ALPINE_VERSION
LABEL maintainer="senthilrch <senthilrch@gmail.com>"
Expand Down

0 comments on commit 23c1c21

Please sign in to comment.