sergey-safarov created an issue (kamailio/kamailio#4241)
### Description
In the GitHub Actions present Alpine Docker image build error ``` tar (child): kamailio_min-without_os_files.tar.gz: Cannot open: No such file or directory tar (child): Error is not recoverable: exiting now tar: Child returned status 2 tar: Error is not recoverable: exiting now ``` https://github.com/kamailio/kamailio/actions/runs/14722992691/job/4132011103...
With high probability, this does not work
I will work to fix this, but if possible, it will be fine to switch to use `cmake` for Alpine Docker image.
sergey-safarov left a comment (kamailio/kamailio#4241)
@xkaraman could help write `cmake` rules to replace this bash script https://github.com/kamailio/kamailio-ci/blob/master/alpine/build.sh
xkaraman left a comment (kamailio/kamailio#4241)
@sergey-safarov Sure i can help you out? What does this script does exactly?
sergey-safarov left a comment (kamailio/kamailio#4241)
**build_and_install** - build Kamailio sources, package, and install https://github.com/kamailio/kamailio-ci/blob/master/alpine/build.sh#L12C1-L2...
**list_installed_kamailio_packages** - list installed packages and filter by kamailio string. This output installed the kamailio packages. https://github.com/kamailio/kamailio-ci/blob/master/alpine/build.sh#L27-L36
**kamailio_files()** - list the content of the kamailio packages and some mandatory packages. https://github.com/kamailio/kamailio-ci/blob/master/alpine/build.sh#L27-L36
**extra_files()** - list of mandatory files for Alpine-based Kamailio docker image. https://github.com/kamailio/kamailio-ci/blob/master/alpine/build.sh#L38-L58
**sort_filelist**—after merging the `ldd` output, some files may be listed several times. function make filelist deduplication https://github.com/kamailio/kamailio-ci/blob/master/alpine/build.sh#L60-L63
**filter_unnecessary_files()** - exclude debug, man, docs and redme files from packaging into the docker image https://github.com/kamailio/kamailio-ci/blob/master/alpine/build.sh#L65-L78
**ldd_helper()** - functions to call `ldd` and parse output. For `Kamailio` modules required preload Kamailio binary file. https://github.com/kamailio/kamailio-ci/blob/master/alpine/build.sh#L80C1-L8...
**find_binaries** - we package binary files only. `ldd` is used to test file is binary or not. This function also dynamically linked files https://github.com/kamailio/kamailio-ci/blob/master/alpine/build.sh#L87C1-L1...
**filter_os_files** - exclude files present in the base Alpine Docker image. Required to avoid unnecessary file copy to the layer. https://github.com/kamailio/kamailio-ci/blob/master/alpine/build.sh#L87C1-L1...
**tar_files** - create two tar archives. First contains all the files required for `minimal` Docker images. The second tar archive contains files required to add to the base Alpine image. Probably here kamailio binary files are listed twice in the `$TARLIST`. https://github.com/kamailio/kamailio-ci/blob/master/alpine/build.sh#L118-L13...
**make_image_tar** - create a minimal image tree and add busybox to the tree. After this package tar again https://github.com/kamailio/kamailio-ci/blob/master/alpine/build.sh#L135-L14...
**create_apk_dir** - copy the kamailio packages to the mounted folder. These files will be present on the host when docker container is terminated https://github.com/kamailio/kamailio-ci/blob/master/alpine/build.sh#L143-L14...
xkaraman left a comment (kamailio/kamailio#4241)
Quick question regarding `make apk` and `abuild -r`?
`make apk` target, I will see what that does and get back to you, if you happen to know please let me know.
and `abuild -r` is an alpine specific tool? what does it require?
--- So, after the additions for packaging, i hope this will be an easy transition:
Configure as ` cmake -S . -B build-alpine -DCMAKE_INSTALL_PREFIX=/usr -DVERBOSE=off -DBUILD_DOC=OFF --fresh -DEXCLUDE_MODULES="db_oracle dnssec jwt microhttpd nats nsq ruxc secsipid_proc stirshaken tls_wolfssl app_lua" -DCMAKE_BUILD_TYPE="Release" -DMODULE_GROUP_NAME="ALL_PACKAGED" -DINCLUDE_MODULES="" `
`BUILD_DOC=OFF`, no documentation/man will be built
`CMAKE_BUILD_TYPE=Release` built release type, you can change to `DEBUG`, if you want debugging symbols.
`MODULE_GROUP_NAME="ALL_PACKAGED"` will built all groups defined in `groups.cmake` and when packaging it will create a separate deb for each. (these probably don't apply to alpine.) You can use `KSTANDARD` and `KMINI` as well every `K{group_name}` if you want a specific group.
---- Then for building and installing:
Build:
`cmake --build build-alpine -j8`
-- If you want to install for staging then you can use:
`DESTDIR=/tmp/alpine-pkg cmake --install build-alpine`
Here you will find all installed files. No extra files should be installed if you have not build manually the man/dbschema. Regarding docs, since we are installing the ones provided from src code directly, and not building them, you can exclude the docs folder created I guess.
If these are not enough to get you started, ping me again until I can see the `apk` target.