Skip to content

Commit e8c673c

Browse files
committed
build: update Dockerfiles, Makefile, and CI for Cilium v1.19
- Update Go base images and build toolchain in Dockerfiles - Add ARG BUILDPLATFORM before first FROM in Windows Dockerfiles - Fix CGO_ENABLED handling and use -run bpf2go in test image Dockerfile - Add _cprog to golangci-lint excluded paths - Update Makefile, CI workflows, devcontainer, and .gitignore Signed-off-by: Quang Nguyen <nguyenquang@microsoft.com>
1 parent 6b7cec7 commit e8c673c

File tree

16 files changed

+128
-126
lines changed

16 files changed

+128
-126
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"ghcr.io/devcontainers/features/github-cli:1": {},
88
"ghcr.io/devcontainers/features/go:1": {},
99
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {},
10-
"ghcr.io/devcontainers-contrib/features/kind:1": {},
1110
"ghcr.io/devcontainers/features/azure-cli:1": {}
1211
},
1312
"postCreateCommand": "bash .devcontainer/installMoreTools.sh && kind create cluster",
@@ -22,4 +21,4 @@
2221
]
2322
}
2423
}
25-
}
24+
}

.github/workflows/golangci-lint.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ jobs:
2828
if: env.IS_NOT_MERGE_GROUP
2929
with:
3030
go-version-file: go.mod
31+
- name: Check BPF object stubs
32+
if: env.IS_NOT_MERGE_GROUP
33+
run: make lint-bpf-objects
3134
- name: golangci-lint
3235
if: env.IS_NOT_MERGE_GROUP
3336
uses: golangci/golangci-lint-action@v9

.github/workflows/images.yaml

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ permissions:
1414
jobs:
1515
retina-images:
1616
name: Build Agent Images - Linux
17-
runs-on: ubuntu-latest
17+
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
1818

1919
strategy:
2020
matrix:
@@ -30,9 +30,6 @@ jobs:
3030
go-version-file: go.mod
3131
- run: go version
3232

33-
- name: Set up QEMU
34-
uses: docker/setup-qemu-action@v3
35-
3633
- name: Az CLI login
3734
uses: azure/login@v2
3835
if: ${{ github.event_name == 'merge_group' }}
@@ -65,7 +62,7 @@ jobs:
6562
build-windows-binaries:
6663
name: Build Windows Binaries
6764
runs-on: ubuntu-latest
68-
65+
6966
steps:
7067
- name: Checkout code
7168
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -131,7 +128,7 @@ jobs:
131128
TAG=$(make version)
132129
echo "TAG=$TAG" >> "$GITHUB_ENV"
133130
if [ "$IS_MERGE_GROUP" == "true" ]; then
134-
az acr login -n ${{ vars.ACR_NAME }}
131+
az acr login -n ${{ vars.ACR_NAME }}
135132
make retina-image-win \
136133
IMAGE_NAMESPACE=${{ github.repository }} \
137134
PLATFORM=${{ matrix.platform }}/${{ matrix.arch }} \
@@ -154,7 +151,7 @@ jobs:
154151

155152
operator-images:
156153
name: Build Operator Images
157-
runs-on: ubuntu-latest
154+
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
158155

159156
strategy:
160157
matrix:
@@ -170,9 +167,6 @@ jobs:
170167
go-version-file: go.mod
171168
- run: go version
172169

173-
- name: Set up QEMU
174-
uses: docker/setup-qemu-action@v3
175-
176170
- name: Az CLI login
177171
uses: azure/login@v2
178172
if: ${{ github.event_name == 'merge_group' }}
@@ -203,18 +197,13 @@ jobs:
203197
IS_MERGE_GROUP: ${{ github.event_name == 'merge_group' }}
204198

205199
retina-shell-images:
206-
name: Build Retina Shell Images (${{ matrix.platform }}, ${{ matrix.arch }})
207-
runs-on: ${{ matrix.runner }}
200+
name: Build Retina Shell Images
201+
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
208202

209203
strategy:
210204
matrix:
211-
include:
212-
- platform: linux
213-
arch: amd64
214-
runner: ubuntu-latest
215-
- platform: linux
216-
arch: arm64
217-
runner: ubuntu-24.04-arm
205+
platform: ["linux"]
206+
arch: ["amd64", "arm64"]
218207

219208
steps:
220209
- name: Checkout code
@@ -255,7 +244,7 @@ jobs:
255244

256245
kubectl-retina-images:
257246
name: Build Kubectl Retina Images
258-
runs-on: ubuntu-latest
247+
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
259248

260249
strategy:
261250
matrix:
@@ -271,9 +260,6 @@ jobs:
271260
go-version-file: go.mod
272261
- run: go version
273262

274-
- name: Set up QEMU
275-
uses: docker/setup-qemu-action@v3
276-
277263
- name: Az CLI login
278264
uses: azure/login@v2
279265
if: ${{ github.event_name == 'merge_group' }}
@@ -337,7 +323,7 @@ jobs:
337323
shell: bash
338324
run: |
339325
set -euo pipefail
340-
az acr login -n ${{ vars.ACR_NAME }}
326+
az acr login -n ${{ vars.ACR_NAME }}
341327
make manifest COMPONENT=${{ matrix.components }} \
342328
IMAGE_REGISTRY=${{ vars.ACR_NAME }} \
343329
@@ -389,7 +375,7 @@ jobs:
389375
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
390376
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
391377
azure-app-insights-key: ${{ secrets.AZURE_APP_INSIGHTS_KEY }}
392-
378+
393379
perf-test-advanced:
394380
if: ${{ github.event_name == 'merge_group'}}
395381
needs: [manifests]

.gitignore

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,43 @@
1-
# If you prefer the allow list template instead of the deny list, see community template:
2-
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3-
#
4-
# Binaries for programs and plugins
1+
# Binaries
52
*.exe
63
*.exe~
74
*.dll
85
*.so
96
*.dylib
10-
11-
# Avoid checking in keys
12-
*.pem
13-
14-
# Test binary, built with `go test -c`
157
*.test
16-
17-
# Output of the go coverage tool, specifically when used with LiteIDE
18-
*.out
19-
20-
# logs
21-
*.log
22-
23-
# Dependency directories (remove the comment below to include it)
24-
# vendor/
25-
26-
# Go workspace file
27-
go.work
28-
29-
# Object files
308
*.o
9+
bin/
10+
dist/
3111

32-
# docusaurus
33-
site/yarn.lock
34-
site/.docusaurus/
35-
site/node_modules/
12+
# Go
13+
go.work
3614

37-
output
38-
#vscode
39-
.vscode/
15+
# Keys and certificates
16+
*.pem
17+
.certs/
4018

41-
dist/
42-
bin/
19+
# Logs and output
20+
*.log
21+
*.out
22+
.output/
4323

44-
image-metadata-*.json
45-
*packetmonitorsupport*/
46-
*.pem
24+
# Test artifacts
4725
*results*.json
4826
netperf-*.json
4927
netperf-*.csv
28+
image-metadata-*.json
29+
*packetmonitorsupport*/
30+
test-summary
5031

51-
.certs/
32+
# Build artifacts
33+
.artifacts/
5234

53-
artifacts/
35+
# Documentation site
36+
site/yarn.lock
37+
site/.docusaurus/
38+
site/node_modules/
5439

55-
test-summary
40+
# IDE and editor
41+
.vscode/
42+
.clangd
43+
.clang-format

.golangci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ linters:
7878
- third_party$
7979
- builtin$
8080
- examples$
81+
- _cprog$
8182
issues:
8283
max-issues-per-linter: 0
8384
max-same-issues: 0

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,20 @@ lint: ## Fast lint vs default branch showing only new issues.
146146
lint-existing: ## Lint the current branch in entirety.
147147
$(GOLANGCI_LINT) run -v $(LINT_PKG)/...
148148

149+
lint-bpf-objects: ## Check that committed .o files are empty stubs (build generates real ones).
150+
@echo "Checking for non-empty .o files..."
151+
@non_empty=$$(git ls-files '*.o' | xargs -I{} sh -c 'test -s "{}" && echo "{}"'); \
152+
if [ -n "$$non_empty" ]; then \
153+
echo "ERROR: The following .o files must be empty stubs:"; \
154+
echo "$$non_empty"; \
155+
echo "Run 'make empty-bpf-objects' to fix."; \
156+
exit 1; \
157+
fi
158+
@echo "All .o files are empty stubs. OK."
159+
160+
empty-bpf-objects: ## Empty all tracked .o files (they are stubs for the linter).
161+
git ls-files '*.o' | xargs -I{} truncate -s 0 {}
162+
149163
clean: ## clean build artifacts
150164
$(RMDIR) $(OUTPUT_DIR)
151165

cli/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.24.11-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
2-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang@sha256:531bd02db17b0c2ec919f10fc203a6a8c825e8ca01f40c3a1e32e1cf7119c6d8 AS builder
2+
FROM mcr.microsoft.com/oss/go/microsoft/golang@sha256:a1a9699ff2ee1c3a2b5a23e6226ea431b6c876c84b52f78b2f514edcb9816340 AS builder
33

44
ARG VERSION
55
ARG APP_INSIGHTS_ID
@@ -16,21 +16,21 @@ ARG GOARCH=amd64
1616
ENV GOARCH=${GOARCH}
1717

1818
RUN --mount=type=cache,target="/root/.cache/go-build" \
19-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
19+
GOOS=$GOOS GOARCH=$GOARCH go build \
2020
-ldflags "-X github.com/microsoft/retina/internal/buildinfo.Version="$VERSION" \
2121
-X "github.com/microsoft/retina/internal/buildinfo.ApplicationInsightsID"="$APP_INSIGHTS_ID" \
2222
-X "github.com/microsoft/retina/internal/buildinfo.RetinaAgentImageName"="$AGENT_IMAGE_NAME"" \
2323
-a -o kubectl-retina cli/main.go
2424

2525
# Target 1: Distroless (secure, minimal)
2626
# skopeo inspect docker://mcr.microsoft.com/azurelinux/distroless/minimal:3.0 --format "{{.Name}}@{{.Digest}}"
27-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/azurelinux/distroless/minimal@sha256:0801b80a0927309572b9adc99bd1813bc680473175f6e8175cd4124d95dbd50c AS distroless-target
27+
FROM mcr.microsoft.com/azurelinux/distroless/minimal@sha256:0801b80a0927309572b9adc99bd1813bc680473175f6e8175cd4124d95dbd50c AS distroless-target
2828
WORKDIR /
2929
COPY --from=builder /workspace/kubectl-retina .
3030

3131
# Target 2: Shell-enabled (operational, init container support)
3232
# skopeo inspect docker://mcr.microsoft.com/cbl-mariner/base/core:2.0 --format "{{.Name}}@{{.Digest}}"
33-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/cbl-mariner/base/core@sha256:4d97d662d71c1fda938ed9df36d8f490d9107cff37e89c0efa932d073285ad85 AS shell-target
33+
FROM mcr.microsoft.com/cbl-mariner/base/core@sha256:4d97d662d71c1fda938ed9df36d8f490d9107cff37e89c0efa932d073285ad85 AS shell-target
3434
WORKDIR /
3535
COPY --from=builder /workspace/kubectl-retina /bin/kubectl-retina
3636
RUN chmod +x /bin/kubectl-retina

controller/Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# pinned base images
22

33
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.24.11-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
4-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang@sha256:531bd02db17b0c2ec919f10fc203a6a8c825e8ca01f40c3a1e32e1cf7119c6d8 AS golang
4+
FROM mcr.microsoft.com/oss/go/microsoft/golang@sha256:a1a9699ff2ee1c3a2b5a23e6226ea431b6c876c84b52f78b2f514edcb9816340 AS golang
55

66
# skopeo inspect docker://mcr.microsoft.com/azurelinux/base/core:3.0 --format "{{.Name}}@{{.Digest}}"
77
FROM mcr.microsoft.com/azurelinux/base/core@sha256:9948138108a3d69f1dae62104599ac03132225c3b7a5ac57b85a214629c8567d AS azurelinux-core
@@ -19,21 +19,23 @@ ARG GOOS=linux # default to linux
1919
ENV GOARCH=${GOARCH}
2020
ENV GOOS=${GOOS}
2121
RUN if [ "$GOOS" = "linux" ] ; then \
22-
tdnf install -y clang lld bpftool libbpf-devel; \
22+
tdnf install -y clang lld bpftool libbpf-devel; \
2323
fi
2424
COPY ./pkg/plugin /go/src/github.com/microsoft/retina/pkg/plugin
2525
WORKDIR /go/src/github.com/microsoft/retina
2626
RUN if [ "$GOOS" = "linux" ] ; then \
27-
go mod init github.com/microsoft/retina; \
28-
go generate -skip "mockgen" -x /go/src/github.com/microsoft/retina/pkg/plugin/...; \
29-
tar czf /gen.tar.gz ./pkg/plugin; \
30-
rm go.mod; \
27+
go mod init github.com/microsoft/retina; \
28+
go generate -skip "mockgen" -x /go/src/github.com/microsoft/retina/pkg/plugin/...; \
29+
tar czf /gen.tar.gz ./pkg/plugin; \
30+
rm go.mod; \
3131
fi
3232
COPY ./go.mod ./go.sum ./
3333
RUN go mod download
3434
COPY . .
3535
RUN if [ "$GOOS" = "linux" ] ; then \
36-
rm -rf ./pkg/plugin && tar xvf /gen.tar.gz ./pkg/plugin; \
36+
rm -rf ./pkg/plugin && tar xvf /gen.tar.gz ./pkg/plugin; \
37+
find ./pkg/plugin -path "*/_cprog/*.go" -delete; \
38+
find ./pkg/plugin -name "*.go" -exec sed -i '/^[[:space:]]*_[[:space:]]*".*\/_cprog"/d' {} \;; \
3739
fi
3840

3941
# capture binary

controller/Dockerfile.gogen

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.24.11-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
2-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang@sha256:531bd02db17b0c2ec919f10fc203a6a8c825e8ca01f40c3a1e32e1cf7119c6d8
2+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang@sha256:a1a9699ff2ee1c3a2b5a23e6226ea431b6c876c84b52f78b2f514edcb9816340
33

44
# Default linux/architecture.
55
ARG GOOS=linux

controller/Dockerfile.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.24.11-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
2-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang@sha256:531bd02db17b0c2ec919f10fc203a6a8c825e8ca01f40c3a1e32e1cf7119c6d8
2+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang@sha256:a1a9699ff2ee1c3a2b5a23e6226ea431b6c876c84b52f78b2f514edcb9816340
33

44
LABEL Name=retina-builder Version=0.0.1
55

0 commit comments

Comments
 (0)