-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Adrian Riobo Lorenzo <[email protected]>
- Loading branch information
1 parent
f6be286
commit f3b0a87
Showing
18 changed files
with
991 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Changelog | ||
|
||
## 1.0.0 | ||
|
||
* Initial version for managinig 2 types of builders | ||
* linux multi arch container based | ||
* windows and mac build on remote target | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# CRC Builder | ||
|
||
## Modifications to the image | ||
|
||
Changes to `crc-builder/os/macos/builder/build.sh` require re-building and pushing the image to internal registry (ImageStream). Make sure the changes are pushed to some `mybranch` on your fork of the QE platform repo (`github.com/<your-username>/qe-platform`). Since the `crc-builder/manifests/buildconfig.yaml` will be guiding the build of the image, it needs to specify your branch on your fork as the source. | ||
|
||
```diff | ||
source: | ||
contextDir: support/images/crc-builder | ||
git: | ||
# dev | ||
+ ref: 'mybranch' | ||
+ uri: 'https://gitlab.cee.redhat.com/<your-username>/qe-platform.git' | ||
- ref: v2.14.0 | ||
- uri: 'https://gitlab.cee.redhat.com/crc/qe-platform.git' | ||
type: Git | ||
``` | ||
|
||
Log in to `codeready-container` project, apply the changes in `crc-builder/manifests/buildconfig.yaml` and start the build from the corresponding `BuildConfig` (depending on the platform). | ||
|
||
```bash | ||
oc apply -f support/images/crc-builder/manifests/buildconfig.yaml | ||
oc start-build image-crc-builder-<platform> | ||
``` | ||
|
||
Lastly, make sure that `imagePullPolicy` is set to `Always` in all places that use this imageStreamTag (e.g. `crc-builder:v0.0.3-macos`). In our case, we needed to change and re-apply the following YAML. | ||
|
||
```bash | ||
oc apply -f orchestrator/catalog/task/crc-builder-installer/0.3/crc-builder-installer.yaml | ||
``` | ||
|
||
Then undo changes to `crc-builder/manifests/buildconfig.yaml` so it points to the upstream repository. | ||
|
||
_If everything works as expected, send an MR to `gitlab.cee.redhat.com/crc/qe-platform`._ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#8.10 | ||
FROM quay.io/almalinuxorg/8-minimal@sha256:6c50656775e5971f7fb5e0d0d5b17f246873408a67b571ef720b7c1324118433 | ||
|
||
ARG TARGETARCH | ||
|
||
LABEL org.opencontainers.image.authors="CodeReady Containers <[email protected]>" | ||
|
||
ENV GO_VERSION 1.21.11 | ||
|
||
RUN microdnf -y install git make gcc libvirt-devel perl-Digest-SHA xz findutils diffutils tar \ | ||
&& curl -Lo /tmp/${GO_VERSION}.tar.gz https://go.dev/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz \ | ||
&& tar -xzvf /tmp/${GO_VERSION}.tar.gz -C /usr/lib > /dev/null \ | ||
&& ln -s /usr/lib/go/bin/go /usr/local/bin/go \ | ||
&& curl -k -Lo /usr/local/bin/mc https://dl.min.io/client/mc/release/linux-${TARGETARCH}/mc \ | ||
&& chmod +x /usr/local/bin/mc \ | ||
&& rm /tmp/${GO_VERSION}.tar.gz | ||
|
||
COPY lib/common.sh /usr/local/bin | ||
COPY lib/linux/entrypoint.sh /usr/local/bin/entrypoint.sh | ||
|
||
ENTRYPOINT entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
FROM registry.access.redhat.com/ubi8/ubi-minimal as preparer | ||
|
||
ARG OS | ||
ENV OS ${OS} | ||
|
||
COPY lib/${OS}/builder/* /usr/local/crc-builder/ | ||
COPY lib/${OS}/entrypoint.sh /usr/local/bin/entrypoint.sh | ||
|
||
RUN cd /usr/local/crc-builder && \ | ||
if [[ ${OS} == 'windows' ]]; then \ | ||
curl -k -LO https://dl.minio.io/client/mc/release/windows-amd64/mc.exe; \ | ||
else \ | ||
curl -k -LO https://dl.min.io/client/mc/release/darwin-amd64/mc; \ | ||
chmod +x mc; \ | ||
fi; | ||
|
||
FROM quay.io/rhqp/support-tools:v0.0.2 | ||
|
||
LABEL org.opencontainers.image.authors="CodeReady Containers <[email protected]>" | ||
|
||
ENV PLATFORM ${PLATFORM} | ||
ENV BUILDER_RESOURCES "/usr/local/crc-builder" | ||
|
||
COPY --from=preparer /usr/local/crc-builder ${BUILDER_RESOURCES} | ||
COPY --from=preparer /usr/local/bin/entrypoint.sh /usr/local/bin | ||
COPY lib/common.sh /usr/local/bin | ||
|
||
ENTRYPOINT entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/bin/sh | ||
|
||
# Validate required envs are setup to run the container | ||
validate_envs () { | ||
local validate=1 | ||
|
||
[[ -z "${TARGET_HOST+x}" ]] \ | ||
&& echo "TARGET_HOST required" \ | ||
&& validate=0 | ||
|
||
[[ -z "${TARGET_HOST_USERNAME+x}" ]] \ | ||
&& echo "TARGET_HOST_USERNAME required" \ | ||
&& validate=0 | ||
|
||
[[ -z "${TARGET_HOST_KEY_PATH+x}" && -z "${TARGET_HOST_PASSWORD+x}" ]] \ | ||
&& echo "TARGET_HOST_KEY_PATH or TARGET_HOST_PASSWORD required" \ | ||
&& validate=0 | ||
|
||
return $validate | ||
} | ||
|
||
validate_assets_info () { | ||
local validate=1 | ||
|
||
[[ -z "${TRAY_URL+x}" ]] \ | ||
&& echo "TRAY_URL required" \ | ||
&& validate=0 | ||
|
||
return $validate | ||
} | ||
|
||
validate_s3_configuration () { | ||
local validate=1 | ||
|
||
[[ -z "${DATALAKE_URL}" || -z "${DATALAKE_ACCESS_KEY}" || -z "${DATALAKE_SECRET_KEY}" ]] \ | ||
&& echo "s3 credentials are required, binary can not be updaloaded" \ | ||
&& validate=0 | ||
|
||
return $validate | ||
} | ||
|
||
# Define remote connection | ||
remote_connection () { | ||
local remote="${TARGET_HOST_USERNAME}@${TARGET_HOST}" | ||
if [[ ! -z "${TARGET_HOST_DOMAIN+x}" ]]; then | ||
remote="${TARGET_HOST_USERNAME}@${TARGET_HOST_DOMAIN}@${TARGET_HOST}" | ||
fi | ||
echo "${remote}" | ||
} | ||
|
||
# scp connection string | ||
scp_cmd () { | ||
local options='-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' | ||
if [[ ! -z "${TARGET_HOST_KEY_PATH+x}" ]]; then | ||
echo "scp -r ${options} -i ${TARGET_HOST_KEY_PATH} " | ||
else | ||
echo "sshpass -p ${TARGET_HOST_PASSWORD} scp -r ${options} " | ||
fi | ||
} | ||
|
||
# ssh connection string | ||
ssh_cmd () { | ||
local options='-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' | ||
local connection_string=$(remote_connection) | ||
if [[ ! -z "${TARGET_HOST_KEY_PATH+x}" ]]; then | ||
echo "ssh ${options} -i ${TARGET_HOST_KEY_PATH} ${connection_string}" | ||
else | ||
echo "sshpass -p ${TARGET_HOST_PASSWORD} ssh ${options} ${connection_string}" | ||
fi | ||
} | ||
|
||
upload_path() { | ||
path="distributables/app" | ||
if [[ -z ${CRC_VERSION+x} ]]; then | ||
if [[ ! -z ${PULL_REQUEST+x} ]]; then | ||
echo "${path}/pr-${PULL_REQUEST}" | ||
else | ||
echo "${path}/${REF}" | ||
fi | ||
else | ||
echo "${path}/release/${CRC_VERSION}" | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#!/bin/sh | ||
# Script to be executed on macos machine to build a crc macos installer | ||
# and upload it to s3 compatible storage | ||
|
||
# Execution is controlled based on ENVS: | ||
|
||
# CUSTOM_BUNDLE_VERSION_VARIABLE When build based on a custom bundle need to set type: PODMAN_VERSION or OPENSHIFT_VERSION | ||
# CUSTOM_BUNDLE_VERSION When build based on a custom bundle need to set version | ||
# CRC_SCM: Source code repository for crc | ||
# CRC_SCM_PR: Optional parameter to build an specific PR for crc | ||
# CRC_SCM_REF: Optional parameter to build an specific PR for crc | ||
# CRC_VERSION: Build based on crc version | ||
# DATALAKE_URL: url for remote s3 compatible storage where build bits will be stored | ||
# DATALAKE_ACCESS_KEY: remote s3 credential | ||
# DATALAKE_SECRET_KEY:remote s3 credential | ||
|
||
# Defaults | ||
CRC_SCM="${CRC_SCM:-"https://github.com/code-ready/crc.git"}" | ||
CRC_SCM_REF="${CRC_SCM_REF:-"main"}" | ||
ADMINHELPER_SCM="${ADMINHELPER_SCM:-"https://github.com/code-ready/admin-helper.git"}" | ||
VFKIT_SCM="${VFKIT_SCM:-"https://github.com/code-ready/vfkit.git"}" | ||
|
||
set -exuo pipefail | ||
|
||
# Upload content to S3 compatible | ||
# $1 remote path | ||
# $2 local path to be uploaded | ||
s3_upload() { | ||
[[ -z "${DATALAKE_URL}" || -z "${DATALAKE_ACCESS_KEY}" || -z "${DATALAKE_SECRET_KEY}" ]] \ | ||
&& echo "s3 credentials are required, binary can not be updaloaded" \ | ||
&& exit 1 | ||
|
||
./mc alias set datalake \ | ||
${DATALAKE_URL} \ | ||
${DATALAKE_ACCESS_KEY} \ | ||
${DATALAKE_SECRET_KEY} \ | ||
--api S3v4 | ||
|
||
# Create bucket if not exits | ||
./mc mb "datalake/${1}" | ||
# Copy files to datalake | ||
./mc cp "${2}/crc-macos-installer.pkg" "datalake/${1}/crc-macos-installer.pkg" | ||
./mc cp "${2}/crc-macos-installer.sha256sum" "datalake/${1}/crc-macos-installer.pkg.sha256sum" | ||
# Make bucket public | ||
# ./mc anonymous set public "datalake/${1}/" | ||
} | ||
|
||
##################### | ||
####### MAIN ######## | ||
##################### | ||
|
||
# Custom setup for git | ||
git config --global http.version "HTTP/1.1" | ||
git config --global http.lowSpeedLimit 0 | ||
git config --global http.lowSpeedTime 999999 | ||
|
||
# Get crc code | ||
git clone ${CRC_SCM} | ||
|
||
# Fetch according to parameters provided | ||
if [[ -z ${CRC_VERSION+x} ]]; then | ||
CRC_VERSION_PARTIAL=$(date +'%y.%m.%d') | ||
if [[ ! -z ${CRC_SCM_PR+x} ]]; then | ||
git -C crc fetch origin pull/${CRC_SCM_PR}/head:pr-${CRC_SCM_PR} | ||
git -C crc checkout pr-${CRC_SCM_PR} | ||
else | ||
git -C crc checkout ${CRC_SCM_REF} | ||
fi | ||
# In case we build for a custom bundle we need to match the version | ||
# if [[ ! -z ${CUSTOM_BUNDLE_VERSION_VARIABLE+x} ]] && [[ ! -z ${CUSTOM_BUNDLE_VERSION+x} ]]; then | ||
# sed -i.bak "s/${CUSTOM_BUNDLE_VERSION_VARIABLE} ?= .*/${CUSTOM_BUNDLE_VERSION_VARIABLE} = ${CUSTOM_BUNDLE_VERSION}/g" crc/Makefile | ||
# fi | ||
sed -i.bak "s/CRC_VERSION = .*/CRC_VERSION = ${CRC_VERSION_PARTIAL}/g" crc/Makefile | ||
else | ||
git -C crc checkout "tags/v${CRC_VERSION}" -b "v${CRC_VERSION}" | ||
fi | ||
|
||
# Build admin-helper | ||
git clone ${ADMINHELPER_SCM} | ||
admin_version_line=$(cat admin-helper/crc-admin-helper.spec.in | grep Version:) | ||
admin_version=${admin_version_line##*:} | ||
admin_version=$(echo $admin_version | xargs) | ||
make -C admin-helper out/macos-amd64/crc-admin-helper VERSION=$admin_version | ||
|
||
# Build vfkit | ||
git clone ${VFKIT_SCM} | ||
sudo make -C vfkit all | ||
|
||
# Build pkg | ||
pushd crc | ||
# custom resources to be included | ||
mkdir custom_embedded | ||
cp ./../admin-helper/out/macos-amd64/crc-admin-helper custom_embedded/crc-admin-helper-darwin | ||
cp ./../vfkit/out/vfkit custom_embedded/vfkit | ||
cp ./../vfkit/vf.entitlements custom_embedded/vf.entitlements | ||
|
||
# Match admin-helper version with latest from master head | ||
sed -i '' "s/crcAdminHelperVersion =.*/crcAdminHelperVersion = \"${admin_version}\"/g" pkg/crc/version/version.go | ||
|
||
# create pkg | ||
make out/macos-universal/crc-macos-installer.pkg NO_CODESIGN=1 CUSTOM_EMBED=true EMBED_DOWNLOAD_DIR=custom_embedded | ||
# check sum | ||
pushd out/macos-universal | ||
shasum -a 256 * > crc-macos-installer.sha256sum | ||
popd | ||
popd | ||
|
||
# Upload | ||
s3_upload ${UPLOAD_PATH} crc/out/macos-universal |
Oops, something went wrong.