Skip to content

Commit 4b94caa

Browse files
authored
Fix all possible docker issues wrt local and CI builds (kadalu#639)
Buildx: 1. Things are simpler if building on an amd64 platform for amd64 image 2. `--platform` and `--load` is must while building images on non amd64 host in `build.sh` 3. `--load` will not work if `--platform` has more than one entry 4. However, `--push` and `--load` work if `--platform` has only one entry and `--load` is used while building dependent image in the next step to first pull from local docker 5. If `--platform` contains more than one entry, it's mandatory to use `--push` 6. Faulty release for 0.8.5 non amd64 is likely due to existing cache and `no-cache` is set for release CI Fixes: kadalu#633 Signed-off-by: Leela Venkaiah G <[email protected]>
1 parent f997b97 commit 4b94caa

File tree

7 files changed

+28
-8
lines changed

7 files changed

+28
-8
lines changed

.github/workflows/on-pr-merge.yml

+6
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
file: extras/Dockerfile.builder
5757
platforms: linux/amd64
5858
push: false
59+
load: true
5960
tags: |
6061
docker.io/kadalu/builder:latest
6162
build-args: |
@@ -73,6 +74,7 @@ jobs:
7374
platforms: linux/amd64
7475
target: prod
7576
push: true
77+
load: true
7678
tags: |
7779
docker.io/kadalu/kadalu-csi:${{ github.sha }}
7880
docker.io/kadalu/kadalu-csi:devel
@@ -91,6 +93,7 @@ jobs:
9193
platforms: linux/amd64
9294
target: prod
9395
push: true
96+
load: true
9497
tags: |
9598
docker.io/kadalu/kadalu-operator:${{ github.sha }}
9699
docker.io/kadalu/kadalu-operator:devel
@@ -109,6 +112,7 @@ jobs:
109112
platforms: linux/amd64
110113
target: prod
111114
push: true
115+
load: true
112116
tags: |
113117
docker.io/kadalu/kadalu-server:${{ github.sha }}
114118
docker.io/kadalu/kadalu-server:devel
@@ -141,6 +145,7 @@ jobs:
141145
platforms: linux/amd64
142146
target: prod
143147
push: true
148+
load: true
144149
tags: |
145150
docker.io/kadalu/test-io:${{ github.sha }}
146151
docker.io/kadalu/test-io:devel
@@ -160,6 +165,7 @@ jobs:
160165
platforms: linux/amd64
161166
target: prod
162167
push: true
168+
load: true
163169
tags: |
164170
docker.io/kadalu/test-csi:${{ github.sha }}
165171
docker.io/kadalu/test-csi:devel

.github/workflows/on-release-tag.yml

+6
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ jobs:
7272
overwrite: true
7373
file_glob: true
7474

75+
# Use no-cache while building images as they may break release and they are built
76+
# only during release so the delay/bandwidth worth the time
7577
multi-arch-build-for-release:
7678
runs-on: ubuntu-latest
7779
steps:
@@ -111,6 +113,7 @@ jobs:
111113
file: extras/Dockerfile.builder
112114
platforms: linux/amd64,linux/arm64,linux/arm/v7
113115
push: true
116+
no-cache: true
114117
tags: |
115118
docker.io/kadalu/builder:${{ steps.vars.outputs.tag }}
116119
docker.io/kadalu/builder:latest
@@ -129,6 +132,7 @@ jobs:
129132
platforms: linux/amd64,linux/arm64,linux/arm/v7
130133
target: prod
131134
push: true
135+
no-cache: true
132136
tags: |
133137
docker.io/kadalu/kadalu-csi:${{ steps.vars.outputs.tag }}
134138
docker.io/kadalu/kadalu-csi:latest
@@ -148,6 +152,7 @@ jobs:
148152
platforms: linux/amd64,linux/arm64,linux/arm/v7
149153
target: prod
150154
push: true
155+
no-cache: true
151156
tags: |
152157
docker.io/kadalu/kadalu-server:${{ steps.vars.outputs.tag }}
153158
docker.io/kadalu/kadalu-server:latest
@@ -167,6 +172,7 @@ jobs:
167172
platforms: linux/amd64,linux/arm64,linux/arm/v7
168173
target: prod
169174
push: true
175+
no-cache: true
170176
tags: |
171177
docker.io/kadalu/kadalu-operator:${{ steps.vars.outputs.tag }}
172178
docker.io/kadalu/kadalu-operator:latest

build.sh

+8-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ KADALU_VERSION="${KADALU_VERSION}"
1111
RUNTIME_CMD=${RUNTIME_CMD:-docker}
1212
# Use buildx for docker to simulate release script in github workflow
1313
# Requires Docker >=v19.03
14-
build="buildx build"
14+
PLATFORM=$(uname -m | sed 's|aarch64|arm64|' | sed 's|x86_64|amd64|' | sed 's|armv7l|arm/v7|')
15+
build="buildx build --platform linux/$PLATFORM --load"
1516
if [[ "${RUNTIME_CMD}" == "buildah" ]]; then
1617
build="bud"
1718
fi
@@ -21,7 +22,7 @@ fi
2122
# only look for those tags. For version info on non-release commits, we want to
2223
# include the git commit info as a "build" suffix ("+stuff" at the end). There
2324
# is also special casing here for when no tags match.
24-
VERSION_GLOB="v[0-9]*"
25+
VERSION_GLOB="[0-9]*"
2526
# Get the nearest "version" tag if one exists. If not, this returns the full
2627
# git hash
2728
NEAREST_TAG="$(git describe --always --tags --match "$VERSION_GLOB" --abbrev=0)"
@@ -85,8 +86,11 @@ $RUNTIME_CMD $build \
8586
-t "${DOCKER_USER}/builder:latest" "${build_args[@]}" \
8687
--network host -f extras/Dockerfile.builder .
8788

88-
echo "Building images kadalu-\$service:${VERSION}";
89-
89+
echo "Building kadalu-server with version tag as ${VERSION}";
9090
build_container "kadalu-server" "server/Dockerfile" ${KADALU_VERSION}
91+
92+
echo "Building kadalu-csi with version tag as ${VERSION}";
9193
build_container "kadalu-csi" "csi/Dockerfile" ${KADALU_VERSION}
94+
95+
echo "Building kadalu-operator with version tag as ${VERSION}";
9296
build_container "kadalu-operator" "operator/Dockerfile" ${KADALU_VERSION}

csi/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ ENV PATH="/kadalu/bin:/opt/bin:/opt/sbin:$PATH"
66

77
COPY csi-requirements.txt /tmp/
88

9-
RUN python3 -m pip install -r /tmp/csi-requirements.txt
9+
RUN python3 -m pip install -r /tmp/csi-requirements.txt && \
10+
grep -Po '^[\w\.-]*(?=)' /tmp/csi-requirements.txt | xargs -I pkg python3 -m pip show pkg | grep -P '^(Name|Version|Location)'
1011

1112
FROM python:3.9.6-slim-bullseye as prod
1213
ENV DEBIAN_FRONTEND=noninteractive

extras/Dockerfile.builder

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ RUN apt-get update -yq && \
1919
2020
COPY builder-requirements.txt /tmp/
2121
RUN python3 -m venv $VIRTUAL_ENV && cd $VIRTUAL_ENV && \
22-
python3 -m pip install -r /tmp/builder-requirements.txt
22+
python3 -m pip install -r /tmp/builder-requirements.txt && \
23+
grep -Po '^[\w\.-]*(?=)' /tmp/builder-requirements.txt | xargs -I pkg python3 -m pip show pkg | grep -P '^(Name|Version|Location)'
2324
2425
RUN sed -i "s/include-system-site-packages = false/include-system-site-packages = true/g" /kadalu/pyvenv.cfg
2526

operator/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ ENV PATH="/kadalu/bin:/opt/bin:/opt/sbin:$PATH"
66

77
COPY operator-requirements.txt /tmp/
88

9-
RUN python3 -m pip install -r /tmp/operator-requirements.txt
9+
RUN python3 -m pip install -r /tmp/operator-requirements.txt && \
10+
grep -Po '^[\w\.-]*(?=)' /tmp/operator-requirements.txt | xargs -I pkg python3 -m pip show pkg | grep -P '^(Name|Version|Location)'
1011

1112
FROM python:3.9.6-slim-bullseye as prod
1213

server/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ ENV PATH="/kadalu/bin:/opt/bin:/opt/sbin:$PATH"
66

77
COPY server-requirements.txt /tmp/
88

9-
RUN python3 -m pip install -r /tmp/server-requirements.txt
9+
RUN python3 -m pip install -r /tmp/server-requirements.txt && \
10+
grep -Po '^[\w\.-]*(?=)' /tmp/server-requirements.txt | xargs -I pkg python3 -m pip show pkg | grep -P '^(Name|Version|Location)'
1011

1112
FROM python:3.9.6-slim-bullseye as prod
1213

0 commit comments

Comments
 (0)