@@ -15,22 +15,8 @@ find_container_tool() {
15
15
# Determine which container tool to use
16
16
CONTAINER_TOOL=$( find_container_tool)
17
17
18
- # Find the directory containing the dockerfile by traversing up the directory tree
19
- find_dockerfile_dir () {
20
- DIR=$( cd " $( dirname " $0 " ) " && pwd) /$( basename " $0 " )
21
- while [ " $DIR " != " /" ]; do
22
- if ls " $DIR " /* Dockerfile 1> /dev/null 2>&1 ; then
23
- echo " $DIR "
24
- return
25
- fi
26
- DIR=$( dirname " $DIR " )
27
- done
28
- echo " Error: Dockerfile not found in the directory hierarchy." >&2
29
- exit 1
30
- }
31
-
32
18
# Locate the directory containing dockerfile (root)
33
- PROJECT_ROOT_DIR=$( find_dockerfile_dir )
19
+ PROJECT_ROOT_DIR=" $( cd " $( dirname " $0 " ) " && pwd ) /.. "
34
20
35
21
# Check SELinux status and set appropriate mount option
36
22
check_selinux () {
@@ -57,5 +43,15 @@ SELINUX=$(check_selinux)
57
43
58
44
# Build binary
59
45
$CONTAINER_TOOL image rm build-podman-compose
60
- $CONTAINER_TOOL build -v " $PROJECT_ROOT_DIR :/result$SELINUX " -t build-podman-compose $PROJECT_ROOT_DIR
46
+
47
+ if expr " $CONTAINER_TOOL " : ' .*docker.*' > /dev/null; then
48
+ $CONTAINER_TOOL build -t build-podman-compose " $PROJECT_ROOT_DIR "
49
+ $CONTAINER_TOOL run --name build-podman-compose build-podman-compose
50
+ $CONTAINER_TOOL cp build-podman-compose:/result/podman-compose " $PROJECT_ROOT_DIR /podman-compose"
51
+ $CONTAINER_TOOL container stop build-podman-compose
52
+ $CONTAINER_TOOL container rm -f build-podman-compose
53
+ else
54
+ $CONTAINER_TOOL build -v " $PROJECT_ROOT_DIR :/result$SELINUX " -t build-podman-compose " $PROJECT_ROOT_DIR "
55
+ fi
56
+ $CONTAINER_TOOL image rm python:3.11-slim
61
57
$CONTAINER_TOOL image rm build-podman-compose
0 commit comments