Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5d223b9

Browse files
committed
Add podman wrapper script
1 parent 2e17182 commit 5d223b9

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

Containerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ENV HOME=${USER_HOME_DIR}
99
ENV BUILDAH_ISOLATION=chroot
1010

1111
COPY --chown=0:0 entrypoint.sh /
12+
COPY --chown=0:0 podman-wrapper.sh /usr/bin/
1213

1314
RUN microdnf --disableplugin=subscription-manager install -y ${INSTALL_PACKAGES}; \
1415
microdnf update -y ; \
@@ -17,6 +18,7 @@ RUN microdnf --disableplugin=subscription-manager install -y ${INSTALL_PACKAGES}
1718
mkdir -p ${WORK_DIR} ; \
1819
pip3 install -U podman-compose ; \
1920
pip3 install -U cekit ; \
21+
mkdir -p /home/user/.local/share ; \
2022
chgrp -R 0 /home ; \
2123
chmod -R g=u /home ${WORK_DIR} ; \
2224
chmod +x /entrypoint.sh ; \

podman-wrapper.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
ORIGINAL_PODMAN_PATH=${ORIGINAL_PODMAN_PATH:-"/usr/bin/podman.orig"}
5+
KUBEDOCK_SUPPORTED_COMMANDS=${KUBEDOCK_SUPPORTED_COMMANDS:-"run ps exec cp logs inspect kill rm wait stop start"}
6+
7+
PODMAN_ARGS=( "$@" )
8+
9+
TRUE=0
10+
FALSE=1
11+
12+
exec_original_podman() {
13+
exec ${ORIGINAL_PODMAN_PATH} "${PODMAN_ARGS[@]}"
14+
}
15+
16+
exec_kubedock_podman() {
17+
exec env CONTAINER_HOST=tcp://127.0.0.1:2475 "${ORIGINAL_PODMAN_PATH}" "${PODMAN_ARGS[@]}"
18+
}
19+
20+
podman_command() {
21+
echo "${PODMAN_ARGS[0]}"
22+
}
23+
24+
command_is_supported_by_kubedock() {
25+
CMD=$(podman_command)
26+
for SUPPORTED_CMD in $KUBEDOCK_SUPPORTED_COMMANDS; do
27+
if [ "$SUPPORTED_CMD" = "$CMD" ]; then
28+
return $TRUE
29+
fi
30+
done
31+
return ${FALSE}
32+
}
33+
34+
if command_is_supported_by_kubedock; then
35+
exec_kubedock_podman
36+
else
37+
exec_original_podman
38+
fi

0 commit comments

Comments
 (0)