openziti / ziti-builder

Cross-compile builder container image for ziti-tunnel-sdk-c
Apache License 2.0
2 stars 0 forks source link

Publish the cross-compile toolchain as a container image #3

Closed qrkourier closed 1 year ago

qrkourier commented 1 year ago

The purpose of this change is to improve the developer experience for T-SDK, specifically building the ziti-edge-tunnel (ZET) binary. Building the C-SDK and ZET packages (RPM, DEB) are not in scope for this issue.

The new container image will be versioned separately from T-SDK and live in a separate repo. It will be based on the unofficial cross-build container, which will be updated to use Ubuntu Bionic for GLIBC 2.27.

Then, a version of the new container image will be pinned to the CMake workflows for the T-SDK, replacing the current job-container, ubuntu:18.04 (link to workflow).

qrkourier commented 1 year ago

Please comment on whether this implementation meets your expectations for a cross-compile container image: https://github.com/openziti/ziti-tunnel-sdk-c-builder#readme.

qrkourier commented 1 year ago

This solution will replace the Debian-based cross-build container documented in this repo's README file.

qrkourier commented 1 year ago

@ekoby has suggested that we broaden the scope of the container image to be a more general-purpose build tool shared by the CI and local build scripts in the following projects:

I am beginning to investigate the build requirements for C-SDK and zitify since they may be different from T-SDK. I propose the follow developer experience for local builds for each project:

A build.sh script in the repo will have the default behavior of emulating the CMake workflow in CI. Optionally, the developer may override the default build target, etc. by specifying arbitrary CMake options and arguments.

As a stretch goal, the build script could detect the host arch of the developer's workstation and automatically compile for that target arch. Please comment on whether this would meet your expectations.

Notably, I do not plan to design a CLI/API for the build procedure, i.e. replete opts and args for the developer to learn in order to interact with the build script. If this is an important goal for you then please comment on how you want that to work and why.

qrkourier commented 1 year ago

This solution will replace some of the steps in this repo's CMake CI workflow. For example, the steps that install and run cmake and vcpkg. If the same approach is adopted by the C-SDK or zitify repos then the same types of steps in those repos' CMake workflows will be replaced by a single step to run this container.

ekoby commented 1 year ago

I would prefer that Docker image does not make assumptions about the build process or scripts. For example in CI, I just want to use this image like this

jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: ziti-c-builder:latest

so I can still use github actions that provide useful utilities, like caching

I guess I just want an image that has all the tools -- cmake, git, gcc, gcc-crosscompile, etc

qrkourier commented 1 year ago

That makes sense. I'd like to propose the following solution summarizing the input I've received up to this point. Please comment on whether this meets your expectations for a CMake container image.

qrkourier commented 1 year ago

I have updated the README.md in this issue's resolving pull request to reflect the implementation sketch above.

ekoby commented 1 year ago

the prescription for cmake.sh seem superfluous in this context, the consumer project can do whatever, right?

qrkourier commented 1 year ago

the prescription for cmake.sh seem superfluous in this context, the consumer project can do whatever, right?

That's true. It's technically superfluous because the container image will not prescribe any command or use case, assuming the premeditated series of changes in the repositories that will consume this new container image are acceptable as described here. That assumption is probably correct. If that assumption is incorrect, and the consuming repos must use the image differently for some reason, then it will change the design of this image.

qrkourier commented 1 year ago

I've marked the associated pull request ready for review. After acceptance of the initial design, I plan to test the automatically published image with each of the Ziti projects that could adopt this image in their CI.

qrkourier commented 1 year ago

Here's an implementation of cmake.sh using this container image to cross-compile the Linux artifacts for the T-SDK in CI. A developer can run ./cmake.sh to build the default target for x86_64 locally, or ./cmake.sh -p ci-linux-arm64 to build the default target with an alternative os-architecture preset.

https://github.com/openziti/ziti-tunnel-sdk-c/pull/662

qrkourier commented 1 year ago
❯ ./cmake.sh help

Usage: cmake.sh [CMD] [ARGS...] 

Runs CMD in the ziti-cmake container, and builds the 
default target if no CMD is specified

    -c  CMAKE_CONFIG  set CMAKE_BUILD_TYPE (default: Release) 
    -p  CMAKE_PRESET  set CMAKE_TOOLCHAIN_FILE preset (default: ci-linux-x64) 
    -t  CMAKE_TARGET  set CMAKE_TARGET (default: bundle)
qrkourier commented 1 year ago

@scareything Will you react to the emulation experience on your M1 macOS? I've raised a new issue in this repo to improve the experience on arm64 silicon by running the build in an arm64 image instead of emulating amd64.