mirror of
https://github.com/containers/podman-compose.git
synced 2025-08-09 05:54:34 +02:00
add Dockerfile and related scripts
This commit is contained in:
16
scripts/download_and_build_podman-compose.sh
Normal file
16
scripts/download_and_build_podman-compose.sh
Normal file
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Delete repository dir
|
||||
rm -rf podman-compose-src
|
||||
|
||||
# Clone repository
|
||||
git clone https://github.com/containers/podman-compose podman-compose-src
|
||||
|
||||
# Generate binary
|
||||
sh podman-compose-src/scripts/generate_binary_using_dockerfile.sh
|
||||
|
||||
# Move binary outside repo's dir
|
||||
mv podman-compose-src/podman-compose .
|
||||
|
||||
# Delete repository dir
|
||||
rm -rf podman-compose-src
|
57
scripts/generate_binary_using_dockerfile.sh
Normal file
57
scripts/generate_binary_using_dockerfile.sh
Normal file
@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Find an available container tool (docker or podman)
|
||||
find_container_tool() {
|
||||
if command -v docker > /dev/null 2>&1; then
|
||||
echo "sudo docker"
|
||||
elif command -v podman > /dev/null 2>&1; then
|
||||
echo "podman"
|
||||
else
|
||||
echo "Error: Neither docker nor podman is available." >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Determine which container tool to use
|
||||
CONTAINER_TOOL=$(find_container_tool)
|
||||
|
||||
# Locate the directory containing dockerfile (root)
|
||||
PROJECT_ROOT_DIR="$(cd "$(dirname "$0")" && pwd)/.."
|
||||
|
||||
# Check SELinux status and set appropriate mount option
|
||||
check_selinux() {
|
||||
if command -v getenforce > /dev/null 2>&1; then
|
||||
SELINUX_STATUS=$(getenforce)
|
||||
if [ "$SELINUX_STATUS" = "Enforcing" ] || [ "$SELINUX_STATUS" = "Permissive" ]; then
|
||||
echo ":z"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
elif [ -f /sys/fs/selinux/enforce ]; then
|
||||
if [ "$(cat /sys/fs/selinux/enforce)" = "1" ]; then
|
||||
echo ":z"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
# Get the SELinux option for volume mounts if SELinux is enforcing or permissive
|
||||
SELINUX=$(check_selinux)
|
||||
|
||||
# Build binary
|
||||
$CONTAINER_TOOL image rm build-podman-compose
|
||||
|
||||
if expr "$CONTAINER_TOOL" : '.*docker.*' >/dev/null; then
|
||||
$CONTAINER_TOOL build -t build-podman-compose "$PROJECT_ROOT_DIR"
|
||||
$CONTAINER_TOOL run --name build-podman-compose build-podman-compose
|
||||
$CONTAINER_TOOL cp build-podman-compose:/result/podman-compose "$PROJECT_ROOT_DIR/podman-compose"
|
||||
$CONTAINER_TOOL container stop build-podman-compose
|
||||
$CONTAINER_TOOL container rm -f build-podman-compose
|
||||
else
|
||||
$CONTAINER_TOOL build -v "$PROJECT_ROOT_DIR:/result$SELINUX" -t build-podman-compose "$PROJECT_ROOT_DIR"
|
||||
fi
|
||||
$CONTAINER_TOOL image rm python:3.11-slim
|
||||
$CONTAINER_TOOL image rm build-podman-compose
|
Reference in New Issue
Block a user