Skip to content

Commit

Permalink
Speed up CI builds (#583)
Browse files Browse the repository at this point in the history
* Compile go binaries outside from containers

* Avoid login if there are no credentials

* Build all go images in the same job

* Revert "Compile go binaries outside from containers"

This reverts commit 0f605ee.

* Revert change to build binaries outside of containers

* Remove unnecessary dep ensure

* Add missing cert

* Fix typo in definition

* Restore lint fixes
  • Loading branch information
andresmgot committed Sep 7, 2018
1 parent 95a73d2 commit 1af2906
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 61 deletions.
78 changes: 27 additions & 51 deletions .circleci/config.yml
Expand Up @@ -29,42 +29,24 @@ workflows:
<<: *build_always
- test_dashboard:
<<: *build_always
- build_chartrepo:
- build_go_images:
<<: *build_always
requires:
- test_go
- build_chartsvc:
<<: *build_always
requires:
- test_go
- build_chart_apprepository:
<<: *build_always
requires:
- test_go
- build_dashboard:
<<: *build_always
requires:
- test_dashboard
- build_tiller_proxy:
<<: *build_always
requires:
- test_go
- GKE_1_9:
<<: *build_on_master
requires:
- build_chartrepo
- build_chartsvc
- build_chart_apprepository
- test_go
- test_dashboard
- build_go_images
- build_dashboard
- build_tiller_proxy
- GKE_1_10:
<<: *build_on_master
requires:
- build_chartrepo
- build_chartsvc
- build_chart_apprepository
- test_go
- test_dashboard
- build_go_images
- build_dashboard
- build_tiller_proxy
- sync_chart:
<<: *build_on_master
requires:
Expand Down Expand Up @@ -100,20 +82,20 @@ exports: &exports
# Apart from using a DEV_TAG we use a different image ID to avoid polluting the tag
# history of the production tag
echo "export IMG_MODIFIER=-ci" >> $BASH_ENV
build_image: &build_image
working_directory: /go/src/github.com/kubeapps/kubeapps
docker:
- image: circleci/golang:1.9
build_images: &build_images
steps:
- setup_remote_docker
- checkout
- <<: *exports
- run: make IMG_MODIFIER="$IMG_MODIFIER" VERSION="${DEV_TAG}" ${IMAGE}
- run: |
if [[ -z "${CIRCLE_PULL_REQUEST}" && -n "${DOCKER_USERNAME}" && -n "${DOCKER_PASSWORD}" ]]; then
docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}"
docker push ${IMAGE}${IMG_MODIFIER}:${DEV_TAG}
fi
read -ra IMG_ARRAY <<< "$IMAGES"
for IMAGE in "${IMG_ARRAY[@]}"; do
make IMG_MODIFIER="$IMG_MODIFIER" VERSION="${DEV_TAG}" ${IMAGE}
if [[ -z "${CIRCLE_PULL_REQUEST}" && -n "${DOCKER_USERNAME}" && -n "${DOCKER_PASSWORD}" ]]; then
docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}"
docker push ${IMAGE}${IMG_MODIFIER}:${DEV_TAG}
fi
done
gke_test: &gke_test
docker:
- image: circleci/golang:1.9
Expand Down Expand Up @@ -172,26 +154,20 @@ jobs:
- run: yarn install --cwd=dashboard --frozen-lockfile
- run: yarn --cwd=dashboard run lint
- run: yarn --cwd=dashboard run test --maxWorkers=4 --coverage
build_chartrepo:
<<: *build_image
environment:
- IMAGE=kubeapps/chart-repo
build_chartsvc:
<<: *build_image
environment:
- IMAGE=kubeapps/chartsvc
build_chart_apprepository:
<<: *build_image
build_go_images:
docker:
- image: circleci/golang:1.9
working_directory: /go/src/github.com/kubeapps/kubeapps
environment:
- IMAGE=kubeapps/apprepository-controller
GOPATH: /home/circleci/.go_workspace
IMAGES: "kubeapps/apprepository-controller kubeapps/chart-repo kubeapps/chartsvc kubeapps/tiller-proxy"
<<: *build_images
build_dashboard:
<<: *build_image
environment:
- IMAGE=kubeapps/dashboard
build_tiller_proxy:
<<: *build_image
docker:
- image: circleci/golang:1.9
environment:
- IMAGE=kubeapps/tiller-proxy
IMAGES: "kubeapps/dashboard"
<<: *build_images
release:
docker:
- image: circleci/golang:1.9
Expand Down
3 changes: 3 additions & 0 deletions .dockerignore
@@ -0,0 +1,3 @@
dashboard/node_modules
.git
docs
4 changes: 0 additions & 4 deletions Makefile
Expand Up @@ -18,10 +18,6 @@ kubeapps/%:
kubeapps/dashboard:
docker build -t kubeapps/dashboard$(IMG_MODIFIER):$(VERSION) -f dashboard/Dockerfile dashboard/

kubeapps/tiller-proxy:
CGO_ENABLED=0 GOOS=linux go build -installsuffix cgo -o ./cmd/tiller-proxy/proxy-static ./cmd/tiller-proxy
docker build -t kubeapps/tiller-proxy$(IMG_MODIFIER):$(VERSION) -f cmd/tiller-proxy/Dockerfile cmd/tiller-proxy

test:
$(GO) test $(GO_PACKAGES)

Expand Down
1 change: 0 additions & 1 deletion cmd/chart-repo/Dockerfile
@@ -1,7 +1,6 @@
FROM quay.io/deis/go-dev:v1.8.2 as builder
COPY . /go/src/github.com/kubeapps/kubeapps
WORKDIR /go/src/github.com/kubeapps/kubeapps
RUN dep ensure
RUN CGO_ENABLED=0 go build -a -installsuffix cgo ./cmd/chart-repo

FROM scratch
Expand Down
2 changes: 0 additions & 2 deletions cmd/tiller-proxy/.gitignore

This file was deleted.

9 changes: 6 additions & 3 deletions cmd/tiller-proxy/Dockerfile
@@ -1,7 +1,10 @@
FROM alpine:3.6 as builder
RUN apk --no-cache add ca-certificates
FROM quay.io/deis/go-dev:v1.8.2 as builder
COPY . /go/src/github.com/kubeapps/kubeapps
WORKDIR /go/src/github.com/kubeapps/kubeapps
RUN CGO_ENABLED=0 go build -a -installsuffix cgo ./cmd/tiller-proxy

FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY ./proxy-static /proxy
COPY --from=builder /go/src/github.com/kubeapps/kubeapps/tiller-proxy /proxy
EXPOSE 8080
CMD ["/proxy"]

0 comments on commit 1af2906

Please sign in to comment.