11# This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json
22# Copyright (c) 2022-2024 Contributors to the Eclipse Foundation
33#
4+ # This program and the accompanying materials are made available under the
5+ # terms of the Apache License, Version 2.0 which is available at
6+ # https://www.apache.org/licenses/LICENSE-2.0.
7+ #
8+ # Unless required by applicable law or agreed to in writing, software
9+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+ # License for the specific language governing permissions and limitations
12+ # under the License.
13+ #
414# SPDX-License-Identifier: Apache-2.0
515
616name : Build CCU vehicle-mock for single arch
1727
1828permissions :
1929 contents : read
30+ deployments : write
2031 packages : write
2132 actions : write
2233 checks : write
2536 build-image :
2637 name : " Building image (${{ inputs.app_name }})"
2738 runs-on : ubuntu-22.04
39+ container : ghcr.io/eclipse-velocitas/devcontainer-base-images/python:v0.4
40+ env :
41+ APP_NAME : ${{ inputs.app_name }}
2842
2943 steps :
3044 - name : Checkout repository
@@ -38,66 +52,55 @@ jobs:
3852 - name : Set up Docker Buildx
3953 uses : docker/setup-buildx-action@v3
4054
41- - name : Log in to Container Registry (GHCR)
42- uses : docker/login-action@v3
43- with :
44- registry : ghcr.io
45- username : ${{ github.actor }}
46- password : ${{ secrets.GITHUB_TOKEN }}
47-
48- - id : repo_lc
49- name : Prepare repository name in lower case for docker upload
55+ - id : github-repository-name-case-adjusted
56+ name : Prepare repository name in lower case for docker upload. This supports repository names in mixed case
5057 uses : ASzc/change-string-case-action@v6
5158 with :
5259 string : ${{ github.repository }}
5360
61+ - uses : de-vri-es/setup-git-credentials@v2
62+ with :
63+ credentials : https://user:${{ secrets.GITHUB_TOKEN }}@github.com/
64+
65+ - name : Init velocitas project
66+ working-directory : ./vehicle-mock
67+ run : |
68+ velocitas init
69+
70+ - name : Setup git config
71+ working-directory : ./vehicle-mock
72+ shell : bash
73+ run : |
74+ git config --global user.email "github-automation@users.noreply.github.com"
75+ git config --global user.name "Github Automation"
76+
5477 - name : Set Arguments for next step
5578 id : set_args
56- shell : bash
5779 run : |
58- if [ "${{ inputs.platform }}" = "multiarch" ]; then
59- echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
80+ if [ ${{ inputs.platform }} = "multiarch" ]; then
81+ echo "Build Multiarch"
82+ echo "platforms=linux/amd64, linux/arm64" >> $GITHUB_OUTPUT
83+ echo "type=oci,dest=./${{ env.APP_NAME }}.tar" >> $GITHUB_OUTPUT
6084 else
85+ echo "Build ${{inputs.platform}}"
6186 echo "platforms=linux/${{ inputs.platform }}" >> $GITHUB_OUTPUT
87+ echo "type=docker,dest=./${{ env.APP_NAME }}.tar" >> $GITHUB_OUTPUT
6288 fi
63-
64- # CI-only:不改仓库里的 Dockerfile,只在 CI 生成补丁版 Dockerfile.ci
65- # 仅两处补丁:
66- # 1) staticx:加 --no-build-isolation(避免 arm64 下构建 staticx wheel 失败)
67- # 2) pyinstaller:只添加 jaraco 的 hidden-import(不使用 collect-submodules,避免非法模块名 show-newlines)
68- - name : Prepare patched Dockerfile for CI
6989 shell : bash
70- run : |
71- cp vehicle-mock/Dockerfile vehicle-mock/Dockerfile.ci
72-
73- # 1) staticx fix
74- sed -i 's/pip3 install --no-cache-dir staticx/pip3 install --no-cache-dir --no-build-isolation staticx/g' vehicle-mock/Dockerfile.ci
75-
76- # 2) pyinstaller fix (precise line replacement)
77- # Original line in your Dockerfile:
78- # RUN pyinstaller --clean -F -s --paths=src mockprovider.py
79- # Patch it to include jaraco hidden-imports (NO collect-submodules)
80- sed -i 's|^RUN pyinstaller --clean -F -s --paths=src mockprovider.py|RUN pyinstaller --clean -F -s --paths=src --hidden-import jaraco.text --hidden-import jaraco.functools --hidden-import jaraco.context mockprovider.py|g' vehicle-mock/Dockerfile.ci
8190
82- echo "Patched lines:"
83- grep -n "staticx\|^RUN pyinstaller" vehicle-mock/Dockerfile.ci || true
91+ - name : Docker Login
92+ uses : docker/login-action@v2.1.0
93+ with :
94+ registry : ghcr.io
95+ username : ${{ github.actor }}
96+ password : ${{ secrets.GITHUB_TOKEN }}
8497
85- - name : Build and push Docker image
86- uses : docker/build-push-action@v6
98+ - name : Build and push vehicle-mock image
99+ id : build-production
100+ uses : docker/build-push-action@v3.2.0
87101 with :
88102 context : ./vehicle-mock
89- file : ./vehicle-mock/Dockerfile.ci
103+ file : ./vehicle-mock/Dockerfile
104+ tags : ghcr.io/${{ steps.github-repository-name-case-adjusted.outputs.lowercase }}/vehicle-mock:${{ inputs.platform }}
90105 push : true
91106 platforms : ${{ steps.set_args.outputs.platforms }}
92- tags : |
93- ghcr.io/${{ steps.repo_lc.outputs.lowercase }}/vehicle-mock:dev
94- ghcr.io/${{ steps.repo_lc.outputs.lowercase }}/vehicle-mock:${{ github.sha }}
95- labels : |
96- org.opencontainers.image.source=https://github.com/${{ steps.repo_lc.outputs.lowercase }}
97- org.opencontainers.image.revision=${{ github.sha }}
98-
99- - name : Print image reference
100- run : |
101- echo "Pushed:"
102- echo " ghcr.io/${{ steps.repo_lc.outputs.lowercase }}/vehicle-mock:dev"
103- echo " ghcr.io/${{ steps.repo_lc.outputs.lowercase }}/vehicle-mock:${{ github.sha }}"
0 commit comments