chore: تنظیم Nexus برای NuGet و Docker offline
Build and Deploy / build (push) Failing after 5s

- Dockerfile: استفاده از Nexus Docker (194.5.195.53:32082)
- NuGet.config: استفاده از Nexus NuGet با HTTP و allowInsecureConnections
- workflow: حذف kubectl dependency، اضافه کردن 32082 به insecure-registries
- csproj: تغییر push آدرس به Nexus foursat-nuget-hosted
This commit is contained in:
masoodafar-web
2026-01-29 02:56:26 +03:30
parent 24cbb378c9
commit 3219d07dea
28 changed files with 62 additions and 75 deletions
+23 -45
View File
@@ -16,21 +16,12 @@ jobs:
image: docker:latest
options: --privileged
steps:
# - name: Install dependencies
# run: |
# apk add --no-cache git curl
# # Install kubectl
# curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
# chmod +x kubectl
# mv kubectl /usr/local/bin/
- name: Start Docker daemon with insecure registry
run: |
mkdir -p /etc/docker
cat > /etc/docker/daemon.json << 'DAEMON'
{
"insecure-registries": ["194.5.195.53:30080", "gitea-svc:3000"],
"insecure-registries": ["194.5.195.53:30080", "194.5.195.53:32500", "194.5.195.53:32082", "gitea-svc:3000"],
"dns": ["0.0.0.0"]
}
DAEMON
@@ -43,34 +34,24 @@ jobs:
docker info
# بررسی وجود cached images
echo "📊 Checking cached base images..."
docker images | grep mcr.microsoft.com || echo "⚠️ WARNING: Base images not cached!"
- name: Load cached Docker images (if not present)
run: |
# بررسی و load کردن images از cache محلی
if ! docker images | grep -q "mcr.microsoft.com/dotnet/aspnet.*9.0"; then
echo "⚠️ Base images not found! Trying to load from cache..."
if [ -f /var/cache/docker/dotnet-aspnet-9.tar ]; then
docker load -i /var/cache/docker/dotnet-aspnet-9.tar
else
echo "❌ ERROR: Cache file not found! Please run server-cache-images.sh first!"
exit 1
fi
echo "📊 Available Docker images:"
docker images --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}" | head -20
echo ""
echo "🔍 Checking for .NET images:"
if docker images | grep -q "mcr.microsoft.com/dotnet/aspnet.*9.0"; then
echo "✅ .NET aspnet:9.0 found"
else
echo "⚠️ WARNING: .NET aspnet:9.0 not found - build will fail!"
echo "Please pre-pull images on the runner host"
fi
if ! docker images | grep -q "mcr.microsoft.com/dotnet/sdk.*9.0"; then
echo "⚠️ SDK image not found! Trying to load from cache..."
if [ -f /var/cache/docker/dotnet-sdk-9.tar ]; then
docker load -i /var/cache/docker/dotnet-sdk-9.tar
else
echo "❌ ERROR: Cache file not found! Please run server-cache-images.sh first!"
exit 1
fi
if docker images | grep -q "mcr.microsoft.com/dotnet/sdk.*9.0"; then
echo "✅ .NET sdk:9.0 found"
else
echo "⚠️ WARNING: .NET sdk:9.0 not found - build will fail!"
echo "Please pre-pull images on the runner host"
fi
echo "✅ All required images are cached:"
docker images | grep mcr.microsoft.com
- name: Checkout code
run: |
@@ -94,14 +75,11 @@ jobs:
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
- name: Deploy to Kubernetes
- name: Build and Push Complete
run: |
# Setup kubeconfig
mkdir -p ~/.kube
echo "${{ secrets.KUBECONFIG }}" | base64 -d > ~/.kube/config
# Restart deployment to pull new image
kubectl rollout restart deployment/backoffice-bff || echo "Deployment doesn't exist yet"
# Wait for rollout to complete
kubectl rollout status deployment/backoffice-bff --timeout=5m || echo "Deployment rollout pending"
echo "🎉 Build and push completed successfully!"
echo "📦 Image pushed to: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}"
echo "📦 Latest tag: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
echo ""
echo "🚀 To deploy manually on server:"
echo "kubectl set image deployment/backoffice-bff backoffice-bff=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}"
+4 -2
View File
@@ -24,7 +24,9 @@ jobs:
- name: Install dependencies
run: |
apk add --no-cache git curl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
# Install kubectl with fixed version
KUBECTL_VERSION="v1.31.0"
curl -LO "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl"
chmod +x kubectl
mv kubectl /usr/local/bin/
@@ -33,7 +35,7 @@ jobs:
mkdir -p /etc/docker
cat > /etc/docker/daemon.json << 'DAEMON'
{
"insecure-registries": ["194.5.195.53:30080", "gitea-svc:3000"]
"insecure-registries": ["194.5.195.53:30080", "194.5.195.53:32082", "gitea-svc:3000"]
}
DAEMON
mkdir -p ~/.docker