Merge pull request #246 from carverauto/updates/k8s_demo #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .github/workflows/container-build.yml | |
name: Build and Push Containers | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '*.md' | |
- 'docs/**' | |
- '.github/**' | |
- '!.github/workflows/container-build.yml' | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
build-containers: | |
runs-on: ubuntu-latest | |
env: | |
VERSION: latest | |
BASE_REPO: ghcr.io/carverauto/serviceradar | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Extract short SHA | |
id: vars | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.24' | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'npm' | |
cache-dependency-path: 'web/package-lock.json' | |
- name: Install build dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libsqlite3-dev gcc | |
- name: Setup ko | |
uses: ko-build/[email protected] | |
- name: Build web UI | |
run: ./scripts/build-web.sh | |
- name: Move web artifacts | |
run: | | |
mkdir -p pkg/cloud/api/web/ | |
cp -r web/dist pkg/cloud/api/web/ | |
mkdir -p cmd/cloud/.kodata | |
cp -r web/dist cmd/cloud/.kodata/web | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push container images | |
run: | | |
# Common tag variables | |
SHA_TAG=sha-${{ steps.vars.outputs.sha_short }} | |
# Build agent | |
cd cmd/agent | |
KO_DOCKER_REPO=${{ env.BASE_REPO }}/serviceradar-agent GOFLAGS="-tags=containers" ko build \ | |
--platform=linux/amd64,linux/arm64 \ | |
--tags=${SHA_TAG},latest \ | |
--bare . | |
cd ../.. | |
# Build poller | |
cd cmd/poller | |
KO_DOCKER_REPO=${{ env.BASE_REPO }}/serviceradar-poller GOFLAGS="-tags=containers" ko build \ | |
--platform=linux/amd64,linux/arm64 \ | |
--tags=${SHA_TAG},latest \ | |
--bare . | |
cd ../.. | |
# Build cloud (with CGO enabled) | |
cd cmd/cloud | |
CGO_ENABLED=1 KO_DOCKER_REPO=${{ env.BASE_REPO }}/serviceradar-cloud GOFLAGS="-tags=containers" ko build \ | |
--platform=linux/amd64 \ | |
--tags=${SHA_TAG},latest \ | |
--bare . | |
cd ../.. | |
# Build dusk checker | |
cd cmd/checkers/dusk | |
KO_DOCKER_REPO=${{ env.BASE_REPO }}/serviceradar-dusk-checker GOFLAGS="-tags=containers" ko build \ | |
--platform=linux/amd64,linux/arm64 \ | |
--tags=${SHA_TAG},latest \ | |
--bare . | |
cd ../../.. | |
# Build snmp checker | |
cd cmd/checkers/snmp | |
KO_DOCKER_REPO=${{ env.BASE_REPO }}/serviceradar-snmp-checker GOFLAGS="-tags=containers" ko build \ | |
--platform=linux/amd64,linux/arm64 \ | |
--tags=${SHA_TAG},latest \ | |
--bare . |