Skip to content

github-actions: build docker images #508

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

Draft
wants to merge 41 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
53fc1e4
github-actions: build docker images
v1v Feb 10, 2025
8d4f068
fix
v1v Feb 10, 2025
76984c3
run
v1v Feb 10, 2025
518fb0f
fix
v1v Feb 10, 2025
abf5955
fail fast false
v1v Feb 10, 2025
618bace
debug
v1v Feb 10, 2025
fd4ba45
avoid default
v1v Feb 10, 2025
f58ea5c
honour the variable
v1v Feb 10, 2025
bd67b6b
use a different google bucket
v1v Feb 10, 2025
ed7d7be
debug
v1v Feb 10, 2025
b49cbc3
test
v1v Feb 10, 2025
5e0fbc8
use what Ivan did in https://github.com/kuisathaverat/golang-crossbui…
v1v Feb 10, 2025
74813f1
fix
v1v Feb 10, 2025
33ad71f
fix
v1v Feb 10, 2025
850f5c5
split
v1v Feb 10, 2025
1fa60e0
fix
v1v Feb 10, 2025
9acdc2f
fix
v1v Feb 10, 2025
e914779
docker login
v1v Feb 10, 2025
7f3eb06
see https://github.com/elastic/golang-crossbuild/issues/6
v1v Feb 10, 2025
ef58cd7
refactor
v1v Feb 10, 2025
6c19cf6
fix
v1v Feb 10, 2025
b754340
support staging and production
v1v Feb 10, 2025
9e95525
refactor
v1v Feb 10, 2025
b1f2607
chore
v1v Feb 10, 2025
38f0f74
support fpm and llvm
v1v Feb 10, 2025
dc762f5
refactor
v1v Feb 10, 2025
436b4f6
chore
v1v Feb 10, 2025
99fb808
fix
v1v Feb 10, 2025
c855235
set missing variables
v1v Feb 10, 2025
a4221af
run
v1v Feb 10, 2025
a44fd79
fix
v1v Feb 10, 2025
e897227
simplify matrix
v1v Feb 10, 2025
8b94fe2
add
v1v Feb 10, 2025
1e06629
chore
v1v Feb 10, 2025
0a7e4a6
trying to solve this
v1v Feb 10, 2025
43b1d95
run
v1v Feb 10, 2025
29e9e65
disable jobs for now
v1v Feb 11, 2025
6103ab8
Merge branch 'main' into feature/use-github-actions-2
v1v Feb 11, 2025
b4510dc
Merge remote-tracking branch 'upstream/main' into feature/use-github-…
v1v Feb 11, 2025
219e9b0
remove debian 7 and 8
v1v Feb 11, 2025
90a0c6c
remove ci-fpm and ci-llvm-apple
v1v Feb 11, 2025
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
52 changes: 52 additions & 0 deletions .github/actions/build-push/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
name: docker build and push
inputs:
docker-registry:
description: 'The docker registry'
required: true
docker-username:
description: 'The docker username'
required: true
docker-password:
description: 'The docker password'
required: true
make-directory:
description: 'What directory to run make from'
required: true
make-file:
description: 'What Makefile'
required: true
make-goal-suffix:
description: 'What make goal suffix'
required: true

runs:
using: "composite"
steps:
# TODO: use google auth action
- name: Docker login
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ inputs.docker-registry }}
username: ${{ inputs.docker-username }}
password: ${{ inputs.docker-password }}

- name: Docker build
run: make -C "${MAKE_DIR}" -f "${MAKEFILE}" build${MAKE_GOAL_SUFFIX}
env:
MAKE_DIR: "${{ inputs.make-directory }}"
MAKEFILE: "${{ inputs.make-file }}"
MAKE_GOAL_SUFFIX: "${{ inputs.make-goal-suffix }}"
shell: bash

- name: Docker build
run: make -C "${MAKE_DIR}" -f "${MAKEFILE}" push${MAKE_GOAL_SUFFIX}
env:
MAKE_DIR: "${{ inputs.make-directory }}"
MAKEFILE: "${{ inputs.make-file }}"
MAKE_GOAL_SUFFIX: "${{ inputs.make-goal-suffix }}"
shell: bash

- name: Docker images
run: docker images --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}"
shell: bash
86 changes: 86 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
name: ci

on:
push: ~

permissions:
contents: read

env:
# TODO: support for other release branches with the format [0-9]+.[0-9]+
REPOSITORY: "${{ startsWith(github.head_ref, 'main') && 'docker.elastic.co/beats-dev' || 'docker.elastic.co/observability-ci' }}"
# TODO: use the google bucket instead
GS_BUCKET_PATH: "golang-crossbuild-tmp"
# TODO: bypass access to the google bucket for now
CI: "false"
# NOTE: as long as we don't use the google bucket but downloading from github
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build-push:
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
makefile: [
"Makefile",
"Makefile.debian9",
"Makefile.debian10",
"Makefile.debian11",
"Makefile.debian12"
]
fips: [ "false", "true" ]
runs-on: "ubuntu-24.04"
env:
FIPS: "${{matrix.fips}}"
steps:
- uses: actions/checkout@v4

# TODO: move to the build-push composite action
# then need to enable the support ci-fpm ane ci-llvm-apple
- uses: elastic/oblt-actions/google/auth@v1

- name: Debug gcloud CLI
run: |
gcloud info || true
gsutil list -lra gs://golang-crossbuild-tmp/private || true
gcloud auth list --filter=status:ACTIVE --format="value(account)" || true

- name: Docker build and push
uses: ./.github/actions/build-push
with:
docker-registry: ${{ secrets.ELASTIC_DOCKER_REGISTRY }}
docker-username: ${{ secrets.ELASTIC_DOCKER_USERNAME }}
docker-password: ${{ secrets.ELASTIC_DOCKER_PASSWORD }}
make-directory: 'go'
make-file: "${{matrix.makefile}}"

build-push-arm:
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
fips: [ "false", "true" ]
runs-on: "ubuntu-24.04-arm"
env:
FIPS: "${{matrix.fips}}"
steps:
- uses: actions/checkout@v4

# TODO: move to the build-push composite action
- uses: elastic/oblt-actions/google/auth@v1

- name: Docker build and push
uses: ./.github/actions/build-push
with:
docker-registry: ${{ secrets.ELASTIC_DOCKER_REGISTRY }}
docker-username: ${{ secrets.ELASTIC_DOCKER_USERNAME }}
docker-password: ${{ secrets.ELASTIC_DOCKER_PASSWORD }}
make-directory: 'go'
make-file: 'Makefile.debian9'
make-goal-suffix: '-arm'
14 changes: 12 additions & 2 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ NPCAP_VERSION := 1.80
NPCAP_FILE := npcap-$(NPCAP_VERSION)-oem.exe
SUFFIX_NPCAP_VERSION := -npcap-$(NPCAP_VERSION)
NPCAP_REPOSITORY := docker.elastic.co/observability-ci
GS_BUCKET_PATH ?= ingest-buildkite-ci
GS_BUCKET_PATH ?=
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unset, so we are forced to set it always



ifeq ($(BUILDX),1)
Expand All @@ -18,18 +18,28 @@ endif

# Requires login at google storage.
copy-npcap:
@echo 'cp gs://$(GS_BUCKET_PATH)/private/$(NPCAP_FILE)'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for debugging purposes only

ifeq ($(CI),true)
@gsutil cp gs://$(GS_BUCKET_PATH)/private/$(NPCAP_FILE) ../npcap/lib/$(NPCAP_FILE)
else
@echo 'Only available if running in the CI'
mkdir -p ../npcap/lib/
touch ../npcap/lib/npcap-1.80-oem.exe
endif

# Requires login at google storage.
copy-sdks:
@echo 'cp gs://$(GS_BUCKET_PATH)/sdks'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for debugging purposes only

ifeq ($(CI),true)
@gcloud storage cp gs://ingest-buildkite-ci/sdks . --recursive
@gcloud storage cp gs://$(GS_BUCKET_PATH)/sdks . --recursive
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honour the variable

else
@echo 'Only available if running in the CI'
mkdir -p sdks/
gh api https://github.com/the-tcpdump-group/tcpdump-htdocs/raw/refs/heads/master/release/libpcap-1.8.1.tar.gz -H "Accept: application/vnd.github.raw" > sdks/libpcap-1.8.1.tar.gz
curl -sSfL -o sdks/MacOSX10.11.sdk.tar.xz https://s3.amazonaws.com/beats-files/deps/MacOSX10.11.sdk.tar.xz
curl -sSfL -o sdks/WpdPack_4_1_2.zip https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip
# see https://github.com/elastic/golang-crossbuild/pull/454/files#diff-36b826ca106e191815b93280143b7cfd13c583e4adc3e27442a5057ac7294586L54
curl -sSfL -o sdks/MacOSX11.3.sdk.tar.xz https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz
endif

push:
Expand Down