Skip to content
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

CI: Build/publish multi-architecture Docker images via ko #1124

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f647a0c
CI: Build/publish Docker images via ko
aknuds1 Feb 8, 2022
83b67e1
Don't use bingo
aknuds1 Feb 8, 2022
01445d5
Fix .ko.yaml
aknuds1 Feb 9, 2022
b0ff609
Fix image building with ko
aknuds1 Feb 9, 2022
cb2daba
Use Alpine as base image with ko
aknuds1 Feb 9, 2022
0db1bd2
Add ko to build-image.
pstibrany Feb 9, 2022
6a6e77b
Use Alpine as base image with ko
aknuds1 Feb 9, 2022
177e634
Push Mimir Docker manifest list without md5
aknuds1 Feb 9, 2022
56dbaee
Configure ko's image creation timestamp
aknuds1 Feb 9, 2022
2b15f9d
ko: Update build flags
aknuds1 Feb 9, 2022
7b45d2b
CI: Update build image
aknuds1 Feb 9, 2022
e8f01f2
CI: Build also tool manifest lists with ko
aknuds1 Feb 10, 2022
727d22f
Build Mimir and tool images with ko instead of Docker
aknuds1 Feb 10, 2022
175796f
push-images: Push images to registry
aknuds1 Feb 15, 2022
932cd24
push-images: Push mimir and mimirtool to docker.io
aknuds1 Feb 15, 2022
7d37a74
mimir-build-image: Upgrade ko
aknuds1 Feb 16, 2022
b4935ec
Makefile: Change load-*-image to tag image also as latest
aknuds1 Feb 16, 2022
5cc2cda
Fix image repository
aknuds1 Feb 16, 2022
44ab73b
Fix GitHub workflow
aknuds1 Apr 5, 2022
2bcac10
Upgrade to Alpine 3.15.4
aknuds1 Apr 5, 2022
673eed6
Add ko configurations for remaining images
aknuds1 Apr 5, 2022
b550424
Pin ko version in GitHub workflow
aknuds1 Apr 6, 2022
9b01659
Upgrade ko version
aknuds1 Apr 6, 2022
242cca9
Upgrade build image
aknuds1 Apr 6, 2022
11e51f8
Merge remote-tracking branch 'origin/main' into chore/build-multiplat…
aknuds1 Apr 25, 2022
657d674
Merge remote-tracking branch 'origin/main' into chore/build-multiplat…
aknuds1 Apr 27, 2022
f02e7d1
Merge remote-tracking branch 'origin/main' into chore/build-multiplat…
aknuds1 Apr 28, 2022
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
105 changes: 55 additions & 50 deletions .github/workflows/test-build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
lint:
runs-on: ubuntu-20.04
container:
image: grafana/mimir-build-image:update-go-1.17.8-8a996bb57
image: grafana/mimir-build-image:chore-build-multiplatform-images-3b8a0c120
steps:
- name: Checkout Repo
uses: actions/checkout@v2
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
lint-jsonnet:
runs-on: ubuntu-20.04
container:
image: grafana/mimir-build-image:update-go-1.17.8-8a996bb57
image: grafana/mimir-build-image:chore-build-multiplatform-images-3b8a0c120
steps:
- name: Checkout Repo
uses: actions/checkout@v2
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
test_group_id: [0, 1, 2, 3]
test_group_total: [4]
container:
image: grafana/mimir-build-image:update-go-1.17.8-8a996bb57
image: grafana/mimir-build-image:chore-build-multiplatform-images-3b8a0c120
steps:
- name: Checkout Repo
uses: actions/checkout@v2
Expand All @@ -107,7 +107,7 @@ jobs:
build-mimir:
runs-on: ubuntu-20.04
container:
image: grafana/mimir-build-image:update-go-1.17.8-8a996bb57
image: grafana/mimir-build-image:chore-build-multiplatform-images-3b8a0c120
steps:
- name: Checkout Repo
uses: actions/checkout@v2
Expand All @@ -117,26 +117,27 @@ jobs:
run: |
mkdir -p /go/src/github.com/grafana/mimir
ln -s $GITHUB_WORKSPACE/* /go/src/github.com/grafana/mimir
- name: Build Image
run: |
make BUILD_IN_CONTAINER=false ./cmd/mimir/.uptodate
- name: Save Images
- name: Build Images
run: |
mkdir /tmp/images
ln -s /tmp/images ./docker-images
make BUILD_IN_CONTAINER=false save-images
- name: Create Docker Images Archive
run: tar -cvf mimir-images.tar /tmp/images
- name: Upload Docker Images Artifact
export GIT_REVISION=$(git rev-parse --short HEAD)
export VERSION=$(cat "./VERSION" 2> /dev/null)
export GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
# Configure ko's image creation timestamp to correspond to the commit timestamp
export SOURCE_DATE_EPOCH=$(git show -s --format=%ct)
export KO_DOCKER_REPO=grafana
ko build -B --image-label org.opencontainers.image.title=mimir,org.opencontainers.image.source=https://github.com/grafana/mimir/tree/main/cmd/mimir,org.opencontainers.image.revision=${GIT_REVISION} --oci-layout-path mimir-oci-layout --platform=linux/amd64,linux/arm64 --push=false ./cmd/mimir
- name: Create Mimir OCI Image Layout Archive
run: tar -cvf mimir-oci-layout.tar mimir-oci-layout
- name: Upload Mimir OCI Image Layout
uses: actions/upload-artifact@v2
with:
name: Docker Images Mimir
path: ./mimir-images.tar
name: Mimir OCI Image Layout
path: ./mimir-oci-layout.tar

build-tools:
runs-on: ubuntu-20.04
container:
image: grafana/mimir-build-image:update-go-1.17.8-8a996bb57
image: grafana/mimir-build-image:chore-build-multiplatform-images-3b8a0c120
steps:
- name: Checkout Repo
uses: actions/checkout@v2
Expand All @@ -149,19 +150,23 @@ jobs:
- name: Build Images
# Build everything except mimir (run by build-mimir job) and build image (not managed by CI).
run: |
make list-image-targets | grep -v -E '/mimir-build-image/|/cmd/mimir/|/mimir-mixin-tools/' | xargs -I {} make BUILD_IN_CONTAINER=false {}
- name: Save Images
run: |
mkdir /tmp/images
ln -s /tmp/images ./docker-images
make BUILD_IN_CONTAINER=false save-images
- name: Create Docker Images Archive
run: tar -cvf tools-images.tar /tmp/images
- name: Upload Docker Image Artifact
IMAGES="mimirtool metaconvert query-tee"
export GIT_REVISION=$(git rev-parse --short HEAD)
export VERSION=$(cat "./VERSION" 2> /dev/null)
export GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
# Configure ko's image creation timestamp to correspond to the commit timestamp
export SOURCE_DATE_EPOCH=$(git show -s --format=%ct)
export KO_DOCKER_REPO=grafana
for name in ${IMAGES}; do
ko build -B --image-label org.opencontainers.image.title=${name},org.opencontainers.image.source=https://github.com/grafana/mimir/tree/main/cmd/${name},org.opencontainers.image.revision=${GIT_REVISION} --oci-layout-path ${name}-oci-layout --platform=linux/amd64,linux/arm64 --push=false ./cmd/${name}
done
- name: Create Tool OCI Image Layouts Archive
run: tar -cvf tool-oci-layouts.tar *-oci-layout
- name: Upload Tool OCI Image Layouts
uses: actions/upload-artifact@v2
with:
name: Docker Images Tools
path: ./tools-images.tar
name: Tool OCI Image Layouts
path: ./tool-oci-layouts.tar

integration:
needs: build-mimir
Expand All @@ -182,20 +187,24 @@ jobs:
uses: actions/checkout@v2
- name: Install Docker Client
run: sudo ./.github/workflows/scripts/install-docker.sh
# TODO: Work into image, since this job doesn't use the Mimir build image (which has ko installed)
# Keep revision in sync with that in Mimir build image
- name: Install ko
run: |
go install github.com/grafana/ko@37f6651b50ba1ecdfb691be4602472d4df8424e4
- name: Symlink Expected Path to Workspace
run: |
sudo mkdir -p /go/src/github.com/grafana/mimir
sudo ln -s $GITHUB_WORKSPACE/* /go/src/github.com/grafana/mimir
- name: Download Docker Images Mimir Artifacts
- name: Download Mimir OCI Image Layout
uses: actions/download-artifact@v2
with:
name: Docker Images Mimir
- name: Extract Docker Image Archive
run: tar -xvf mimir-images.tar -C /
- name: Load Docker Images
name: Mimir OCI Image Layout
- name: Load Mimir Docker Image
run: |
ln -s /tmp/images ./docker-images
make BUILD_IN_CONTAINER=false load-images
tar -xvf mimir-oci-layout.tar
IMAGE_TAG=$(make image-tag)
KO_DOCKER_REPO=grafana ko publish-layout -B --tags ${IMAGE_TAG} --local mimir mimir-oci-layout
- name: Preload Images
# We download docker images used by integration tests so that all images are available
# locally and the download time doesn't account in the test execution time, which is subject
Expand All @@ -216,7 +225,7 @@ jobs:
if: (startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/r') ) && github.event_name == 'push' && github.repository == 'grafana/mimir'
runs-on: ubuntu-20.04
container:
image: grafana/mimir-build-image:update-go-1.17.8-8a996bb57
image: grafana/mimir-build-image:chore-build-multiplatform-images-3b8a0c120
steps:
- name: Checkout Repo
uses: actions/checkout@v2
Expand All @@ -226,29 +235,25 @@ jobs:
run: |
mkdir -p /go/src/github.com/grafana/mimir
ln -s $GITHUB_WORKSPACE/* /go/src/github.com/grafana/mimir
- name: Download Docker Tool Images Artifacts
- name: Download Tool OCI Image Layouts
uses: actions/download-artifact@v2
with:
name: Docker Images Tools
- name: Download Docker Mimir Image Artifacts
name: Tool OCI Image Layouts
- name: Download Mimir OCI Image Layout
uses: actions/download-artifact@v2
with:
name: Docker Images Mimir
- name: Extract Docker Images
run: |
tar -xvf mimir-images.tar -C /
tar -xvf tools-images.tar -C /
- name: Load Images
name: Mimir OCI Image Layout
- name: Extract OCI Image Layouts
run: |
ln -s /tmp/images ./docker-images
make BUILD_IN_CONTAINER=false load-images
tar -xvf mimir-oci-layout.tar
tar -xvf tool-oci-layouts.tar
- name: Deploy
run: |
if [ -n "$DOCKER_PASSWORD" ]; then
printenv DOCKER_PASSWORD | docker login -u "$DOCKER_USERNAME" --password-stdin
printenv DOCKER_PASSWORD | ko login -u "$DOCKER_USERNAME" --password-stdin
fi
export IMAGE_TAG=$(make image-tag)
./push-images
export IMAGE_TAG=$(./tools/image-tag)
make ci-push-images
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
10 changes: 0 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
cmd/mimirtool/mimirtool
cmd/mimirtool/mimirtool_linux_amd64
cmd/mimirtool/mimirtool_linux_arm64
cmd/test-exporter/test-exporter
cmd/mimir/mimir
cmd/mimir/mimir_linux_amd64
cmd/mimir/mimir_linux_arm64
cmd/query-tee/query-tee
cmd/query-tee/query-tee_linux_amd64
cmd/query-tee/query-tee_linux_arm64
cmd/metaconvert/metaconvert
cmd/metaconvert/metaconvert_linux_amd64
cmd/metaconvert/metaconvert_linux_arm64
cmd/mimir-continuous-test/mimir-continuous-test
cmd/mimir-continuous-test/mimir-continuous-test_linux_amd64
cmd/mimir-continuous-test/mimir-continuous-test_linux_arm64
.uptodate
.pkg
.cache
Expand Down
49 changes: 49 additions & 0 deletions .ko.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# ko's standard base image causes our integration tests to fail, due to lack of permission to read
# TLS CA certificates installed in the filesystem it looks like.
defaultBaseImage: grafana/alpine:3.15.4

builds:
- id: mimir
aknuds1 marked this conversation as resolved.
Show resolved Hide resolved
main: ./cmd/mimir
env:
- CGO_ENABLED=0
ldflags:
- -X github.com/grafana/mimir/pkg/util/version.Branch={{.Env.GIT_BRANCH}}
- -X github.com/grafana/mimir/pkg/util/version.Revision={{.Env.GIT_REVISION}}
- -X github.com/grafana/mimir/pkg/util/version.Version={{.Env.VERSION}}
- -extldflags "-static"
- -s
- -w
- id: mimirtool
main: ./cmd/mimirtool
env:
- CGO_ENABLED=0
ldflags:
- -X github.com/grafana/mimir/pkg/util/version.Branch={{.Env.GIT_BRANCH}}
- -X github.com/grafana/mimir/pkg/util/version.Revision={{.Env.GIT_REVISION}}
- -X github.com/grafana/mimir/pkg/util/version.Version={{.Env.VERSION}}
- -extldflags "-static"
- -s
- -w
- id: metaconvert
main: ./cmd/metaconvert
env:
- CGO_ENABLED=0
ldflags:
- -X github.com/grafana/mimir/pkg/util/version.Branch={{.Env.GIT_BRANCH}}
- -X github.com/grafana/mimir/pkg/util/version.Revision={{.Env.GIT_REVISION}}
- -X github.com/grafana/mimir/pkg/util/version.Version={{.Env.VERSION}}
- -extldflags "-static"
- -s
- -w
- id: query-tee
main: ./cmd/query-tee
env:
- CGO_ENABLED=0
ldflags:
- -X github.com/grafana/mimir/pkg/util/version.Branch={{.Env.GIT_BRANCH}}
- -X github.com/grafana/mimir/pkg/util/version.Revision={{.Env.GIT_REVISION}}
- -X github.com/grafana/mimir/pkg/util/version.Version={{.Env.VERSION}}
- -extldflags "-static"
- -s
- -w
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
* [ENHANCEMENT] Alertmanager: added `insight=true` field to alertmanager dispatch logs. #1379
* [ENHANCEMENT] Store-gateway: Add the experimental ability to run index header operations in a dedicated thread pool. This feature can be configured using `-blocks-storage.bucket-store.index-header-thread-pool-size` and is disabled by default. #1660
* [ENHANCEMENT] Querier: wait until inflight queries are completed when shutting down queriers and running Mimir with query-scheduler. #1756
* [ENHANCEMENT] Docker images are now published as multi-architecture (AMD64/ARM64). #1124
* [BUGFIX] Query-frontend: do not shard queries with a subquery unless the subquery is inside a shardable aggregation function call. #1542
* [BUGFIX] Query-frontend: added `component=query-frontend` label to results cache memcached metrics to fix a panic when Mimir is running in single binary mode and results cache is enabled. #1704
* [BUGFIX] Mimir: services' status content-type is now correctly set to `text/html`. #1575
Expand Down
Loading