Skip to content

Commit 95a867e

Browse files
committed
Enabling use podman in build-and-push target
1 parent 1bda427 commit 95a867e

2 files changed

Lines changed: 14 additions & 103 deletions

File tree

Makefile

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ include $(abspath $(PROJECT_DIR)/build/automation/init.mk)
44
# ==============================================================================
55
# Development workflow targets
66

7-
docker_cmd:
7+
docker-cmd:
88
DOCKER_CMD=$(DOCKER_CMD)
99

10+
docker-debugger:
11+
DOCKER_LIB_IMAGE_DIR=$(DOCKER_LIB_IMAGE_DIR)
12+
1013
# docker_get_reg:
1114
# echo $(_docker-get-reg)
1215

@@ -504,39 +507,6 @@ tag-commit-to-rollback-blue-green-environment: # Tags commit to rollback blue/gr
504507
commit-date-hash-tag:
505508
echo "$(BUILD_COMMIT_DATETIME)-$(BUILD_COMMIT_HASH)"
506509

507-
######### Trial for podman #############
508-
509-
# podman-run-tester: ### Run Python container with Podman
510-
# make docker-config > /dev/null 2>&1
511-
# mkdir -p $(TMP_DIR)/.python/pip/{cache,packages}
512-
# lib_volume_mount=$$(([ $(BUILD_ID) -eq 0 ] || [ "$(LIB_VOLUME_MOUNT)" == true ]) && echo "--volume $(TMP_DIR)/.python/pip/cache:/tmp/.cache/pip --volume $(TMP_DIR)/.python/pip/packages:/tmp/.packages" ||:)
513-
# container=$$([ -n "$(CONTAINER)" ] && echo $(CONTAINER) || echo tester-$(BUILD_COMMIT_HASH)-$(BUILD_ID)-$$(date --date=$$(date -u +"%Y-%m-%dT%H:%M:%S%z") -u +"%Y%m%d%H%M%S" 2> /dev/null)-$$(make secret-random LENGTH=8))
514-
# /opt/podman/bin/podman run --interactive $(_TTY) --rm \
515-
# --name $$container \
516-
# --user $$(id -u):$$(id -g) \
517-
# --env-file <(make _list-variables PATTERN="^(AWS|TX|TEXAS|NHSD|TERRAFORM)") \
518-
# --env-file <(make _list-variables PATTERN="^(DB|DATABASE|SMTP|APP|APPLICATION|UI|API|SERVER|HOST|URL)") \
519-
# --env-file <(make _list-variables PATTERN="^(PROFILE|ENVIRONMENT|BUILD|PROGRAMME|ORG|SERVICE|PROJECT)") \
520-
# --env-file <(make _docker-get-variables-from-file VARS_FILE=$(VARS_FILE)) \
521-
# --env HOME=/tmp \
522-
# --env PIP_TARGET=/tmp/.packages \
523-
# --env PYTHONPATH=/tmp/.packages \
524-
# --env XDG_CACHE_HOME=/tmp/.cache \
525-
# --volume $(PROJECT_DIR):/project \
526-
# --volume $(HOME)/.aws:/tmp/.aws \
527-
# --volume $(HOME)/bin:/tmp/bin \
528-
# --volume $(HOME)/etc:/tmp/etc \
529-
# --volume $(HOME)/usr:/tmp/usr \
530-
# $$lib_volume_mount \
531-
# --network $(DOCKER_NETWORK) \
532-
# --workdir /project/$(shell echo $(abspath $(DIR)) | sed "s;$(PROJECT_DIR);;g") \
533-
# $(ARGS) \
534-
# $$(make _docker-get-reg)/tester:latest \
535-
# $(CMD)
536-
537-
538-
######### Trial for podman #############
539-
540510
docker-run-tester: ### Run python container - mandatory: CMD; optional: SH=true,DIR,ARGS=[Docker args],LIB_VOLUME_MOUNT=true,VARS_FILE=[Makefile vars file],IMAGE=[image name],CONTAINER=[container name]
541511
make docker-config > /dev/null 2>&1
542512
mkdir -p $(TMP_DIR)/.python/pip/{cache,packages}

build/automation/lib/docker.mk

Lines changed: 10 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,9 @@ DOCKER_LIBRARY_TOOLS_VERSION = $(shell cat $(DOCKER_LIB_IMAGE_DIR)/tools/VERSION
4444
COMPOSE_HTTP_TIMEOUT := $(or $(COMPOSE_HTTP_TIMEOUT), 6000)
4545
DOCKER_CLIENT_TIMEOUT := $(or $(DOCKER_CLIENT_TIMEOUT), 6000)
4646

47-
######### Trial for podman #############
48-
4947
# DOCKER_CMD=$(shell type -p docker >/dev/null 2>&1 && echo docker || echo podman)
5048
DOCKER_CMD=$(shell command -v docker >/dev/null 2>&1 && echo docker || echo podman)
5149

52-
######### Trial for podman #############
53-
5450
# ==============================================================================
5551

5652
docker-create-from-template: ### Create Docker image from template - mandatory: NAME,TEMPLATE=[library template image name]
@@ -75,75 +71,11 @@ docker-create-from-template: ### Create Docker image from template - mandatory:
7571
docker-config: ### Configure Docker networking
7672
$(DOCKER_CMD) network create $(DOCKER_NETWORK) 2> /dev/null ||:
7773

78-
######### Trial for podman #############
79-
80-
# podman-build podman-image: ### Build Podman image - mandatory: NAME; optional: VERSION, FROM_CACHE=true, BUILD_OPTS=[build options], EXAMPLE=true
81-
# reg=$$(make _docker-get-reg)
82-
# # Try to execute `make build` from the image directory
83-
# if [ -d $(DOCKER_LIB_IMAGE_DIR)/$(NAME) ] && [ -z "$(__PODMAN_BUILD)" ]; then
84-
# cd $(DOCKER_LIB_IMAGE_DIR)/$(NAME)
85-
# make build __PODMAN_BUILD=true PODMAN_REGISTRY=$(PODMAN_LIBRARY_REGISTRY)
86-
# exit
87-
# elif [ -d $(DOCKER_CUSTOM_DIR)/$(NAME) ] && [ -z "$(__PODMAN_BUILD)" ]; then
88-
# cd $(DOCKER_CUSTOM_DIR)/$(NAME)
89-
# make build __PODMAN_BUILD=true && exit || cd $(PROJECT_DIR)
90-
# elif [ -d $(DOCKER_DIR)/$(NAME) ] && [ -z "$(__PODMAN_BUILD)" ]; then
91-
# cd $(DOCKER_DIR)/$(NAME)
92-
# make build __PODMAN_BUILD=true && exit || cd $(PROJECT_DIR)
93-
# elif [ -d $(DOCKER_DIR)/$(GENERIC_IMAGE_NAME) ] && [ -z "$(__PODMAN_BUILD)" ]; then
94-
# cd $(DOCKER_DIR)/$(GENERIC_IMAGE_NAME)
95-
# make build __PODMAN_BUILD=true && exit || cd $(PROJECT_DIR)
96-
# fi
97-
# # Dockerfile (now Podman)
98-
# make NAME=$(NAME) \
99-
# docker-create-dockerfile FILE=Dockerfile$(shell [ -n "$(EXAMPLE)" ] && echo .example) \
100-
# docker-image-set-version VERSION=$(VERSION)
101-
# # Cache
102-
# cache_from=
103-
# if [[ "$(FROM_CACHE)" =~ ^(true|yes|y|on|1|TRUE|YES|Y|ON)$$ ]]; then
104-
# make /opt/podman/bin/podman-pull NAME=$(NAME) VERSION=latest
105-
# cache_from="--cache-from $$reg/$(NAME):latest"
106-
# fi
107-
# # Build
108-
# dir=$$(make _docker-get-dir)
109-
# export IMAGE=$$reg/$(NAME)$(shell [ -n "$(EXAMPLE)" ] && echo -example)
110-
# export VERSION=$$(make docker-image-get-version)
111-
# make -s file-replace-variables FILE=$$dir/Dockerfile.effective
112-
# /opt/podman/bin/podman build --rm \
113-
# --build-arg IMAGE=$$IMAGE \
114-
# --build-arg VERSION=$$VERSION \
115-
# --build-arg BUILD_ID=$(BUILD_ID) \
116-
# --build-arg BUILD_DATE=$(BUILD_DATE) \
117-
# --build-arg BUILD_REPO=$(BUILD_REPO) \
118-
# --build-arg BUILD_BRANCH=$(BUILD_BRANCH) \
119-
# --build-arg BUILD_COMMIT_HASH=$(BUILD_COMMIT_HASH) \
120-
# --build-arg BUILD_COMMIT_DATE=$(BUILD_COMMIT_DATE) \
121-
# --label name=$$IMAGE \
122-
# --label version=$$VERSION \
123-
# --label build-id=$(BUILD_ID) \
124-
# --label build-date=$(BUILD_DATE) \
125-
# --label build-repo=$(BUILD_REPO) \
126-
# --label build-branch=$(BUILD_BRANCH) \
127-
# --label build-commit-hash=$(BUILD_COMMIT_HASH) \
128-
# --label build-commit-date=$(BUILD_COMMIT_DATE) \
129-
# $(BUILD_OPTS) $$cache_from \
130-
# --file $$dir/Dockerfile.effective \
131-
# --tag $$reg/$(NAME)$(shell [ -n "$(EXAMPLE)" ] && echo -example):$$(make docker-image-get-version) \
132-
# $$dir
133-
# # Tag
134-
# /opt/podman/bin/podman tag \
135-
# $$reg/$(NAME)$(shell [ -n "$(EXAMPLE)" ] && echo -example):$$(make docker-image-get-version) \
136-
# $$reg/$(NAME)$(shell [ -n "$(EXAMPLE)" ] && echo -example):latest
137-
# /opt/podman/bin/podman rmi --force $$(/opt/podman/bin/podman images | grep "<none>" | awk '{ print $$3 }') 2> /dev/null ||:
138-
# make docker-image-keep-latest-only NAME=$(NAME)
139-
# /opt/podman/bin/podman image inspect $$reg/$(NAME)$(shell [ -n "$(EXAMPLE)" ] && echo -example):latest --format='{{.Size}}'
140-
141-
142-
######### Trial for podman #############
14374
docker-build docker-image: ### Build Docker image - mandatory: NAME; optional: VERSION,FROM_CACHE=true,BUILD_OPTS=[build options],EXAMPLE=true
14475
reg=$$(make _docker-get-reg)
14576
# Try to execute `make build` from the image directory
14677
if [ -d $(DOCKER_LIB_IMAGE_DIR)/$(NAME) ] && [ -z "$(__DOCKER_BUILD)" ]; then
78+
echo "0_____________________________$(DOCKER_LIB_IMAGE_DIR), $(NAME), $(__DOCKER_BUILD), $(DOCKER_LIBRARY_REGISTRY)"
14779
cd $(DOCKER_LIB_IMAGE_DIR)/$(NAME)
14880
make build __DOCKER_BUILD=true DOCKER_REGISTRY=$(DOCKER_LIBRARY_REGISTRY)
14981
exit
@@ -226,6 +158,7 @@ docker-create-repository: ### Create Docker repository to store an image - manda
226158
docker-push: ### Push Docker image - mandatory: NAME; optional: VERSION|TAG
227159
make docker-login
228160
reg=$$(make _docker-get-reg)
161+
echo "0 -----------------------------------------------------------------$(IMAGE_NAME) or $(IMAGE_VERSION) or $(IMAGE_TAG)"
229162
if [ -n "$(or $(VERSION), $(TAG))" ]; then
230163
echo "1 -----------------------------------------------------------------$(NAME) or $(VERSION) or $(TAG)"
231164
$(DOCKER_CMD) push $$reg/$(NAME):$(or $(VERSION), $(TAG))
@@ -257,14 +190,17 @@ docker-pull: ### Pull Docker image - mandatory: NAME,DIGEST|VERSION|TAG
257190
docker-tag: ### Tag latest or provide arguments - mandatory: NAME,VERSION|TAG|[SOURCE,TARGET]|[DIGEST,VERSION|TAG]
258191
reg=$$(make _docker-get-reg)
259192
if [ -n "$(DIGEST)" ] && [ -n "$(TAG)" ]; then
193+
echo "0_____________________________$(DIGEST), $(NAME), $(VERSION), $(TAG)"
260194
$(DOCKER_CMD) tag \
261195
$$reg/$(NAME)@$(DIGEST) \
262196
$$reg/$(NAME):$(or $(VERSION), $(TAG))
263197
elif [ -n "$(SOURCE)" ] && [ -n "$(TARGET)" ]; then
198+
echo "1_____________________________$(SOURCE), $(TARGET) "
264199
$(DOCKER_CMD) tag \
265200
$$reg/$(NAME):$(SOURCE) \
266201
$$reg/$(NAME):$(TARGET)
267202
elif [ -n "$(or $(VERSION), $(TAG))" ]; then
203+
echo "2_____________________________$(NAME), $(VERSION), $(TAG)"
268204
$(DOCKER_CMD) tag \
269205
$$reg/$(NAME):latest \
270206
$$reg/$(NAME):$(or $(VERSION), $(TAG))
@@ -876,13 +812,18 @@ docker-compose-exec: ### Run Docker Compose exec command - mandatory: CMD; optio
876812
# ==============================================================================
877813

878814
_docker-get-dir:
815+
echo "---------------------- NAME=$(NAME)"
879816
if [ -n "$(DOCKER_CUSTOM_DIR)" ] && [ -d $(DOCKER_CUSTOM_DIR)/$(NAME) ]; then
817+
echo "0----------------------"
880818
echo $(DOCKER_CUSTOM_DIR)/$(NAME)
881819
elif [ -d $(DOCKER_LIB_IMAGE_DIR)/$(NAME) ]; then
820+
echo "1----------------------"
882821
echo $(DOCKER_LIB_IMAGE_DIR)/$(NAME)
883822
elif [ -d $(DOCKER_DIR)/$(GENERIC_IMAGE_NAME) ] && [ ! -z $(GENERIC_IMAGE_NAME) ] ; then
823+
echo "2----------------------"
884824
echo $(DOCKER_DIR)/$(GENERIC_IMAGE_NAME)
885825
else
826+
echo "3----------------------"
886827
echo $(DOCKER_DIR)/$(NAME)
887828
fi
888829

0 commit comments

Comments
 (0)