Skip to content

Commit ec86e8e

Browse files
committed
feat: add pi docker build
1 parent 7cdd8cd commit ec86e8e

File tree

2 files changed

+83
-15
lines changed

2 files changed

+83
-15
lines changed

.github/workflows/pi_build.yml

Lines changed: 74 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,98 @@ env:
1313
GH_TOKEN: ${{ secrets.GH_TOKEN }}
1414

1515
jobs:
16-
pi-build:
17-
name: 'Parent Images: Build Requirements'
16+
pi-compile:
17+
name: 'Parent Images: Compile Requirements'
1818
runs-on: ubuntu-latest
1919
env:
2020
PYTHON_VERSION: ${{ vars.PYTHON_VERSION }}
21+
outputs:
22+
updated_parent_types: ${{ steps.run-build.outputs.updated_parent_types }}
2123
steps:
2224
- name: Checkout repository
2325
uses: actions/checkout@v4
24-
with:
25-
ref: ${{ github.sha }}
26-
fetch-depth: 0
2726

2827
- name: GitHub Configuration
2928
run: git config --global url."https://oauth2:${{ secrets.GH_TOKEN }}@github.com".insteadOf https://github.com
3029

3130
- name: Clone cicd-deployment-scripts
3231
run: git clone --branch parent-images https://github.com/code-kern-ai/cicd-deployment-scripts.git
33-
32+
3433
- name: Set up Python
3534
uses: actions/setup-python@v5
3635
with:
3736
python-version: ${{ env.PYTHON_VERSION }}
38-
37+
3938
- name: Install dependencies
4039
run: python -m pip install pip-tools
41-
40+
4241
- name: Run build
42+
id: run-build
4343
run: |
4444
bash cicd-deployment-scripts/pi/build.sh \
45-
-p "${{ github.event.pull_request.number }}"
45+
-p "${{ github.event.pull_request.number }}"
46+
47+
pi-build:
48+
name: 'Parent Images: Build'
49+
runs-on: ubuntu-latest
50+
needs: pi-compile
51+
env:
52+
PYTHON_VERSION: ${{ vars.PYTHON_VERSION }}
53+
DEV_CONTAINER_REGISTRY: ${{ vars.DEV_CONTAINER_REGISTRY }}
54+
DEV_LOGIN_USERNAME: ${{ secrets.DEV_LOGIN_USERNAME }}
55+
DEV_LOGIN_PASSWORD: ${{ secrets.DEV_LOGIN_PASSWORD }}
56+
DOCKERHUB_CONTAINER_REGISTRY: ${{ vars.DOCKERHUB_CONTAINER_REGISTRY }}
57+
DOCKERHUB_LOGIN_USERNAME: ${{ secrets.DOCKERHUB_LOGIN_USERNAME }}
58+
DOCKERHUB_LOGIN_PASSWORD: ${{ secrets.DOCKERHUB_LOGIN_PASSWORD }}
59+
IMAGE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || github.event.pull_request.head.ref }}
60+
strategy:
61+
matrix:
62+
parent_image_type: ${{ toJson(needs.pi-compile.outputs.updated_parent_types) }}
63+
steps:
64+
- name: Dump needs context
65+
env:
66+
NEEDS_CONTEXT: ${{ toJson(needs) }}
67+
run: echo "$NEEDS_CONTEXT"
68+
69+
- name: Checkout repository
70+
uses: actions/checkout@v4
71+
with:
72+
repository: '${{ github.repository_owner }}/refinery-${{ matrix.parent_image_type }}-parent-image'
73+
submodules: 'true'
74+
75+
- name: Set up Docker Buildx
76+
uses: docker/setup-buildx-action@v3
77+
with:
78+
platforms: linux/amd64,linux/arm64
79+
80+
- name: Set up QEMU
81+
uses: docker/setup-qemu-action@v3
82+
with:
83+
platforms: arm64,arm
84+
85+
- name: Log into DEV registry
86+
uses: docker/login-action@v3
87+
with:
88+
registry: "${{ env.DEV_CONTAINER_REGISTRY }}"
89+
username: "${{ env.DEV_LOGIN_USERNAME }}"
90+
password: "${{ env.DEV_LOGIN_PASSWORD }}"
91+
92+
- name: Log into Docker Hub registry
93+
uses: docker/login-action@v3
94+
with:
95+
username: "${{ env.DOCKERHUB_LOGIN_USERNAME }}"
96+
password: "${{ env.DOCKERHUB_LOGIN_PASSWORD }}"
97+
98+
- name: Build & Push refinery-${{ matrix.parent_image_type }}-parent-image:amd64
99+
if: ${{ github.event_name != 'release' }}
100+
uses: docker/build-push-action@v5
101+
with:
102+
cache-from: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-image:dev-${{ matrix.parent_image_type }}-cache
103+
cache-to: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-image:dev-${{ matrix.parent_image_type }}-cache,mode=max,image-manifest=true
104+
platforms: linux/amd64
105+
file: Dockerfile
106+
tags: ${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-image:dev-${{ matrix.parent_image_type }}
107+
push: true
108+
build-args: |
109+
platform=linux/amd64
110+
label=dockerfile-path=https://github.com/refinery-${{ matrix.parent_image_type }}-parent-image/blob/${{ github.sha }}/Dockerfile

pi/build.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,24 @@ do
1212
done
1313

1414
UPDATED_FILES=$(gh pr diff $PR_NUMBER --name-only)
15+
UPDATED_PARENT_TYPES=()
1516
while IFS= read -r file; do
1617
if [[ $file != requirements/* ]] || [[ $file != *.in ]]; then
1718
continue
1819
fi
1920

2021
parent_image_type=$(basename $file | sed 's|-requirements.in||g')
22+
UPDATED_PARENT_TYPES+=($parent_image_type)
2123

2224
echo "::group::Compiling $parent_image_type-requirements.in"
2325
pip-compile requirements/$parent_image_type-requirements.in
24-
25-
echo "Running pip install for $parent_image_type"
26-
python -m venv ./venv/
27-
source ./venv/bin/activate
28-
pip install -r requirements/$parent_image_type-requirements.txt
29-
rm -rf ./venv/
3026
echo "::endgroup::"
3127

3228
done <<< "$UPDATED_FILES"
29+
30+
JSON=""
31+
for parent_image_type in "${UPDATED_PARENT_TYPES[@]}"; do
32+
JSON+="\"$parent_image_type\","
33+
done
34+
JSON="[${JSON::-1}]"
35+
echo "updated_parent_types=$JSON" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)