feat: remove Python code execution and pyodide #311
This file contains hidden or 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
| name: OpenWebUI Docker Build | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - ionos-dev | |
| - 'ts**' | |
| - 'tl/ci-test-**' | |
| tags: | |
| - 'ionos-**' | |
| - 'snap-**' | |
| - 'live-**' | |
| env: | |
| JOB_NAME: openwebui-build-push-image | |
| BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
| REGISTRY_HOST: ${{ vars.REGISTRY_HOST }} | |
| REGISTRY_URL: ${{ vars.REGISTRY_HOST }}${{ vars.REGISTRY_PATH }} | |
| jobs: | |
| build: | |
| runs-on: self-hosted | |
| permissions: | |
| contents: read | |
| issues: write | |
| steps: | |
| - name: Set TIMESTAMP variable | |
| run: echo "TIMESTAMP=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
| - name: Install kubectl | |
| uses: azure/setup-kubectl@v4 | |
| id: install | |
| with: | |
| version: 'latest' | |
| - name: Create Docker Secret Config for Kaniko | |
| run: | | |
| mkdir -p $HOME/.docker | |
| AUTH="$(echo -n "${HARBOR_USERNAME}:${HARBOR_PASSWORD}" | base64 -w0 )" | |
| echo "{\"auths\":{\"${REGISTRY_HOST}\":{\"auth\":\"${AUTH}\"}}}" > $HOME/.docker/config.json | |
| set +e | |
| kubectl get secret dock-sec -n arc-runners | |
| if [ $? -eq 0 ]; then | |
| echo "dock-sec already exists, deleting it ..." | |
| kubectl delete secret -n arc-runners dock-sec --ignore-not-found | |
| fi | |
| echo "Create docker-sec ..." | |
| kubectl create secret generic dock-sec --from-file=config.json=$HOME/.docker/config.json --namespace=arc-runners | |
| set -e | |
| env: | |
| HARBOR_USERNAME: ${{ secrets.HARBOR_USERNAME }} | |
| HARBOR_PASSWORD: ${{ secrets.HARBOR_PASSWORD }} | |
| - name: Create and Apply Kaniko Job | |
| run: | | |
| set +e | |
| # Check if the job exists | |
| kubectl get job ${{ env.JOB_NAME }} -n arc-runners | |
| if [ $? -eq 0 ]; then | |
| echo "Job gpt-build-push-image, deleting it..." | |
| kubectl delete job ${{ env.JOB_NAME }} -n arc-runners --ignore-not-found | |
| fi | |
| # Create a new job | |
| echo " | |
| apiVersion: batch/v1 | |
| kind: Job | |
| metadata: | |
| name: openwebui-build-push-image | |
| namespace: arc-runners | |
| spec: | |
| template: | |
| spec: | |
| initContainers: | |
| - name: git-clone | |
| image: alpine/git | |
| command: ["/bin/sh", "-c"] | |
| args: | |
| - | | |
| git config --global url."https://oauth:${TOKEN}@github.com/".insteadOf "https://github.com/" && | |
| git clone --recursive -b ${{ env.BRANCH_NAME }} --depth=1 https://github.com/${{ github.repository }}.git /workspace | |
| volumeMounts: | |
| - name: build-context | |
| mountPath: /workspace | |
| containers: | |
| - name: kaniko | |
| image: gcr.io/kaniko-project/executor:latest | |
| args: | |
| - --dockerfile=./Dockerfile | |
| - --context=dir:///workspace | |
| - --destination=${{ env.REGISTRY_URL }}:${{ github.run_id }} | |
| - --destination=${{ env.REGISTRY_URL }}:${ADDITIONAL_TAG//\//_} | |
| - --build-arg=BUILD_HASH=${{ github.sha }} | |
| - --git=recurse-submodules=true | |
| - --skip-tls-verify | |
| volumeMounts: | |
| - name: build-context | |
| mountPath: /workspace | |
| - name: dock-sec | |
| mountPath: /kaniko/.docker | |
| restartPolicy: Never | |
| volumes: | |
| - name: build-context | |
| emptyDir: {} | |
| - name: dock-sec | |
| secret: | |
| secretName: dock-sec | |
| backoffLimit: 1 | |
| " | kubectl apply -f - | |
| set -e | |
| env: | |
| TOKEN: ${{ secrets.GIT_TOKEN }} | |
| ADDITIONAL_TAG: ${{ github.ref_name || github.sha }} | |
| - name: Monitor Job Status and Print Logs | |
| run: | | |
| echo "Monitoring build job." | |
| set -e | |
| TIMEOUT=1200 # Set your desired timeout in seconds | |
| INTERVAL=30 # Interval for checking job status and printing logs | |
| until POD_NAME=$(kubectl get pods --namespace=arc-runners --selector=job-name=${{ env.JOB_NAME }} --output=jsonpath='{.items[0].metadata.name}' 2>/dev/null); do | |
| echo "Waiting for pod to be created..." | |
| sleep 5 | |
| done | |
| echo "Pod ${POD_NAME} is created." | |
| # Wait for pod to be running | |
| POD_STATUS="" | |
| until [ "$POD_STATUS" == "Running" ]; do | |
| POD_STATUS=$(kubectl get pod ${POD_NAME} -o jsonpath='{.status.phase}') | |
| if [ "$POD_STATUS" == "Failed" ]; then | |
| echo "Pod failed." | |
| echo "git-clone:" | |
| kubectl logs -c git-clone ${POD_NAME} | |
| echo "kaniko:" | |
| kubectl logs -c kaniko ${POD_NAME} | |
| exit 1 | |
| fi | |
| if [ "$POD_STATUS" != "Running" ]; then | |
| echo "Waiting for pod ${POD_NAME} to be running. Current status: ${POD_STATUS}" | |
| sleep 5 | |
| fi | |
| done | |
| echo "Pod ${POD_NAME} is running. Following the log ..." | |
| echo "=== Logs for pod ${POD_NAME} ===" | |
| kubectl logs --namespace=arc-runners ${POD_NAME} --follow | |
| echo "=== END: Logs for pod ${POD_NAME} ===" | |
| echo "Wait for the container to stop running ..." | |
| for n in $( seq 1 10 ); do | |
| sleep 10 | |
| # This would either yield an object (truthy for is running) or nothing if not running anymore | |
| running_state="$( kubectl get pod ${POD_NAME} -o jsonpath='{.status.containerStatuses[0].state.running}' )" | |
| if [ -z "${running_state}" ]; then | |
| break | |
| else | |
| echo "Container still running after $(( n * 10 ))s. Waiting 10s more ..." | |
| fi | |
| done | |
| # tr -d is used to remove quotes from the returned _numerical_ value | |
| JOB_EXIT_CODE=$( kubectl get pod ${POD_NAME} -o jsonpath='{.status.containerStatuses[0].state.terminated.exitCode}' | tr -d "'" ) | |
| if [[ "$JOB_EXIT_CODE" == "0" ]]; then | |
| echo "Job ${{ env.JOB_NAME }} is complete." | |
| echo "Image is pushed to the Harbor Registry with TAG '${{ github.run_id }}' and '${ADDITIONAL_TAG//\//_}'" | |
| else | |
| echo "Job ${{ env.JOB_NAME }} failed. Status JSON:" | |
| kubectl get --namespace=arc-runners pod/${POD_NAME} -o "jsonpath='{.status}'" | |
| exit 1 | |
| fi | |
| env: | |
| ADDITIONAL_TAG: ${{ github.ref_name || github.sha }} | |
| - name: Delete Kaniko Job | |
| run: | | |
| kubectl delete job ${{ env.JOB_NAME }} --namespace=arc-runners --ignore-not-found | |
| kubectl delete secret -n arc-runners dock-sec --ignore-not-found | |
| echo "All tasks completed gracefully." |