Skip to content

Commit 56aa90f

Browse files
mirkokurtrobgee86stefanotorneorjtokenring
committed
First commit
Co-authored-by: Roberto Gazia <[email protected]> Co-authored-by: Stefano Torneo <[email protected]> Co-authored-by: Marco Colombo <[email protected]>
0 parents  commit 56aa90f

File tree

224 files changed

+190367
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

224 files changed

+190367
-0
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: Calculate Docker Image Size
2+
3+
on:
4+
workflow_dispatch:
5+
issue_comment:
6+
types: [created]
7+
8+
permissions:
9+
contents: read
10+
pull-requests: write
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
env:
16+
PYTHON_VERSION: '3.13'
17+
TASKFILE_VERSION: 'v3.44.0'
18+
TASKFILE_PATH: '/home/runner/go/bin'
19+
if: |
20+
github.event_name == 'workflow_dispatch' ||
21+
(github.event_name == 'issue_comment' && github.event.comment.body == '/calculate-size' && github.event.issue.pull_request)
22+
23+
services:
24+
registry:
25+
image: registry:3
26+
ports:
27+
- 5000:5000
28+
29+
steps:
30+
- name: Checkout Code
31+
uses: actions/checkout@v4
32+
33+
- name: Get PR Information
34+
id: pr_info
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
run: |
38+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
39+
echo "Searching for PR from branch '${{ github.ref_name }}'..."
40+
PR_NUMBER=$(gh pr list --state open --head "${{ github.ref_name }}" --json number --jq '.[0].number // empty')
41+
else
42+
# For issue_comment, the PR number is in the event context
43+
PR_NUMBER=${{ github.event.issue.number }}
44+
fi
45+
46+
if [ -z "$PR_NUMBER" ]; then
47+
echo "Could not find an associated open pull request."
48+
else
49+
echo "Found PR #$PR_NUMBER"
50+
fi
51+
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
52+
53+
- name: Checkout PR Branch (for comment trigger)
54+
if: github.event_name == 'issue_comment'
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
run: |
58+
gh pr checkout ${{ steps.pr_info.outputs.pr_number }}
59+
60+
- name: Set up Python
61+
uses: actions/setup-python@v5
62+
with:
63+
python-version: ${{ env.PYTHON_VERSION }}
64+
cache: 'pip'
65+
cache-dependency-path: 'pyproject.toml'
66+
67+
- name: Install and build library
68+
run: |
69+
which task || curl -sSfL https://taskfile.dev/install.sh | sh -s -- -b ${{ env.TASKFILE_PATH }} ${{ env.TASKFILE_VERSION }}
70+
export PATH="${{ env.TASKFILE_PATH }}:$PATH"
71+
task init:ci
72+
task build-dev
73+
cp ./dist/arduino*.whl ./containers/python-apps-base/
74+
75+
- name: Set up QEMU
76+
uses: docker/setup-qemu-action@v3
77+
78+
- name: Setup Docker buildx
79+
uses: docker/setup-buildx-action@v3
80+
with:
81+
driver-opts: network=host
82+
83+
- name: Build the base Docker image
84+
uses: docker/build-push-action@v6
85+
with:
86+
context: ./containers/python-base
87+
file: ./containers/python-base/Dockerfile
88+
tags: localhost:5000/app-bricks/python-base:latest
89+
platforms: linux/arm64
90+
push: true
91+
cache-from: type=gha
92+
cache-to: type=gha,mode=max
93+
94+
- name: Build the apps base Docker image
95+
uses: docker/build-push-action@v6
96+
with:
97+
context: ./containers/python-apps-base
98+
file: ./containers/python-apps-base/Dockerfile
99+
tags: localhost:5000/app-bricks/python-apps-base:latest
100+
platforms: linux/arm64
101+
push: true
102+
build-args: |
103+
REGISTRY=localhost:5000/
104+
cache-from: type=gha
105+
cache-to: type=gha,mode=max
106+
107+
- name: Pull images for inspection
108+
run: |
109+
docker image pull --platform linux/arm64 localhost:5000/app-bricks/python-base:latest
110+
docker image pull --platform linux/arm64 localhost:5000/app-bricks/python-apps-base:latest
111+
112+
- name: Add image sizes to Job Summary
113+
run: |
114+
echo "## Docker Image Sizes" >> $GITHUB_STEP_SUMMARY
115+
echo "" >> $GITHUB_STEP_SUMMARY
116+
echo "| Image | Size |" >> $GITHUB_STEP_SUMMARY
117+
echo "|-------|------|" >> $GITHUB_STEP_SUMMARY
118+
echo "| app-bricks/python-base | $(docker images 'localhost:5000/app-bricks/python-base:latest' --format '{{.Size}}') |" >> $GITHUB_STEP_SUMMARY
119+
echo "| app-bricks/python-apps-base | $(docker images 'localhost:5000/app-bricks/python-apps-base:latest' --format '{{.Size}}') |" >> $GITHUB_STEP_SUMMARY
120+
121+
- name: Comment on PR with image sizes
122+
if: steps.pr_info.outputs.pr_number != ''
123+
env:
124+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125+
run: |
126+
SIZE1=$(docker images 'localhost:5000/app-bricks/python-base:latest' --format '{{.Size}}')
127+
SIZE2=$(docker images 'localhost:5000/app-bricks/python-apps-base:latest' --format '{{.Size}}')
128+
gh pr comment ${{ steps.pr_info.outputs.pr_number }} --body-file - <<EOF
129+
## Docker Image Sizes
130+
131+
| Image | Size |
132+
|-------|------|
133+
| app-bricks/python-base | $SIZE1 |
134+
| app-bricks/python-apps-base | $SIZE2 |
135+
EOF

.github/workflows/ci_checks.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Run Tests and Check Documentation
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
ci-checks:
8+
runs-on: ubuntu-latest
9+
env:
10+
PYTHON_VERSION: '3.13'
11+
TASKFILE_VERSION: 'v3.44.0'
12+
TASKFILE_PATH: '/home/runner/go/bin'
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: ${{ env.PYTHON_VERSION }}
21+
22+
- name: Install dependencies
23+
run: |
24+
which task || curl -sSfL https://taskfile.dev/install.sh | sh -s -- -b ${{ env.TASKFILE_PATH }} ${{ env.TASKFILE_VERSION }}
25+
export PATH="${{ env.TASKFILE_PATH }}:$PATH"
26+
task init:ci
27+
28+
- name: Check code formatting
29+
run: |
30+
export PATH="${{ env.TASKFILE_PATH }}:$PATH"
31+
task fmt > /dev/null 2>&1
32+
if git diff --quiet; then
33+
echo "Code is properly formatted."
34+
else
35+
echo "Please format the code by running 'task fmt'."
36+
exit 1
37+
fi
38+
39+
- name: Check linting
40+
run: |
41+
export PATH="${{ env.TASKFILE_PATH }}:$PATH"
42+
task lint > /dev/null 2>&1
43+
if git diff --quiet; then
44+
echo "Code is properly linted."
45+
else
46+
echo "Please lint the code by running 'task lint'."
47+
exit 1
48+
fi
49+
50+
- name: Run tests
51+
run: |
52+
export PATH="${{ env.TASKFILE_PATH }}:$PATH"
53+
task test
54+
55+
- name: Check license headers and files
56+
run: |
57+
export PATH="${{ env.TASKFILE_PATH }}:$PATH"
58+
task license > /dev/null 2>&1
59+
if git diff --quiet; then
60+
echo "License data is up to date!"
61+
else
62+
echo "Please update license headers and files by running 'task license'."
63+
exit 1
64+
fi
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: BASE - build Python base image
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "base/*"
8+
9+
env:
10+
GHCR_REGISTRY: ghcr.io
11+
REPO: app-bricks/python-base
12+
13+
permissions:
14+
contents: write
15+
packages: write
16+
id-token: write
17+
18+
jobs:
19+
build:
20+
21+
runs-on: ubuntu-latest
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
include:
26+
- dockerfile: ./containers/python-base/Dockerfile
27+
context: ./containers/python-base
28+
max-parallel: 2
29+
30+
steps:
31+
- name: Log into ${{ env.GHCR_REGISTRY }} registry
32+
uses: docker/login-action@v3
33+
with:
34+
registry: ${{ env.GHCR_REGISTRY }}
35+
username: ${{ github.repository_owner }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Checkout repository
39+
uses: actions/checkout@v4
40+
41+
#Add support for more platforms with QEMU
42+
- name: Set up QEMU
43+
uses: docker/setup-qemu-action@v3
44+
with:
45+
platforms: linux/arm64
46+
47+
- name: Setup Docker buildx
48+
uses: docker/setup-buildx-action@v3
49+
50+
# Extract metadata from the GitHub context
51+
- name: Extract Docker metadata
52+
id: meta
53+
uses: docker/metadata-action@v5
54+
with:
55+
tags: |
56+
type=raw,value=latest,enable=true
57+
type=match,pattern=base\/(.*),group=1
58+
images: |
59+
${{ env.GHCR_REGISTRY }}/arduino/${{ env.REPO }}
60+
61+
# Build and push Docker image with Buildx (don't push on PR)
62+
- name: Build and push Docker image
63+
id: build-and-push
64+
uses: docker/build-push-action@v6
65+
with:
66+
context: ${{ matrix.context }}
67+
file: ${{ matrix.dockerfile }}
68+
push: true
69+
tags: ${{ steps.meta.outputs.tags }}
70+
labels: ${{ steps.meta.outputs.labels }}
71+
platforms: linux/arm64
72+
cache-from: type=gha
73+
cache-to: type=gha,mode=max
74+
provenance: false
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: AI Containers Release - Build and Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- "ai/*"
7+
8+
env:
9+
GHCR_REGISTRY: ghcr.io
10+
GHCR_DESTINATION_ORG: ghcr.io/arduino
11+
GH_DESTINATION_REPO: https://github.com/arduino/app-bricks-py
12+
13+
permissions:
14+
contents: write
15+
packages: write
16+
id-token: write
17+
pull-requests: write
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-latest
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
include:
26+
- dockerfile: ./containers/ei-models-runner/Dockerfile
27+
context: ./containers/ei-models-runner
28+
image: /app-bricks/ei-models-runner
29+
max-parallel: 1
30+
31+
steps:
32+
- name: Log into destination image registry ${{ env.GHCR_REGISTRY }}
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ${{ env.GHCR_REGISTRY }}
36+
username: ${{ github.repository_owner }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Checkout repository
40+
uses: actions/checkout@v4
41+
42+
# Add support for more platforms with QEMU
43+
- name: Set up QEMU
44+
uses: docker/setup-qemu-action@v3
45+
with:
46+
platforms: linux/arm64
47+
48+
- name: Setup Docker buildx
49+
uses: docker/setup-buildx-action@v3
50+
51+
# Extract metadata from the GitHub context
52+
- name: Extract Docker metadata
53+
id: meta
54+
uses: docker/metadata-action@v5
55+
with:
56+
tags: |
57+
type=match,pattern=ai\/(.*),group=1
58+
images: |
59+
${{ env.GHCR_DESTINATION_ORG }}${{ matrix.image }}
60+
labels: |
61+
org.opencontainers.image.source=${{ env.GH_DESTINATION_REPO}}
62+
org.opencontainers.image.url=${{ env.GH_DESTINATION_REPO}}
63+
64+
# Build and push Docker image with Buildx (don't push on PR)
65+
- name: Build and push Docker image
66+
id: build-and-push
67+
uses: docker/build-push-action@v6
68+
with:
69+
context: ${{ matrix.context }}
70+
file: ${{ matrix.dockerfile }}
71+
push: true
72+
tags: ${{ steps.meta.outputs.tags }}
73+
labels: ${{ steps.meta.outputs.labels }}
74+
platforms: linux/arm64
75+
cache-from: type=gha
76+
cache-to: type=gha,mode=max
77+
provenance: false
78+
79+
# Images are ready. Now modify files and create a PR.
80+
- name: Set up Python
81+
uses: actions/setup-python@v5
82+
with:
83+
python-version: "3.13"
84+
85+
- name: Update AI container images references
86+
env:
87+
PUBLIC_IMAGE_REGISTRY_BASE: ${{ env.GHCR_DESTINATION_ORG }}/
88+
run: |
89+
echo "##### Installing libasound2-dev..."
90+
sudo apt install libasound2-dev
91+
echo "##### Installing build dependencies..."
92+
pip install --upgrade pip build
93+
echo "##### Installing module as installable module..."
94+
pip install -e ".[dev]"
95+
echo "##### Update references..."
96+
arduino-bricks-update-ai-container-ref -v ${{ steps.meta.outputs.version }} -r ${{ env.GHCR_DESTINATION_ORG }}/
97+
98+
- name: Configure Git
99+
run: |
100+
git config user.name "AppLab Actions Bot"
101+
git config user.email "[email protected]"
102+
103+
- name: Create new branch name
104+
run: |
105+
BRANCH_NAME="ai-container-release-$(date +"%Y%m%d%H%M%S")"
106+
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
107+
id: push_changes
108+
109+
- name: Create Pull Request
110+
uses: peter-evans/create-pull-request@v6
111+
with:
112+
token: ${{ secrets.GITHUB_TOKEN }}
113+
commit-message: "feat: update AI container images references"
114+
title: "[RELEASE BOT] Update AI container images references"
115+
body: |
116+
This PR was automatically generated by a GitHub Actions workflow.
117+
It includes modifications to update AI container images references after new release.
118+
branch: ${{ steps.push_changes.outputs.branch_name }}
119+
base: main # Target branch for the PR
120+
draft: false

0 commit comments

Comments
 (0)