Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move build tools to this repo #130

Merged
merged 2 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/keda-tools.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: keda-tools
on:
push:
branches:
- main
paths:
- 'tools/**'
- 'Makefile'

jobs:
validate:
name: Validate
runs-on: ARM64
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
# Username used to log in to a Docker registry. If not set then no login will occur
username: ${{ github.repository_owner }}
# Password or personal access token used to log in to a Docker registry. If not set then no login will occur
password: ${{ secrets.GHCR_AUTH_PAT }}
# Server address of Docker registry. If not set then will default to Docker Hub
registry: ghcr.io

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and publish Tools image
run: make push-keda-tools
4 changes: 4 additions & 0 deletions .github/workflows/master.yml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ on:
push:
branches:
- main
paths:
- 'e2e/images/**'
- 'Makefile'

jobs:
validate:
name: Build
Expand Down
48 changes: 46 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,53 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v1
uses: actions/checkout@v3
with:
fetch-depth: 1

- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
e2e-images:
- 'e2e/images/**'

- name: Build
run: make build-e2e-images
if: steps.filter.outputs.e2e-images == 'true'
run: make build-e2e-images

validate-keda-tools:
name: Validate keda-tools - ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- runner: ARM64
name: arm64
- runner: ubuntu-latest
name: amd64
steps:
- uses: actions/checkout@v3

- name: Register workspace path
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"

- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
tools:
- 'tools/**'
- 'Makefile'

- name: Set up QEMU
if: steps.filter.outputs.tools == 'true'
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
if: steps.filter.outputs.tools == 'true'
uses: docker/setup-buildx-action@v2

- name: Build tools
if: steps.filter.outputs.tools == 'true'
run: make build-keda-tools
29 changes: 26 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
IMAGE_TAG := $(shell git describe --always --abbrev=7)
KEDA_TOOLS_GO_VERSION = 1.20.5

IMAGE_REGISTRY ?= ghcr.io
IMAGE_REPO ?= kedacore
IMAGE_KEDA_TOOLS = $(IMAGE_REGISTRY)/$(IMAGE_REPO)/keda-tools:$(KEDA_TOOLS_GO_VERSION)

BUILD_PLATFORMS ?= linux/amd64,linux/arm64

E2E_IMAGE_TAG := $(shell git describe --always --abbrev=7)

##################################################
# e2e tests images #
##################################################

e2e-images: build-e2e-images push-e2e-images

build-e2e-images:
IMAGE_TAG=$(IMAGE_TAG) ./e2e/images/build.sh
IMAGE_TAG=$(E2E_IMAGE_TAG) ./e2e/images/build.sh

push-e2e-images:
IMAGE_TAG=$(IMAGE_TAG) ./e2e/images/build.sh --push
IMAGE_TAG=$(E2E_IMAGE_TAG) ./e2e/images/build.sh --push

##################################################
# tools image #
##################################################

build-keda-tools:
docker build -f tools/Dockerfile -t $(IMAGE_KEDA_TOOLS) --build-arg GO_VERSION=$(KEDA_TOOLS_GO_VERSION) .

push-keda-tools:
docker buildx build --push --platform=${BUILD_PLATFORMS} -f tools/Dockerfile -t ${IMAGE_KEDA_TOOLS} --build-arg GO_VERSION=$(KEDA_TOOLS_GO_VERSION) .
67 changes: 67 additions & 0 deletions tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
FROM ubuntu:20.04

# Install prerequisite
RUN apt update && \
apt-get install software-properties-common -y
RUN apt-add-repository ppa:git-core/ppa && \
apt update && \
apt install -y wget curl build-essential git git-lfs unzip

# Use Bash instead of Dash
RUN ln -sf bash /bin/sh

# Install python3
RUN apt install -y python3 python3-pip

# Install azure-cli
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash

# Install docker
RUN apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common lsb-release && \
curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | apt-key add - 2>/dev/null && \
add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" && \
apt-get update &&\
apt-get install -y docker-ce-cli

# Install golang
ARG GO_VERSION
RUN curl -LO https://golang.org/dl/go${GO_VERSION}.linux-$(dpkg --print-architecture).tar.gz && \
tar -C /usr/local -xvzf go${GO_VERSION}.linux-$(dpkg --print-architecture).tar.gz && \
rm -rf go${GO_VERSION}.linux-$(dpkg --print-architecture).tar.gz

# Install kubectl
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/$(dpkg --print-architecture)/kubectl" && \
curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/$(dpkg --print-architecture)/kubectl.sha256" && \
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check && \
chmod +x ./kubectl && mv ./kubectl /usr/bin/kubectl && \
rm kubectl.sha256

# Install operator-sdk
RUN RELEASE_VERSION=v1.0.1 && \
curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu && \
curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu.asc && \
gpg --keyserver keyserver.ubuntu.com --recv-key 0CF50BEE7E4DF6445E08C0EA9AFDE59E90D2B445 && \
gpg --verify operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu.asc && \
chmod +x operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu && \
mkdir -p /usr/local/bin/ && \
cp operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu /usr/local/bin/operator-sdk && \
rm operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu

ENV PATH=${PATH}:/usr/local/go/bin
ENV GOROOT=/usr/local/go
ENV GOPATH=/go
ENV PATH=${PATH}:${GOPATH}/bin

# Install gh
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null && \
apt update && \
apt install -y gh

# Protocol Buffer Compiler
RUN PROTOC_VERSION=21.9 \
&& if [ $(dpkg --print-architecture) = "amd64" ]; then PROTOC_ARCH="x86_64"; else PROTOC_ARCH="aarch_64" ; fi \
&& curl -LO "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-$PROTOC_ARCH.zip" \
&& unzip "protoc-${PROTOC_VERSION}-linux-$PROTOC_ARCH.zip" -d $HOME/.local \
&& mv $HOME/.local/bin/protoc /usr/local/bin/protoc \
&& mv $HOME/.local/include/ /usr/local/bin/include/