From 18ed8c71de77e4164e6eae74ef6750c28dd222ae Mon Sep 17 00:00:00 2001 From: Ronan LE MEILLAT Date: Sat, 23 Sep 2023 15:04:07 +0200 Subject: [PATCH] multi arch --- kaniko-build-x86.sh | 60 +++++++++++++++++++++++++++++++++++++++++++++ kaniko-build.sh | 2 -- 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100755 kaniko-build-x86.sh diff --git a/kaniko-build-x86.sh b/kaniko-build-x86.sh new file mode 100755 index 0000000..82622ef --- /dev/null +++ b/kaniko-build-x86.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# Tiltfile looks like: +# os. putenv ( 'DOCKER_USERNAME' , 'registry-user' ) +# os. putenv ( 'DOCKER_PASSWORD' , 'password' ) +# os. putenv ( 'DOCKER_EMAIL' , 'none@example.org' ) +# os. putenv ( 'DOCKER_REGISTRY' , 'registry.example.org' ) +# Namespace='sandbox-hcfp' +# os.putenv('NAMESPACE',Namespace) +# allow_k8s_contexts('kubernetes-admin') +# k8s_yaml(helm('./k8s/helm/hcfmailerplus', name='hcfmailer-plus', namespace=Namespace, values='dev-values.yaml')) +# custom_build('highcanfly/hcfmailer-plus','./kaniko-build.sh',['./autocert', './scripts'],skips_local_docker=True) + +#kubectl create secret generic registry-credentials --from-file=.dockerconfigjson=$HOME/.docker/config.json --type=kubernetes.io/dockerconfigjson +# +# EXPECTED_REF=serveur/highcanfly_hcfmailer-plus:tilt-build-1683738819 +# EXPECTED_IMAGE=highcanfly_hcfmailer-plus +# EXPECTED_TAG=tilt-build-1683738819 +# REGISTRY_HOST=server.fqdn +# EXPECTED_REGISTRY=server.fqdn +echo "NAMESPACE=$NAMESPACE" +KANIKO_POD=$(kubectl -n $NAMESPACE get pods | grep "kaniko" | cut -d' ' -f1) +BAD_RANDOM=$(echo $RANDOM-$RANDOM-$RANDOM-$RANDOM | openssl dgst -sha1 ) +echo "Random seed is $BAD_RANDOM" +kubectl create namespace $NAMESPACE +#kubectl create -n $NAMESPACE secret generic ssh-key-secret --from-file=ssh-privatekey=$HOME/.ssh/id_ecdsa --from-file=ssh-publickey=$HOME/.ssh/id_ecdsa.pub --from-literal=ssh-key-type=ecdsa +echo "CURRENT KANIKO POD is kaniko-$BAD_RANDOM" +kubectl -n $NAMESPACE delete pod --wait=false $KANIKO_POD 2>/dev/null +tar -cv --exclude "node_modules" --exclude "dkim.rsa" --exclude "private" --exclude "k8s" --exclude ".git" --exclude ".github" --exclude-vcs --exclude ".docker" --exclude "_sensitive_datas" -f - . | gzip -9 | kubectl run -n $NAMESPACE kaniko-$BAD_RANDOM \ + --rm --stdin=true \ + --image=highcanfly/kaniko:latest --restart=Never \ + --overrides='{ + "apiVersion": "v1", + "spec": { + "containers": [ + { + "name": "kaniko", + "image": "highcanfly/kaniko:latest", + "imagePullPolicy": "Always", + "stdin": true, + "stdinOnce": true, + "args": [ + "-v","info", + "--build-arg","MSVC_ARCH=x86", + "--build-arg","LLVM_ARCH=i686", + "--cache=false", + "--dockerfile=Dockerfile'$EXT'", + "--context=tar://stdin", + "--skip-tls-verify", + "--destination='$EXPECTED_REF'", + "--image-fs-extract-retry=3", + "--push-retry=3", + "--single-snapshot" + ] + } + ], + "restartPolicy": "Never" + } +}' + +#kubectl delete -n $NAMESPACE secret/registry-credentials diff --git a/kaniko-build.sh b/kaniko-build.sh index 82622ef..ff7f6fb 100755 --- a/kaniko-build.sh +++ b/kaniko-build.sh @@ -40,8 +40,6 @@ tar -cv --exclude "node_modules" --exclude "dkim.rsa" --exclude "private" --excl "stdinOnce": true, "args": [ "-v","info", - "--build-arg","MSVC_ARCH=x86", - "--build-arg","LLVM_ARCH=i686", "--cache=false", "--dockerfile=Dockerfile'$EXT'", "--context=tar://stdin",