Skip to content

Commit 0fc5208

Browse files
committed
Build service images in CI
1 parent 4c58301 commit 0fc5208

File tree

2 files changed

+108
-3
lines changed

2 files changed

+108
-3
lines changed

.github/workflows/build-services.yml

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Build Services
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
push:
7+
description: Push images
8+
required: true
9+
type: boolean
10+
default: true
11+
workflow_call:
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
REPO: datadog/images-rb
16+
17+
jobs:
18+
build:
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- service: datadog/agent
24+
arch: ["x86_64", "aarch64"]
25+
- service: datadog/dd-apm-test-agent
26+
arch: ["x86_64", "aarch64"]
27+
- service: elasticsearch
28+
arch: ["x86_64", "aarch64"]
29+
- service: memcached
30+
arch: ["x86_64", "aarch64"]
31+
- service: mongo
32+
arch: ["x86_64", "aarch64"]
33+
- service: mysql
34+
arch: ["x86_64", "aarch64"]
35+
- service: opensearchproject/opensearch
36+
arch: ["x86_64", "aarch64"]
37+
- service: postgres
38+
arch: ["x86_64", "aarch64"]
39+
- service: redis
40+
arch: ["x86_64", "aarch64"]
41+
- service: starburstdata/presto
42+
arch: ["x86_64", "aarch64"]
43+
runs-on: ubuntu-24.04
44+
permissions:
45+
packages: write
46+
name: Build (${{ matrix.service }})
47+
steps:
48+
- name: Set up Docker
49+
uses: crazy-max/ghaction-setup-docker@635d07c09dc2b52072362e9bb37e7e789767106d
50+
with:
51+
daemon-config: |
52+
{
53+
"features": {
54+
"containerd-snapshotter": true
55+
}
56+
}
57+
- name: Checkout
58+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
59+
with:
60+
persist-credentials: false
61+
fetch-depth: 2
62+
- name: Bundle install
63+
run: |
64+
bundle install
65+
- name: Set variables
66+
id: vars
67+
run: |
68+
echo "DOCKER_PLATFORMS=$(echo ${{ join(matrix.arch) }} | tr ',' '\n' | sed 's/^/linux\//' | paste -s -d, -)" >> $GITHUB_OUTPUT
69+
70+
# First, build image for x86_64 as it will fail fast
71+
#
72+
- name: Build single-arch image (x86_64)
73+
if: ${{ contains(matrix.arch, 'x86_64') }}
74+
run: |
75+
bundle exec rake docker:build['services/${{ matrix.service }}:*'] PLATFORM='linux/x86_64'
76+
77+
# Then, build image for aarch64 which, being emulated under qemu, is slower
78+
#
79+
# Start by enabling qemu for aarch64
80+
- name: Enable aarch64 emulation (x86_64)
81+
if: ${{ contains(matrix.arch, 'aarch64') }}
82+
run: |
83+
docker run --privileged --rm tonistiigi/binfmt --install arm64
84+
- name: Build single-arch image (aarch64)
85+
if: ${{ contains(matrix.arch, 'aarch64') }}
86+
run: |
87+
bundle exec rake docker:build['services/${{ matrix.service }}:*'] PLATFORM='linux/aarch64'
88+
89+
# Finally, assemble multi-arch image for a combined push to the registry
90+
#
91+
# This reruns docker build but layers are in the cache, so it's fast
92+
- name: Log in to the Container Registry
93+
run: |
94+
echo ${{ secrets.GITHUB_TOKEN }} | docker login ${{ env.REGISTRY }} -u ${{ github.actor }} --password-stdin
95+
- name: Push release image (${{ join(matrix.arch, ', ') }})
96+
if: ${{ inputs.push }}
97+
run: |
98+
bundle exec rake docker:build['services/${{ matrix.service }}:*'] PLATFORM='${{ steps.vars.outputs.DOCKER_PLATFORMS }}' PUSH=true

.github/workflows/main.yml

+10-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ on:
66
- "**"
77

88
jobs:
9-
build:
10-
name: Build
9+
build-services:
10+
name: Build Services
11+
uses: ./.github/workflows/build-services.yml
12+
permissions:
13+
packages: write
14+
15+
build-ruby:
16+
name: Build Ruby
1117
uses: ./.github/workflows/build-ruby.yml
1218
permissions:
1319
packages: write
@@ -22,7 +28,8 @@ jobs:
2228
success:
2329
name: Success
2430
needs:
25-
- build
31+
- build-services
32+
- build-ruby
2633
- nix
2734
runs-on: ubuntu-24.04
2835
steps:

0 commit comments

Comments
 (0)