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

(chore) #485: Implement Multi-Architecture Docker Image Build and Deployment with Debian Base Image #517

Closed
wants to merge 93 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
84b4359
Create multiarch-dockerhub.yml
Jul 20, 2024
560da48
Update multiarch-dockerhub.yml
Jul 20, 2024
ae7880b
Update multiarch-dockerhub.yml
Jul 21, 2024
f8cdb0d
Create docker-compose-multiarch.yml
Jul 21, 2024
e8a2cef
Update docker-compose-multiarch.yml
Jul 21, 2024
91ab530
Update docker-compose.sh
Jul 21, 2024
e3dfd6d
Update multiarch-dockerhub.yml
Jul 21, 2024
07c8d3d
Update multiarch-dockerhub.yml
Jul 21, 2024
5df64d2
Update multiarch-dockerhub.yml
Jul 21, 2024
9e520d9
Update multiarch-dockerhub.yml
Jul 21, 2024
26b1ea5
Update docker-compose.sh
Jul 21, 2024
42c0aa8
Update docker-compose.sh
Jul 21, 2024
d528295
Update docker-compose.sh
Jul 21, 2024
000a293
Update multiarch-dockerhub.yml
Jul 21, 2024
4a82515
Update multiarch-dockerhub.yml
Jul 21, 2024
19b820e
Update docker-compose-multiarch.yml
Jul 21, 2024
cff3255
Update multiarch-dockerhub.yml
Jul 21, 2024
a0bbcd9
Update docker-compose.sh
Jul 21, 2024
479ef6b
Update multiarch-dockerhub.yml
Jul 21, 2024
fd87945
Delete .github/workflows/clang-format.yml
Jul 21, 2024
baa1d4e
Update docker-compose.sh
Jul 21, 2024
0607bf4
Create clang-format.yml
Jul 21, 2024
e0fed91
Update multiarch-dockerhub.yml
Jul 21, 2024
7fc93bf
Update multiarch-dockerhub.yml
Jul 21, 2024
a1b75a2
Update multiarch-dockerhub.yml
Jul 21, 2024
a568bff
Update multiarch-dockerhub.yml
Jul 21, 2024
711c693
Create test.yml
Jul 21, 2024
61068a6
Delete .github/workflows/test.yml
Jul 21, 2024
8c9fc58
Update docker-compose.sh
Jul 22, 2024
d883786
Update docker-compose.sh
Jul 22, 2024
8d265d4
Update docker-compose.sh
Jul 22, 2024
c1c4863
Update docker-compose.sh
Jul 22, 2024
e40a5f9
Update multiarch-dockerhub.yml
Jul 22, 2024
a2593ee
Update docker-compose.sh
Jul 22, 2024
0a295e5
Update multiarch-dockerhub.yml
Jul 22, 2024
34f3fc3
Update multiarch-dockerhub.yml
Jul 22, 2024
7de6b7d
Update multiarch-dockerhub.yml
Jul 22, 2024
4b42ab8
Update docker-compose.sh
Jul 22, 2024
82cba5a
Update docker-compose.sh
Jul 22, 2024
b34ee5b
Update docker-compose.sh
Jul 22, 2024
d285120
Update multiarch-dockerhub.yml
Jul 22, 2024
f77ea33
Update docker-compose.sh
Jul 22, 2024
11e6881
Update docker-compose.sh
Jul 22, 2024
3d4ad4d
Update docker-compose.sh
Jul 22, 2024
6aa1caa
Update docker-compose-multiarch.yml
Jul 22, 2024
e895c03
Update multiarch-dockerhub.yml
Jul 22, 2024
059b393
Update docker-compose.sh
Jul 23, 2024
134bc0b
Update docker-compose-multiarch.yml
Jul 23, 2024
657764b
Update docker-compose.sh
Jul 23, 2024
0c29865
Update docker-compose.sh
Jul 23, 2024
708bc89
Update docker-compose.sh
Jul 23, 2024
2bfbee9
Update docker-compose.sh
Jul 23, 2024
e3cd3c3
Update docker-compose-multiarch.yml
Jul 23, 2024
228bbcb
Update docker-compose.sh
Jul 23, 2024
0e01e2b
Update docker-compose.sh
Jul 23, 2024
e5255a7
Update docker-compose.sh
Jul 23, 2024
2298933
Update docker-compose-multiarch.yml
Jul 23, 2024
3727ff7
Update docker-compose-multiarch.yml
Jul 23, 2024
f2f0588
Update docker-compose-multiarch.yml
Jul 23, 2024
faeefa5
Update docker-compose.yml
Jul 23, 2024
75fa26a
Update multiarch-dockerhub.yml
Jul 23, 2024
c47a255
Update docker-compose-multiarch.yml
Jul 23, 2024
6b018aa
Update docker-compose-multiarch.yml
Jul 23, 2024
db44db5
Update docker-compose-multiarch.yml
Jul 23, 2024
02c9b93
Update multiarch-dockerhub.yml
Jul 23, 2024
477dab0
Update .env
Jul 23, 2024
88b8723
Update CMakeLists.txt
Jul 23, 2024
b88c6b3
Update multiarch-dockerhub.yml
Jul 23, 2024
f57d685
Update multiarch-dockerhub.yml
Jul 23, 2024
52e15d4
Update docker-compose.sh
Jul 23, 2024
9210967
Update multiarch-dockerhub.yml
Jul 23, 2024
30ef084
Update multiarch-dockerhub.yml
Jul 23, 2024
d0778fb
Update multiarch-dockerhub.yml
Jul 23, 2024
44fb159
Update CMakeLists.txt
Jul 23, 2024
28d8e9d
Update multiarch-dockerhub.yml
Jul 29, 2024
8af4f67
Update multiarch-dockerhub.yml
Jul 29, 2024
c9e79f7
Update multiarch-dockerhub.yml
Aug 7, 2024
ebf80cd
Update multiarch-dockerhub.yml
Aug 7, 2024
8139fe3
Update multiarch-dockerhub.yml
Aug 7, 2024
3f87222
Update docker-compose-multiarch.yml
Aug 7, 2024
b6ff13c
Update multiarch-dockerhub.yml
Aug 7, 2024
913402c
Update multiarch-dockerhub.yml
Aug 7, 2024
4b5f588
Update multiarch-dockerhub.yml
Aug 7, 2024
93c8e88
Update docker-compose-multiarch.yml
Aug 7, 2024
47d9ac8
Update multiarch-dockerhub.yml
Aug 7, 2024
4231410
Update docker-compose-multiarch.yml
Aug 7, 2024
05cea79
Update multiarch-dockerhub.yml
Aug 7, 2024
f6bb736
Update multiarch-dockerhub.yml
Aug 7, 2024
80c226d
Update .env
Aug 7, 2024
c5f5384
Update .env
Aug 7, 2024
3c23bb3
Update multiarch-dockerhub.yml
Aug 7, 2024
a063161
Update docker-compose.yml
Aug 7, 2024
579d428
Update multiarch-dockerhub.yml
Aug 7, 2024
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
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ COMPOSE_PROJECT_NAME='metacall'
# Configure default variables
METACALL_PATH=/usr/local/metacall
METACALL_BUILD_TYPE=relwithdebinfo
METACALL_BASE_IMAGE=debian:trixie-slim # debian:bookworm-slim # ubuntu:jammy # ubuntu:mantic # alpine:3.17
METACALL_BASE_IMAGE=debian:bookworm-slim # debian:bookworm-slim # ubuntu:jammy # ubuntu:mantic # alpine:3.17
97 changes: 97 additions & 0 deletions .github/workflows/multiarch-dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Build and Push Docker Image

on:
pull_request:
workflow_dispatch:
push:
branches:
- master
tags:
- 'v*.*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
IMAGE_NAME: index.docker.io/metacall/core

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm/v6
- linux/arm/v7
- linux/arm64

steps:
- name: Checkout the code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}

- name: Prepare
run: |
echo "METACALL_PLATFORM=${{ matrix.platform //\//- }}" >> $GITHUB_ENV

- name: Build and Push Multi-Architecture Images
run: |
bash ./docker-compose.sh build-multiarch

# - name: Export digest
# id: export_digest
# run: |
# digest=$(docker inspect --format='{{index .RepoDigests 0}}' ${{ env.IMAGE_NAME }}:latest)
# echo "DIGEST=${digest#*:}" >> $GITHUB_ENV

- name: Logout from DockerHub
run: docker logout

# create-manifest:
# needs: build
# steps:
# - name: Checkout the code
# uses: actions/checkout@v3

# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3

# - name: Login to DockerHub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

# - name: Create manifest list and push
# run: |
# docker buildx imagetools create --tag ${{ env.IMAGE_NAME }}:latest \
# --tag ${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }} \
# ${{ env.IMAGE_NAME }}@sha256:${{ env.DIGEST }}

- name: Inspect image
run: docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:latest

- name: Logout from DockerHub
run: docker logout
34 changes: 34 additions & 0 deletions docker-compose-multiarch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: "3.7"

services:
deps:
platform:
- ${METACALL_PLATFORM}
build:
context: .
dockerfile: tools/deps/Dockerfile
image: metacall/core:deps

dev:
platform:
- ${METACALL_PLATFORM}
build:
context: .
dockerfile: tools/dev/Dockerfile
image: metacall/core:dev

runtime:
platform:
- ${METACALL_PLATFORM}
build:
context: .
dockerfile: tools/runtime/Dockerfile
image: metacall/core:runtime

cli:
platform:
- ${METACALL_PLATFORM}
build:
context: .
dockerfile: tools/cli/Dockerfile
image: metacall/core:cli
35 changes: 35 additions & 0 deletions docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,38 @@ sub_build() {
$DOCKER_COMPOSE -f docker-compose.yml build --force-rm cli
}

sub_build_multiarch() {

# Enable BuildKit and set Docker CLI build for Compose
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1

if [ -z "$IMAGE_NAME" ]; then
echo "Error: IMAGE_NAME variable not defined"
exit 1
fi

# Create a new builder instance and use it
docker buildx create --name mybuilder --use

# Inspect the builder instance to ensure it's correctly set up
docker buildx inspect --bootstrap

# Build multi-architecture images using Buildx
ln -sf tools/deps/.dockerignore .dockerignore
$DOCKER_COMPOSE -f docker-compose.yml -f docker-compose-multiarch.yml build --force-rm deps

ln -sf tools/dev/.dockerignore .dockerignore
$DOCKER_COMPOSE -f docker-compose.yml -f docker-compose-multiarch.yml build --force-rm dev

ln -sf tools/runtime/.dockerignore .dockerignore
$DOCKER_COMPOSE -f docker-compose.yml -f docker-compose-multiarch.yml build --force-rm runtime

ln -sf tools/cli/.dockerignore .dockerignore
$DOCKER_COMPOSE -f docker-compose.yml -f docker-compose-multiarch.yml build --force-rm cli

}

# Build MetaCall Docker Compose without cache (link manually dockerignore files)
sub_rebuild() {
ln -sf tools/deps/.dockerignore .dockerignore
Expand Down Expand Up @@ -311,6 +343,9 @@ case "$1" in
build)
sub_build
;;
build-multiarch)
sub_build_multiarch
;;
rebuild)
sub_rebuild
;;
Expand Down
Loading