File tree Expand file tree Collapse file tree 4 files changed +110
-0
lines changed Expand file tree Collapse file tree 4 files changed +110
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Use a base image with necessary build tools
2
+ FROM python:3.11-slim AS builder
3
+
4
+ # Install required packages for building
5
+ RUN apt-get update && apt-get install -y \
6
+ gcc \
7
+ musl-dev \
8
+ build-essential \
9
+ python3-dev \
10
+ && apt-get clean \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Set the working directory
14
+ WORKDIR /app
15
+
16
+ # Copy the application code
17
+ COPY . .
18
+
19
+ # Install PyInstaller
20
+ RUN pip install pyinstaller
21
+ RUN pip install -r requirements.txt
22
+
23
+ # Create a statically linked binary with PyInstaller
24
+ RUN pyinstaller --onefile --clean podman_compose.py
25
+
26
+ # Export binary
27
+ RUN cp /app/dist/podman_compose /result/podman-compose
Original file line number Diff line number Diff line change @@ -74,6 +74,12 @@ pip3 install https://github.com/containers/podman-compose/archive/main.tar.gz
74
74
brew install podman-compose
75
75
```
76
76
77
+ ### Generate binary using docker/podman locally
78
+ This script will download the repo, generate the binary using [ this Dockerfile] ( https://github.com/containers/podman-compose/blob/main/Dockerfile.md ) and let the binary in the directory where you called this script.
79
+ ``` bash
80
+ sh -c " $( curl -sSL https://raw.githubusercontent.com/containers/podman-compose/main/scripts/download_podman-compose.sh) "
81
+ ```
82
+
77
83
### Manual
78
84
79
85
``` bash
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ # Delete repository dir
4
+ rm -rf podman-compose-src
5
+
6
+ # Clone repository
7
+ git clone https://github.com/containers/podman-compose podman-compose-src
8
+
9
+ # Generate binary
10
+ sh podman-compose-src/scripts/generate_binary_using_dockerfile.sh
11
+
12
+ # Move binary outside repo's dir
13
+ mv podman-compose-src/podman-compose .
14
+
15
+ # Delete repository dir
16
+ rm -rf podman-compose-src
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ # Find an available container tool (docker or podman)
4
+ find_container_tool () {
5
+ if command -v docker > /dev/null 2>&1 ; then
6
+ echo " sudo docker"
7
+ elif command -v podman > /dev/null 2>&1 ; then
8
+ echo " podman"
9
+ else
10
+ echo " Error: Neither docker nor podman is available." >&2
11
+ exit 1
12
+ fi
13
+ }
14
+
15
+ # Determine which container tool to use
16
+ CONTAINER_TOOL=$( find_container_tool)
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
+ # Locate the directory containing dockerfile (root)
33
+ PROJECT_ROOT_DIR=$( find_dockerfile_dir)
34
+
35
+ # Check SELinux status and set appropriate mount option
36
+ check_selinux () {
37
+ if command -v getenforce > /dev/null 2>&1 ; then
38
+ SELINUX_STATUS=$( getenforce)
39
+ if [ " $SELINUX_STATUS " = " Enforcing" ] || [ " $SELINUX_STATUS " = " Permissive" ]; then
40
+ echo " :z"
41
+ else
42
+ echo " "
43
+ fi
44
+ elif [ -f /sys/fs/selinux/enforce ]; then
45
+ if [ " $( cat /sys/fs/selinux/enforce) " = " 1" ]; then
46
+ echo " :z"
47
+ else
48
+ echo " "
49
+ fi
50
+ else
51
+ echo " "
52
+ fi
53
+ }
54
+
55
+ # Get the SELinux option for volume mounts if SELinux is enforcing or permissive
56
+ SELINUX=$( check_selinux)
57
+
58
+ # Build binary
59
+ $CONTAINER_TOOL image rm podman-compose
60
+ $CONTAINER_TOOL build -v " $PROJECT_ROOT_DIR :/result$SELINUX " -t podman-compose $PROJECT_ROOT_DIR
61
+ $CONTAINER_TOOL image rm podman-compose
You can’t perform that action at this time.
0 commit comments