From 88325f8f3280c23376d93bb787aa85e7edb4430f Mon Sep 17 00:00:00 2001 From: Kristiyan Gostev Date: Wed, 5 Jun 2024 10:55:02 +0300 Subject: [PATCH] Build container management as a static binary (#91) [#90] Build container management as a static binary - Build container management as a static binary - Remove EOL yocto releases Signed-off-by: Kristiyan Gostev --- .github/workflows/validation.yml | 4 ++-- conf/layer.conf | 2 +- .../container-management/container-management_git.bb | 11 ++++++++++- .../container-management/files/service.template | 11 +++++++---- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index ab9411f..ecf862c 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -35,12 +35,12 @@ jobs: - name: Get branch name (merge) if: github.event_name != 'pull_request' shell: bash - run: if [ ${GITHUB_REF#refs/heads/} == "main" ]; then echo "BRANCH_NAME=$(echo "nanbield")" >>$GITHUB_ENV; else echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >>$GITHUB_ENV; fi + run: if [ ${GITHUB_REF#refs/heads/} == "main" ]; then echo "BRANCH_NAME=$(echo "scarthgap")" >>$GITHUB_ENV; else echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >>$GITHUB_ENV; fi id: get_branch - name: Get branch name (pull request) if: github.event_name == 'pull_request' shell: bash - run: if [ ${{ github.event.pull_request.base.ref }} == "main" ]; then echo "BRANCH_NAME=$(echo "nanbield")" >>$GITHUB_ENV; else echo "BRANCH_NAME=$(echo ${{ github.event.pull_request.base.ref }})" >>$GITHUB_ENV; fi + run: if [ ${{ github.event.pull_request.base.ref }} == "main" ]; then echo "BRANCH_NAME=$(echo "scarthgap")" >>$GITHUB_ENV; else echo "BRANCH_NAME=$(echo ${{ github.event.pull_request.base.ref }})" >>$GITHUB_ENV; fi id: get_branch_pr - name: Checkout uses: actions/checkout@v2 diff --git a/conf/layer.conf b/conf/layer.conf index 63ec080..e2296b8 100644 --- a/conf/layer.conf +++ b/conf/layer.conf @@ -15,5 +15,5 @@ LAYERDEPENDS_meta-kanto = " \ virtualization-layer \ " -LAYERSERIES_COMPAT_meta-kanto = "langdale mickledore nanbield" +LAYERSERIES_COMPAT_meta-kanto = "scarthgap" \ No newline at end of file diff --git a/recipes-containers/container-management/container-management_git.bb b/recipes-containers/container-management/container-management_git.bb index 5bad4bb..95f8ba0 100644 --- a/recipes-containers/container-management/container-management_git.bb +++ b/recipes-containers/container-management/container-management_git.bb @@ -17,6 +17,9 @@ GO_INSTALL = "${GO_IMPORT}/containerm/daemon \ ${GO_IMPORT}/containerm/cli \ " +GO_LINKSHARED = "" +GOBUILDFLAGS:remove = "-buildmode=pie" + require container-management.inc inherit go-mod @@ -48,6 +51,12 @@ FILES:${PN} += "${CM_BIN_DD}/container-management ${CM_BIN_DD}/kanto-cm" # ensure all additional resources are properly packed in the resulting package if provided FILES:${PN} += "${CM_CFG_DD}/container-management/config.json" +# VERSION_PKG = "github.com/eclipse-kanto/container-management/containerm" +# BUILD_TIME = "${@time.strftime('%Y-%m-%dT%H:%M:%SZ',time.gmtime())}" +# BUILD_VERSION = "0.1.0-M2" +# BUILD_REVISION = "${@'${SRCREV}'[:7]}" +# export GO_EXTRA_LDFLAGS="-X ${VERSION_PKG}/version.GitCommit=${BUILD_REVISION} -X ${VERSION_PKG}/version.ProjectVersion=${BUILD_VERSION} -X ${VERSION_PKG}/version.APIVersion=${BUILD_VERSION} -X ${VERSION_PKG}/version.BuildTime=${BUILD_TIME}" + do_install() { install -d ${D}/${CM_BIN_DD} @@ -95,4 +104,4 @@ RDEPENDS:${PN} += "kernel-module-dm-thin-pool kernel-module-nf-nat kernel-module KERNEL_MODULE_AUTOLOAD += "xt_conntrack xt_addrtype" PROVIDES:${PN} += "kanto/container-management" -RPROVIDES:${PN} += "kanto/container-management" +RPROVIDES:${PN} += "kanto/container-management" \ No newline at end of file diff --git a/recipes-containers/container-management/files/service.template b/recipes-containers/container-management/files/service.template index af29fc8..cb432a7 100644 --- a/recipes-containers/container-management/files/service.template +++ b/recipes-containers/container-management/files/service.template @@ -2,13 +2,16 @@ Description=Eclipse Kanto - Container Management Documentation=https://eclipse.org/kanto/docs/ After=network.target containerd.service -Requires=network.target containerd.service +Requires=network.target +Requires=containerd.service [Service] Type=simple -ExecStart=@CM_BIN_DD@/container-management --cfg-file @CM_CFG_DD@/container-management/config.json +Environment=HOME=%h +Environment=XDG_CONFIG_HOME=%E +ExecStart=/usr/bin/container-management --cfg-file /etc/container-management/config.json Restart=always -TimeoutSec=3000 +TimeoutSec=300 [Install] -WantedBy=multi-user.target +WantedBy=multi-user.target \ No newline at end of file