fix: update CI/CD pipeline
CI/CD Pipeline to Rancher - SIDATA / build-and-deploy (push) Failing after 42s

This commit is contained in:
2026-09-07 13:31:39 +07:00
parent c8be35b1de
commit 3ed5d62bda
2 changed files with 214 additions and 135 deletions
+213 -134
View File
@@ -18,64 +18,69 @@ jobs:
http_proxy: http://10.15.3.20:80
https_proxy: http://10.15.3.20:80
# ============================================================
# Internal Network - Bypass Proxy
# ============================================================
NO_PROXY: "localhost,127.0.0.1,10.81.2.10,10.15.39.186,registry-nexus-bpkd.drc-bpkd.data-center.id,registry-bpkd.drc-bpkd.data-center.id,.drc-bpkd.data-center.id,.bpkd.jakarta.go.id"
NO_PROXY: >-
localhost,
127.0.0.1,
10.81.2.10,
10.15.39.186,
10.15.39.0/24,
registry-nexus-bpkd.drc-bpkd.data-center.id,
registry-bpkd.drc-bpkd.data-center.id,
.drc-bpkd.data-center.id,
.bpkd.jakarta.go.id
no_proxy: "localhost,127.0.0.1,10.81.2.10,10.15.39.186,registry-nexus-bpkd.drc-bpkd.data-center.id,registry-bpkd.drc-bpkd.data-center.id,.drc-bpkd.data-center.id,.bpkd.jakarta.go.id"
no_proxy: >-
localhost,
127.0.0.1,
10.81.2.10,
10.15.39.186,
10.15.39.0/24,
registry-nexus-bpkd.drc-bpkd.data-center.id,
registry-bpkd.drc-bpkd.data-center.id,
.drc-bpkd.data-center.id,
.bpkd.jakarta.go.id
steps:
# ============================================================
# 1. Checkout
# Gitea Runner biasanya sudah menyediakan source repository
# pada workspace.
# ============================================================
- name: Checkout Code
uses: actions/checkout@v3
# ============================================================
# 2. Diagnostic
# ============================================================
- name: Test Registry Connectivity
- name: Check Workspace
shell: bash
run: |
set -e
echo "=========================================="
echo "SYSTEM"
echo "WORKSPACE"
echo "=========================================="
hostname
uname -a
pwd
ls -lah
echo ""
echo "=========================================="
echo "PROXY"
echo "=========================================="
echo "Git:"
git --version || true
env | grep -i proxy || true
# ============================================================
# 2. Diagnostic
# ============================================================
- name: Test Internal Network
shell: bash
run: |
set -e
echo ""
echo "=========================================="
echo "DNS"
echo "=========================================="
echo "Nexus:"
getent hosts registry-nexus-bpkd.drc-bpkd.data-center.id || true
echo "BPKD Registry:"
getent hosts registry-bpkd.drc-bpkd.data-center.id || true
getent hosts registry-nexus-bpkd.drc-bpkd.data-center.id
getent hosts registry-bpkd.drc-bpkd.data-center.id
echo ""
echo "=========================================="
echo "HOSTS"
echo "=========================================="
cat /etc/hosts
echo ""
echo "=========================================="
echo "NEXUS /v2/"
echo "NEXUS REGISTRY"
echo "=========================================="
HTTPS_PROXY= \
@@ -89,134 +94,178 @@ jobs:
echo ""
echo "=========================================="
echo "BPKD REGISTRY /v2/"
echo "BPKD REGISTRY"
echo "=========================================="
HTTPS_PROXY= \
HTTP_PROXY= \
https_proxy= \
http_proxy= \
curl -vk \
--connect-timeout 10 \
https://registry-bpkd.drc-bpkd.data-center.id/v2/ \
|| true
# ============================================================
# 3. Login Registry
# 3. Check Buildah
# ============================================================
- name: Log in to Gitea Container Registry
uses: docker/login-action@v2
with:
registry: registry-bpkd.drc-bpkd.data-center.id
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
# ============================================================
# 4. Setup Buildx
#
# PENTING:
# network=host diletakkan DI SINI.
# Jangan diletakkan di build-push-action.
# ============================================================
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
driver-opts: |
network=host
# ============================================================
# 5. Diagnostic BuildKit
# ============================================================
- name: Check BuildKit
- name: Check Build Tools
shell: bash
run: |
set -e
echo "=========================================="
echo "Docker Version"
echo "BUILD TOOLS"
echo "=========================================="
docker version
which buildah || true
which podman || true
buildah --version || true
podman --version || true
# ============================================================
# 4. Login Registry
# ============================================================
- name: Login BPKD Registry
shell: bash
run: |
set -e
echo "Login ke registry BPKD..."
HTTPS_PROXY= \
HTTP_PROXY= \
https_proxy= \
http_proxy= \
NO_PROXY="registry-bpkd.drc-bpkd.data-center.id,10.81.2.10" \
no_proxy="registry-bpkd.drc-bpkd.data-center.id,10.81.2.10" \
buildah login \
--tls-verify=true \
-u "${{ secrets.REGISTRY_USER }}" \
-p "${{ secrets.REGISTRY_PASSWORD }}" \
registry-bpkd.drc-bpkd.data-center.id
# ============================================================
# 5. Pull Base Image dari Nexus
# ============================================================
- name: Prepare Base Image
shell: bash
run: |
set -e
BASE_IMAGE="registry-nexus-bpkd.drc-bpkd.data-center.id/php74-fpm-oci8-lengkap:1.0"
echo "=========================================="
echo "PULL BASE IMAGE"
echo "=========================================="
HTTPS_PROXY= \
HTTP_PROXY= \
https_proxy= \
http_proxy= \
NO_PROXY="registry-nexus-bpkd.drc-bpkd.data-center.id,10.81.2.10" \
no_proxy="registry-nexus-bpkd.drc-bpkd.data-center.id,10.81.2.10" \
buildah pull "$BASE_IMAGE"
echo ""
echo "Base image:"
buildah images | grep php74-fpm-oci8 || true
# ============================================================
# 6. Build Image
# ============================================================
- name: Build Image
shell: bash
run: |
set -e
IMAGE="registry-bpkd.drc-bpkd.data-center.id/${{ secrets.REGISTRY_USER }}/sidata"
TAG="${{ gitea.sha }}"
echo "=========================================="
echo "Buildx Version"
echo "BUILD IMAGE"
echo "=========================================="
docker buildx version
buildah bud \
--network host \
--build-arg http_proxy="${http_proxy}" \
--build-arg https_proxy="${https_proxy}" \
--build-arg no_proxy="${no_proxy}" \
-t "${IMAGE}:${TAG}" \
-t "${IMAGE}:latest" \
.
echo ""
echo "=========================================="
echo "Buildx Inspect"
echo "=========================================="
docker buildx inspect --bootstrap
echo ""
echo "=========================================="
echo "DNS From Build Environment"
echo "=========================================="
getent hosts registry-nexus-bpkd.drc-bpkd.data-center.id || true
echo "Image berhasil dibuat:"
buildah images | grep sidata
# ============================================================
# 6. Build & Push
# 7. Push Image
# ============================================================
- name: Build and Push Docker Image
uses: docker/build-push-action@v6
with:
context: .
push: true
- name: Push Image
shell: bash
run: |
set -e
# ========================================================
# Build arguments
# ========================================================
build-args: |
http_proxy=${{ env.http_proxy }}
https_proxy=${{ env.https_proxy }}
no_proxy=${{ env.no_proxy }}
IMAGE="registry-bpkd.drc-bpkd.data-center.id/${{ secrets.REGISTRY_USER }}/sidata"
# ========================================================
# Image Tags
# ========================================================
tags: |
registry-bpkd.drc-bpkd.data-center.id/${{ secrets.REGISTRY_USER }}/sidata:latest
registry-bpkd.drc-bpkd.data-center.id/${{ secrets.REGISTRY_USER }}/sidata:${{ gitea.sha }}
echo "=========================================="
echo "PUSH IMAGE"
echo "=========================================="
# ========================================================
# Build Cache
# ========================================================
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
HTTPS_PROXY= \
HTTP_PROXY= \
https_proxy= \
http_proxy= \
NO_PROXY="registry-bpkd.drc-bpkd.data-center.id,10.81.2.10" \
no_proxy="registry-bpkd.drc-bpkd.data-center.id,10.81.2.10" \
buildah push \
"${IMAGE}:${{ gitea.sha }}"
HTTPS_PROXY= \
HTTP_PROXY= \
https_proxy= \
http_proxy= \
NO_PROXY="registry-bpkd.drc-bpkd.data-center.id,10.81.2.10" \
no_proxy="registry-bpkd.drc-bpkd.data-center.id,10.81.2.10" \
buildah push \
"${IMAGE}:latest"
# ============================================================
# 7. Deploy ke Rancher
# 8. Install kubectl dari Nexus
# ============================================================
- name: Deploy to Rancher Cluster
- name: Prepare kubectl
shell: bash
run: |
set -e
echo "=========================================="
echo "Download kubectl"
echo "KUBECTL"
echo "=========================================="
KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt)
# Ganti URL berikut dengan lokasi kubectl di Nexus Anda.
KUBECTL_URL="http://10.15.39.186:8081/repository/raw-assets/kubectl"
echo "kubectl version: ${KUBECTL_VERSION}"
curl -fLO \
"https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl"
curl -fL \
--noproxy "*" \
"$KUBECTL_URL" \
-o kubectl
chmod +x kubectl
echo ""
echo "=========================================="
echo "kubectl Client"
echo "=========================================="
./kubectl version --client
echo ""
# ============================================================
# 9. Configure Rancher
# ============================================================
- name: Configure Rancher
shell: bash
run: |
set -e
echo "=========================================="
echo "Configure Rancher"
echo "RANCHER"
echo "=========================================="
./kubectl config set-cluster rancher-cluster \
@@ -233,45 +282,75 @@ jobs:
./kubectl config use-context rancher-context
echo ""
echo "=========================================="
echo "Test Rancher Connection"
echo "=========================================="
echo "Test connection..."
./kubectl cluster-info
echo ""
echo "=========================================="
echo "Kubernetes Nodes"
echo "=========================================="
# ============================================================
# 10. Deploy
# ============================================================
- name: Deploy to Rancher
shell: bash
run: |
set -e
./kubectl get nodes
echo ""
echo "=========================================="
echo "Deploy Application"
echo "DEPLOY SIDATA"
echo "=========================================="
if [ -d "k8s" ]; then
echo "Applying manifests from k8s/"
./kubectl apply -f k8s/
elif [ -f "deploy.yaml" ]; then
echo "Applying deploy.yaml"
./kubectl apply -f deploy.yaml
elif [ -f "deployment.yaml" ]; then
echo "Applying deployment.yaml"
./kubectl apply -f deployment.yaml
else
echo "ERROR: Kubernetes manifest tidak ditemukan."
echo "ERROR: deploy.yaml / deployment.yaml / k8s/ tidak ditemukan."
exit 1
fi
echo ""
# ============================================================
# 11. Update Image
# ============================================================
- name: Update Deployment Image
shell: bash
run: |
set -e
IMAGE="registry-bpkd.drc-bpkd.data-center.id/${{ secrets.REGISTRY_USER }}/sidata:${{ gitea.sha }}"
echo "Image:"
echo "$IMAGE"
# PENTING:
# Ganti sidata dengan nama Deployment Kubernetes.
./kubectl -n sidata set image deployment/sidata \
sidata="$IMAGE"
./kubectl -n sidata rollout status \
deployment/sidata \
--timeout=300s
# ============================================================
# 12. Status
# ============================================================
- name: Deployment Status
shell: bash
run: |
set -e
echo "=========================================="
echo "Deployment Status"
echo "DEPLOYMENT"
echo "=========================================="
./kubectl get deployments -A
./kubectl get pods -A
./kubectl -n sidata get deployment
./kubectl -n sidata get pods -o wide
./kubectl -n sidata get svc
+1 -1
View File
@@ -1,4 +1,4 @@
FROM php74-fpm-oci8-lengkap:1.0
FROM registry-nexus-bpkd.drc-bpkd.data-center.id/php74-fpm-oci8-lengkap:1.0
# =========================================================
# Build arguments