Skip to content

Commit 42f613c

Browse files
committed
ref/fix: stop searching in directoy tree for dockerfile and just use $(cd "$(dirname "$0")" && pwd)/.. also fixed error on build with docker
1 parent deb198c commit 42f613c

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@ RUN pip install -r requirements.txt
2323
# Create a binary with PyInstaller
2424
RUN pyinstaller --onefile --clean podman_compose.py
2525

26+
# Create /result dir in case it is not mounted
27+
RUN mkdir -p /result
28+
2629
# Export binary
2730
RUN cp /app/dist/podman_compose /result/podman-compose

scripts/generate_binary_using_dockerfile.sh

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,8 @@ find_container_tool() {
1515
# Determine which container tool to use
1616
CONTAINER_TOOL=$(find_container_tool)
1717

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-
3218
# Locate the directory containing dockerfile (root)
33-
PROJECT_ROOT_DIR=$(find_dockerfile_dir)
19+
PROJECT_ROOT_DIR="$(cd "$(dirname "$0")" && pwd)/.."
3420

3521
# Check SELinux status and set appropriate mount option
3622
check_selinux() {
@@ -57,5 +43,15 @@ SELINUX=$(check_selinux)
5743

5844
# Build binary
5945
$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
6157
$CONTAINER_TOOL image rm build-podman-compose

0 commit comments

Comments
 (0)