Skip to content

Commit 239143b

Browse files
committed
Build docker image for CI jobs
Signed-off-by: Justin Cinkelj <justin.cinkelj@xlab.si>
1 parent 3ad25b7 commit 239143b

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

ci-infra/docker-image/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
all.requirements

ci-infra/docker-image/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Usage: build new image locally, push it to gcr, use it in CI. and
2+
3+
# we use 'pip install name~=1.2.0' to install latest 1.2.x release
4+
ARG ANSIBLE_CORE_VERSION=2.13.0
5+
6+
# =======================================================================
7+
FROM python:3.10-slim-buster
8+
ARG ANSIBLE_CORE_VERSION
9+
10+
ENV LANG=en_US.UTF-8
11+
12+
RUN apt update && apt install -y git make smbclient genisoimage qemu-utils jq
13+
RUN pip install --upgrade pip wheel
14+
15+
COPY all.requirements /code/ci-infra/docker-image/
16+
RUN pip install -r /code/ci-infra/docker-image/all.requirements && \
17+
pip install yq
18+
19+
RUN pip install ansible-core~=$ANSIBLE_CORE_VERSION

ci-infra/docker-image/build.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
# Usage:
4+
# docker login quay.io, with robot account (justinc1_github+justin_scale_uploader )
5+
# ./build.sh
6+
#
7+
# For quicker testing, run "DOCKER_CACHE='y' ./build.sh"
8+
9+
set -eux
10+
11+
# Where to push images
12+
DOCKER_REGISTRY_REPO=quay.io/justinc1_github/scale_ci_integ
13+
# Tag to push
14+
DOCKER_IMAGE_TAG=1
15+
16+
DOCKER_CACHE="${DOCKER_CACHE:-n}"
17+
if [ "$DOCKER_CACHE" == "n" ]
18+
then
19+
DOCKER_BUILD_OPT="--no-cache"
20+
else
21+
DOCKER_BUILD_OPT=""
22+
fi
23+
24+
THIS_SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
25+
REPO_DIR="$(realpath "$THIS_SCRIPT_DIR/../.." )"
26+
27+
cat "$REPO_DIR/{docs,test,sanity,mypy}.requirements" > all.requirements
28+
# TODO but is ghrc.io feature available/enabled?
29+
# Or push to quay.io?
30+
docker build "$DOCKER_BUILD_OPT" -t "$DOCKER_REGISTRY_REPO:$DOCKER_IMAGE_TAG" .
31+
if [ "$DOCKER_CACHE" == "n" ]
32+
then
33+
# Upload only cleanly build images
34+
# Do not overwrite existing tags.
35+
docker manifest inspect $DOCKER_REGISTRY_REPO:$DOCKER_IMAGE_TAG 1>/dev/null && \
36+
echo Image tag $DOCKER_REGISTRY_REPO:$DOCKER_IMAGE_TAG already pushed to registry 1>&2 && \
37+
exit 1
38+
docker push $DOCKER_REGISTRY_REPO:$DOCKER_IMAGE_TAG
39+
fi

0 commit comments

Comments
 (0)