forked from opendatahub-io-contrib/workbench-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
90 lines (85 loc) · 3.39 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
.PHONY: default ubi9-py39 cuda-ubi9-py39
RELEASE ?= $(shell git describe --tags --always --dirty || echo 'dev')
DATE ?= $(shell date +'%Y%m%d')
REQUIRED_RUNTIME_IMAGE_COMMANDS ?= "curl python oc code-server"
default:
@echo "Options are:"
@echo "Standard images:"
@echo "ubi9-py39 : builds an image based on UBI9 with Python 3.9"
@echo ""
@echo "CUDA images:"
@echo "cuda-ubi9-py39 : builds an image based on UBI9 with Python 3.9"
@echo "---"
@echo "Please specify:"
@echo " - the release number with RELEASE=... (defaults to 'dev')"
@echo " - the build date with DATE=... (defaults to current date)"
ubi9-py39:
cd container && podman build --build-arg=RELEASE=${RELEASE} \
--build-arg=DATE=${DATE} \
--build-arg=BASE_IMAGE=workbench-images:base-ubi9-py39_${RELEASE}_${DATE} \
--build-arg=UBI_VERSION=ubi9 \
--build-arg=PYTHON_VERSION=py39 \
--build-arg=PYTHON_VERSION_LONG="Python 3.9" \
--build-arg=CUDA="" \
-t workbench-images:code-server-ubi9-py39_${RELEASE}_${DATE} .
cuda-ubi9-py39:
cd container && podman build --build-arg=RELEASE=${RELEASE} \
--build-arg=DATE=${DATE} \
--build-arg=BASE_IMAGE=workbench-images:cuda-base-ubi9-py39_${RELEASE}_${DATE} \
--build-arg=UBI_VERSION=ubi9 \
--build-arg=PYTHON_VERSION=py39 \
--build-arg=PYTHON_VERSION_LONG="Python 3.9" \
--build-arg=CUDA="cuda-" \
-t workbench-images:cuda-code-server-ubi9-py39_${RELEASE}_${DATE} .
validate-py39:
@required_commands=$(REQUIRED_RUNTIME_IMAGE_COMMANDS) ; \
if [[ $$IMAGE == "" ]] ; then \
echo "Usage: make validate-py39 IMAGE=<container-image-name>" ; \
exit 1 ; \
fi ; \
fail=0; \
echo "-----------------------------------------------------------" ; \
echo "Validating container image $$IMAGE" ; \
echo "-----------------------------------------------------------" ; \
echo "=> Loading container image ..." ; \
podman inspect $$IMAGE > /dev/null 2>&1 ; \
if [ $$? -ne 0 ]; then \
echo "Container image $$IMAGE is not present or failing" ; \
exit 1; \
fi; \
for cmd in $$required_commands ; do \
echo "=> Checking container image $$IMAGE for $$cmd..." ; \
podman run --rm --entrypoint /bin/bash $$IMAGE -c "which $$cmd > /dev/null 2>&1 " ; \
if [ $$? -ne 0 ]; then \
echo "ERROR: Container image $$IMAGE does not meet criteria for command: $$cmd" ; \
fail=1; \
continue; \
fi; \
if [ $$cmd == "python" ]; then \
echo "=> Checking Python version..." ; \
IMAGE_PYTHON3_MINOR_VERSION=`podman run --rm --entrypoint /bin/bash $$IMAGE -c "$$cmd --version | cut -d' ' -f2 | cut -d'.' -f2"` ; \
if [[ $$IMAGE_PYTHON3_MINOR_VERSION -ne 9 ]]; then \
echo "ERROR: Container image $$IMAGE: unable to parse Python version or wrong version" ; \
fail=1; \
fi; \
fi; \
done ; \
echo "=> Checking for Code-Server ability to start..." ; \
podman run -d --network=host --name validation-container $$IMAGE ; \
for i in {1..6}; do \
nc -z localhost 8787 && break || sleep 5; \
done; \
nc -z localhost 8787 ; \
if [ $$? -ne 0 ]; then \
echo "ERROR: Image $$IMAGE cannot start Code-Server" ; \
fail=1; \
fi; \
echo "Removing container" ; \
podman stop validation-container && podman rm validation-container ; \
echo "-----------------------------------------------------------" ; \
if [ $$fail -eq 1 ]; then \
echo "=> ERROR: Container image $$IMAGE failed to validate" ; \
exit 1 ; \
else \
echo "=> Container image $$IMAGE validated" ; \
fi; \