diff --git a/tests/container_package/Containerfile.crhc-pkg b/tests/container_package/Containerfile.crhc-pkg new file mode 100644 index 0000000..2970edf --- /dev/null +++ b/tests/container_package/Containerfile.crhc-pkg @@ -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 diff --git a/tests/container_package/Containerfile.py_38 b/tests/container_package/Containerfile.py_38 new file mode 100644 index 0000000..370a45d --- /dev/null +++ b/tests/container_package/Containerfile.py_38 @@ -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* diff --git a/tests/container_package/README.md b/tests/container_package/README.md new file mode 100644 index 0000000..a316504 --- /dev/null +++ b/tests/container_package/README.md @@ -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. \ No newline at end of file diff --git a/tests/container_package/generate_binary.sh b/tests/container_package/generate_binary.sh new file mode 100755 index 0000000..7466ba3 --- /dev/null +++ b/tests/container_package/generate_binary.sh @@ -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