Skip to content

Commit

Permalink
[ENHANCEMENT] automated way to create the binary
Browse files Browse the repository at this point in the history
* automated way to create the binary
* removing some comments
  • Loading branch information
waldirio authored Feb 9, 2024
1 parent 3ecda73 commit a0df93a
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/container_package/Containerfile.crhc-pkg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM localhost/py_38

WORKDIR /app
CMD git clone https://github.com/C-RH-C/crhc-cli.git && \
python3.8 -m venv ~/.venv/crhc-cli && \
source ~/.venv/crhc-cli/bin/activate && \
pip install --upgrade pip && \
cd crhc-cli && \
pip install -r requirements.txt && \
./crhc.py && \
pyinstaller --onefile crhc.py && \
cp dist/crhc /app
17 changes: 17 additions & 0 deletions tests/container_package/Containerfile.py_38
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM docker.io/dokken/centos-7

WORKDIR /app
RUN yum install gcc zlib-devel openssl-devel libffi-devel git -y && \
yum clean all && \
wget https://www.python.org/ftp/python/3.8.18/Python-3.8.18.tgz && \
tar xvf Python-3.8.18.tgz

WORKDIR /app/Python-3.8.18
RUN pwd && \
./configure --enable-shared && make && make install && \
echo "/usr/local/lib/" >/etc/ld.so.conf.d/py.conf && \
ldconfig -v && \
python3.8 --version

WORKDIR /app
RUN rm -rf Python-3.8.18*
9 changes: 9 additions & 0 deletions tests/container_package/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generate the binary

Feel free to execute this script on any rhel/linxu that you are testing crhc-cli, this will create 2 containers

- The first one with the python version 3.8
- The second one which will create a binary file based on the latest version of crhc-cli code, and this will be compatible with rhel7/8 or glibc of rhel7/8


Just execute the script and it will be enough to prepare everything. Note that you will be notified about removing any image that you have, assuming this is not a big deal, the script will proceed and do all the necessary steps.
50 changes: 50 additions & 0 deletions tests/container_package/generate_binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/bash

cleaning_all_images()
{
read -p "This operation will remove all the current container iamges. Proceed? (y/n): " answer

if [ "$answer" == "y" ]; then
echo "Ok, proceeding and removing all the local images"
else
echo "exiting ..."
exit 1
fi
podman rmi -a --force
}

check_final_dir()
{
if [ -d /tmp/app ]; then
echo "The directory '/tmp/app' is present, removing it"
echo "running the command 'rm -rfv /tmp/app/'"
rm -rfv /tmp/app/
fi

mkdir -pv /tmp/app
}

create_py38_container()
{
# Creating the container
podman build . -t py_38 -f Containerfile.py_38 --layers=false --no-cache
}

create_crhc-cli_container()
{
# Creating the container
podman build . -t crhc-pkg -f Containerfile.crhc-pkg --layers=false --no-cache
}

create_crhc_bin()
{
# Running the container and creating the binary at /tmp/app
podman run --rm --name crhc-cli-build -v /tmp/app:/app:Z localhost/crhc-pkg
}

# Main
cleaning_all_images
check_final_dir
create_py38_container
create_crhc-cli_container
create_crhc_bin

0 comments on commit a0df93a

Please sign in to comment.