Skip to content

Commit

Permalink
Feat: add helm chart and dockerfile
Browse files Browse the repository at this point in the history
Signed-off-by: FogDong <[email protected]>
  • Loading branch information
FogDong committed Jul 11, 2022
1 parent 9a630e4 commit 64d5dfe
Show file tree
Hide file tree
Showing 19 changed files with 1,678 additions and 37 deletions.
116 changes: 116 additions & 0 deletions .github/workflows/helm-chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: HelmChart
on:
push:
tags:
- "v*"
workflow_dispatch: {}

env:
BUCKET: ${{ secrets.OSS_BUCKET }}
ENDPOINT: ${{ secrets.OSS_ENDPOINT }}
ACCESS_KEY: ${{ secrets.OSS_ACCESS_KEY }}
ACCESS_KEY_SECRET: ${{ secrets.OSS_ACCESS_KEY_SECRET }}

jobs:
publish-images:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Get the vars
id: vars
run: |
echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
- name: Login ghcr.io
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login Alibaba Cloud ACR
uses: docker/login-action@v1
with:
registry: kubevela-registry.cn-hangzhou.cr.aliyuncs.com
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
with:
driver-opts: image=moby/buildkit:master

- name: Build & Pushing vela-workflow for ACR
run: |
docker build --build-arg GOPROXY=https://proxy.golang.org -t kubevela-registry.cn-hangzhou.cr.aliyuncs.com/oamdev/vela-workflow:${{ steps.vars.outputs.TAG }} -f ./cmd/apiserver/Dockerfile .
docker push kubevela-registry.cn-hangzhou.cr.aliyuncs.com/oamdev/vela-workflow:${{ steps.vars.outputs.TAG }}
- uses: docker/build-push-action@v2
name: Build & Pushing vela-workflow for Dockerhub and GHCR
with:
context: .
file: ./cmd/apiserver/Dockerfile
labels: |-
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
build-args: |
GOPROXY=https://proxy.golang.org
tags: |-
docker.io/oamdev/vela-workflow:${{ steps.vars.outputs.TAG }}
ghcr.io/${{ github.repository }}/vela-workflow:${{ steps.vars.outputs.TAG }}
publish-charts:
env:
HELM_CHART: charts/
LOCAL_OSS_DIRECTORY: .oss/
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@master
- name: Get the vars
id: vars
run: |
echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '14'
- uses: oprypin/find-latest-tag@v1
with:
repository: kubevela/workflow
releases-only: true
id: latest_tag
- name: Tag helm chart image
run: |
latest_repo_tag=${{ steps.latest_tag.outputs.tag }}
sub="."
major="$(cut -d"$sub" -f1 <<<"$latest_repo_tag")"
minor="$(cut -d"$sub" -f2 <<<"$latest_repo_tag")"
patch="0"
current_repo_tag="$major.$minor.$patch"
image_tag=${GITHUB_REF#refs/tags/}
chart_version=$latest_repo_tag
if [[ ${GITHUB_REF} == "refs/heads/master" ]]; then
image_tag=latest
chart_version=${current_repo_tag}-nightly-build
fi
sed -i "s/latest/${image_tag}/g" $HELM_CHART/values.yaml
chart_smever=${chart_version#"v"}
sed -i "s/0.1.0/$chart_smever/g" $HELM_CHART/Chart.yaml
- name: Install ossutil
run: wget http://gosspublic.alicdn.com/ossutil/1.7.0/ossutil64 && chmod +x ossutil64 && mv ossutil64 ossutil
- name: Configure Alibaba Cloud OSSUTIL
run: ./ossutil --config-file .ossutilconfig config -i ${ACCESS_KEY} -k ${ACCESS_KEY_SECRET} -e ${ENDPOINT} -c .ossutilconfig
- name: sync cloud to local
run: ./ossutil --config-file .ossutilconfig sync oss://$BUCKET/workflow $LOCAL_OSS_DIRECTORY
- name: Package helm charts
run: |
helm package $HELM_CHART --destination $LOCAL_OSS_DIRECTORY
helm repo index --url https://$BUCKET.$ENDPOINT/workflow $LOCAL_OSS_DIRECTORY
- name: sync local to cloud
run: ./ossutil --config-file .ossutilconfig sync $LOCAL_OSS_DIRECTORY oss://$BUCKET/workflow -f
82 changes: 82 additions & 0 deletions .github/workflows/post-submit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: PostSubmit

on:
push:
branches:
- master
workflow_dispatch: {}

env:
GO_VERSION: '1.17'

jobs:

detect-noop:
runs-on: ubuntu-20.04
outputs:
noop: ${{ steps.noop.outputs.should_skip }}
steps:
- name: Detect No-op Changes
id: noop
uses: fkirc/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
paths_ignore: '["**.md", "**.mdx", "**.png", "**.jpg"]'
do_not_skip: '["workflow_dispatch", "schedule", "push"]'
concurrent_skipping: false

image-multi-arch:
runs-on: ubuntu-20.04
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'
strategy:
matrix:
arch: [ amd64, arm64 ]

steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: Build Image
run: |
IMG_TAG=latest-${{ matrix.arch }} \
OS=linux \
ARCH=${{ matrix.arch }} \
make image-apiserver
- name: Push Image
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login --username ${{ secrets.DOCKER_USER }} --password-stdin
docker push oamdev/vela-workflow:latest-${{ matrix.arch }}
docker push oamdev/vela-workflow:latest-${{ matrix.arch }}
image-manifest:
runs-on: ubuntu-latest
needs: [ image-multi-arch ]
steps:

- name: Checkout
uses: actions/checkout@v2
with:
submodules: true

- name: Create Manifest
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login --username ${{ secrets.DOCKER_USER }} --password-stdin
docker manifest create oamdev/vela-workflow:latest \
oamdev/vela-workflow:latest-amd64 \
oamdev/vela-workflow:latest-arm64
- name: Annotate Manifest
run: |
docker manifest annotate oamdev/vela-workflow:latest \
oamdev/vela-workflow:latest-amd64 --arch amd64
docker manifest annotate oamdev/vela-workflow:latest \
oamdev/vela-workflow:latest-arm64 --arch arm64
- name: Push Manifest
run: |
docker manifest push oamdev/vela-workflow:latest
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ARG BASE_IMAGE
# Build the manager binary
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.17-alpine as builder
ARG GOPROXY
ENV GOPROXY=${GOPROXY:-https://goproxy.cn}
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY controllers/ controllers/
COPY pkg/ pkg/

# Build
ARG TARGETARCH

RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} \
go build -a -ldflags "-s -w" \
-o vela-workflow-${TARGETARCH} cmd/main.go

FROM ${BASE_IMAGE:-alpine:3.15}
# This is required by daemon connecting with cri
RUN apk add --no-cache ca-certificates bash expat

WORKDIR /

ARG TARGETARCH
COPY --from=builder /workspace/vela-workflow-${TARGETARCH} /usr/local/bin/vela-workflow

ENTRYPOINT ["vela-workflow"]
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ help: ## Display this help.
##@ Development

.PHONY: reviewable
reviewable: manifests fmt vet lint staticcheck
reviewable: manifests fmt vet lint staticcheck helm-doc-gen
go mod tidy -compat=1.17

.PHONY: check-diff
Expand Down Expand Up @@ -62,6 +62,10 @@ vet: ## Run go vet against code.
test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile coverage.txt

.PHONY: helm-doc-gen
helm-doc-gen: helmdoc
readme-generator -v charts/vela-workflow/values.yaml -r charts/vela-workflow/README.md

##@ Build

.PHONY: build
Expand All @@ -73,8 +77,8 @@ run: manifests generate fmt vet ## Run a controller from your host.
go run ./cmd/main.go

.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
docker build -t ${IMG} .
docker-build: ## Build docker image with the manager.
docker build --build-arg=VERSION=$(VELA_VERSION) --build-arg=GITVERSION=$(GIT_COMMIT) -t $(IMG) .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
Expand Down
23 changes: 23 additions & 0 deletions charts/vela-workflow/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions charts/vela-workflow/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: vela-workflow
description: A Helm chart for KubeVela Workflow

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 0.1.0

home: https://kubevela.io
icon: https://kubevela.io/img/logo.svg
Loading

0 comments on commit 64d5dfe

Please sign in to comment.