Skip to content

Commit

Permalink
Merge pull request #248 from carverauto/fix/ko_container_builds_cicd
Browse files Browse the repository at this point in the history
Fix/ko container builds cicd
  • Loading branch information
mfreeman451 authored Feb 25, 2025
2 parents d1a678b + 95f7089 commit 3aaca71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 58 deletions.
64 changes: 6 additions & 58 deletions .github/workflows/container-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# .github/workflows/container-build.yml
name: Build and Push Containers
on:
push:
Expand Down Expand Up @@ -32,31 +31,9 @@ jobs:
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:
Expand All @@ -66,44 +43,15 @@ jobs:

- name: Build and push container images
run: |
# Common tag variables
SHA_TAG=sha-${{ steps.vars.outputs.sha_short }}
# Build agent
echo "Pushing to ${{ env.BASE_REPO }}/serviceradar-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 .
--bare --verbose .
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 .
# Uncomment after agent works
# cd cmd/cloud
# KO_DOCKER_REPO=${{ env.BASE_REPO }}/serviceradar-cloud CGO_ENABLED=1 GOFLAGS="-tags=containers" ko build ...
# (add other components)
1 change: 1 addition & 0 deletions cmd/cloud/.ko.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
defaultBaseImage: cgr.dev/chainguard/ko

0 comments on commit 3aaca71

Please sign in to comment.