ci: build images with kaniko inside the job image
The runner does not expose its Docker socket to job containers, so the image job could not run docker build. Include the kaniko executor in the CI image and build/push directly from the job; docker login only writes the registry credentials file. Bump the CI image tag to 2.
This commit is contained in:
1 parent
4c6f1c8fe8
commit
a0434d974f
3 files changed
+22
-14
No files matched your search
+16
-13
@@ -13,13 +13,13 @@ env:
|
|||||||
IMAGE_NAME: taptap/audiomanager
|
IMAGE_NAME: taptap/audiomanager
|
||||||
# Built by scripts/build-ci-image.sh from ci/Dockerfile. Bump the tag when
|
# Built by scripts/build-ci-image.sh from ci/Dockerfile. Bump the tag when
|
||||||
# ci/Dockerfile changes.
|
# ci/Dockerfile changes.
|
||||||
CI_IMAGE: gitea.tap-tap.win/taptap/audiomanager-ci:1
|
CI_IMAGE: gitea.tap-tap.win/taptap/audiomanager-ci:2
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: gitea.tap-tap.win/taptap/audiomanager-ci:1
|
image: gitea.tap-tap.win/taptap/audiomanager-ci:2
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Test
|
- name: Test
|
||||||
@@ -30,7 +30,7 @@ jobs:
|
|||||||
chart:
|
chart:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: gitea.tap-tap.win/taptap/audiomanager-ci:1
|
image: gitea.tap-tap.win/taptap/audiomanager-ci:2
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Lint and render the chart
|
- name: Lint and render the chart
|
||||||
@@ -44,11 +44,8 @@ jobs:
|
|||||||
- chart
|
- chart
|
||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# The runner executes jobs in containers; expose its Docker daemon so the
|
|
||||||
# image build works without a separate DinD service.
|
|
||||||
container:
|
container:
|
||||||
image: gitea.tap-tap.win/taptap/audiomanager-ci:1
|
image: gitea.tap-tap.win/taptap/audiomanager-ci:2
|
||||||
options: --volume /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
@@ -70,12 +67,18 @@ jobs:
|
|||||||
tags+=("$REGISTRY/$IMAGE_NAME:latest")
|
tags+=("$REGISTRY/$IMAGE_NAME:latest")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
build_args=()
|
destinations=()
|
||||||
for tag in "${tags[@]}"; do
|
for tag in "${tags[@]}"; do
|
||||||
build_args+=(-t "$tag")
|
destinations+=(--destination "$tag")
|
||||||
done
|
done
|
||||||
|
|
||||||
docker build "${build_args[@]}" .
|
# Kaniko builds without a Docker daemon. docker login wrote the
|
||||||
for tag in "${tags[@]}"; do
|
# credentials to the default Docker config location.
|
||||||
docker push "$tag"
|
mkdir -p /kaniko/.docker
|
||||||
done
|
cp "$HOME/.docker/config.json" /kaniko/.docker/config.json
|
||||||
|
|
||||||
|
kaniko-executor \
|
||||||
|
--context="dir://$PWD" \
|
||||||
|
--dockerfile="$PWD/Dockerfile" \
|
||||||
|
--snapshot-mode=redo \
|
||||||
|
"${destinations[@]}"
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
# workflows do not download a JDK or install packages on every run.
|
# workflows do not download a JDK or install packages on every run.
|
||||||
#
|
#
|
||||||
# Build and push it with scripts/build-ci-image.sh.
|
# Build and push it with scripts/build-ci-image.sh.
|
||||||
|
FROM gcr.io/kaniko-project/executor:v1.23.2-debug AS kaniko
|
||||||
|
|
||||||
FROM gradle:8.14.3-jdk21
|
FROM gradle:8.14.3-jdk21
|
||||||
|
|
||||||
ARG NODE_VERSION=22.14.0
|
ARG NODE_VERSION=22.14.0
|
||||||
@@ -42,6 +44,9 @@ RUN curl -fsSL "https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz" \
|
|||||||
&& rm -rf /tmp/helm.tgz /tmp/linux-amd64 \
|
&& rm -rf /tmp/helm.tgz /tmp/linux-amd64 \
|
||||||
&& helm version --short
|
&& helm version --short
|
||||||
|
|
||||||
|
# Build images inside the job container without a Docker daemon.
|
||||||
|
COPY --from=kaniko /kaniko/executor /usr/local/bin/kaniko-executor
|
||||||
|
|
||||||
ENV GRADLE_USER_HOME=/root/.gradle \
|
ENV GRADLE_USER_HOME=/root/.gradle \
|
||||||
JAVA_HOME=/opt/java/openjdk
|
JAVA_HOME=/opt/java/openjdk
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ set -euo pipefail
|
|||||||
|
|
||||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
IMAGE="${CI_IMAGE:-gitea.tap-tap.win/taptap/audiomanager-ci}"
|
IMAGE="${CI_IMAGE:-gitea.tap-tap.win/taptap/audiomanager-ci}"
|
||||||
TAG="${1:-1}"
|
TAG="${1:-2}"
|
||||||
|
|
||||||
docker build -f "$ROOT/ci/Dockerfile" -t "$IMAGE:$TAG" "$ROOT"
|
docker build -f "$ROOT/ci/Dockerfile" -t "$IMAGE:$TAG" "$ROOT"
|
||||||
docker push "$IMAGE:$TAG"
|
docker push "$IMAGE:$TAG"
|
||||||
Reference in new issue
Block a user