Skip to content

Commit 3f360f2

Browse files
Refactor the Azure app to remove the postgresql dependency
1 parent b83b9f3 commit 3f360f2

File tree

5 files changed

+27
-38
lines changed

5 files changed

+27
-38
lines changed

.cirrus/azure_app_verify_and_publish.sh

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ set -e # Exit immediately if a command exits with a non-zero status.
88

99
# Version of the original SonarQube chart (e.g., 2025.3.0)
1010
# This should match the version in charts/sonarqube/Chart.yaml
11-
SONARQUBE_CHART_VERSION="${SQ_VERSION:-2025.3.0}"
12-
SONARQUBE_IMAGE_VERSION="${SQ_IMAGE_VERSION:-2025.3.0}"
13-
PSQL_VERSION="${PSQL_VERSION:-11.14.0}" # PostgreSQL version used in the SonarQube chart
11+
SONARQUBE_CHART_VERSION="${SQ_VERSION:-2025.5.0}"
12+
SONARQUBE_IMAGE_VERSION="${SQ_IMAGE_VERSION:-2025.5.0}"
13+
AZURE_CHART_VERSION="${AZ_CHART_VERSION:-2025.5.1}"
1414

1515
# Azure Container Registry (ACR) details
1616
# This should match the 'registryServer' in your manifest.yaml
@@ -25,10 +25,15 @@ APPLICATION_NAME="sonarqube"
2525

2626
echo "--- Starting Azure Marketplace K8s App Packaging Process ---"
2727

28-
# Replace ACR registry placeholder with actual registry value
28+
# Replace Azure app placeholders with actual registry value
2929
echo "Replacing ACR registry placeholders with: ${ACR_REGISTRY}"
30-
sed -i "s|__ACR_REGISTRY_PLACEHOLDER__|${ACR_REGISTRY}|g" azure-marketplace-k8s-app/manifest.yaml
31-
sed -i "s|__ACR_REGISTRY_PLACEHOLDER__|${ACR_REGISTRY}|g" azure-marketplace-k8s-app/sonarqube-azure/values.yaml
30+
sed -i '' "s|__ACR_REGISTRY_PLACEHOLDER__|${ACR_REGISTRY}|g" azure-marketplace-k8s-app/manifest.yaml
31+
sed -i '' "s|__ACR_REGISTRY_PLACEHOLDER__|${ACR_REGISTRY}|g" azure-marketplace-k8s-app/sonarqube-azure/values.yaml
32+
sed -i '' "s|__AZURE_VERSION_PLACEHOLDER__|${AZURE_CHART_VERSION}|g" azure-marketplace-k8s-app/manifest.yaml
33+
sed -i '' "s|__AZURE_VERSION_PLACEHOLDER__|${AZURE_CHART_VERSION}|g" azure-marketplace-k8s-app/sonarqube-azure/values.yaml
34+
sed -i '' "s|__AZURE_VERSION_PLACEHOLDER__|${AZURE_CHART_VERSION}|g" azure-marketplace-k8s-app/sonarqube-azure/Chart.yaml
35+
sed -i '' "s|__SONARQUBE_CHART_VERSION_PLACEHOLDER__|${SONARQUBE_CHART_VERSION}|g" azure-marketplace-k8s-app/sonarqube-azure/Chart.yaml
36+
sed -i '' "s|__SONARQUBE_IMAGE_VERSION_PLACEHOLDER__|${SONARQUBE_IMAGE_VERSION}|g" azure-marketplace-k8s-app/sonarqube-azure/Chart.yaml
3237

3338
cd azure-marketplace-k8s-app
3439

@@ -45,19 +50,11 @@ rm -rf ../charts/sonarqube/charts
4550
# Ensure the wrapper chart's charts/ directory exists for unpacking
4651
mkdir -p sonarqube-azure/charts/
4752

48-
49-
# 2. Build all required Helm chart dependencies
50-
echo "2a. Build fresh SonarQube dependencies..."
51-
cd ../charts/sonarqube
52-
rm -rf charts/ Chart.lock
53-
helm dependency update
54-
echo "SonarQube dependencies rebuilt successfully."
55-
56-
# 2b. Navigate into the wrapper chart directory and update Helm dependencies
57-
echo "2b. Updating Helm dependencies for the wrapper chart (sonarqube-azure)..."
53+
# 2. Navigate into the wrapper chart directory and update Helm dependencies
54+
echo "2. Updating Helm dependencies for the wrapper chart (sonarqube-azure)..."
5855
# This command will read sonarqube-azure/Chart.yaml and package the 'sonarqube'
5956
# dependency (from ../charts/sonarqube) into sonarqube-azure/charts/sonarqube-${SONARQUBE_CHART_VERSION}.tgz
60-
cd ../../azure-marketplace-k8s-app/sonarqube-azure
57+
cd sonarqube-azure
6158
rm -rf ../../charts/sonarqube/.cache/helm/repository/* # Workaround for Helm caching issues on Cirrus
6259
helm dependency update
6360
echo "Helm dependencies updated. Packaged subchart is now in sonarqube-azure/charts/."
@@ -66,21 +63,18 @@ echo "Helm dependencies updated. Packaged subchart is now in sonarqube-azure/cha
6663
echo "3. Decompressing the SonarQube subchart for CPA validation..."
6764
cd charts
6865
tar -xzf "sonarqube-${SONARQUBE_CHART_VERSION}.tgz"
69-
ls -la sonarqube/charts/postgresql
66+
ls -la sonarqube/
7067
rm "sonarqube-${SONARQUBE_CHART_VERSION}.tgz"
7168
echo "SonarQube subchart decompressed and .tgz removed."
7269

7370
# 4. Navigate back to the main offer directory
7471
cd ../.. # Back to azure-marketplace-k8s-app/
7572

76-
77-
# # 5. Push required images to the ACR_REGISTRY registry
78-
echo "5. Push required images to the ACR_REGISTRY registry..."
73+
# 5. Push required images to the ACR_REGISTRY registry
74+
echo "5. Push required images to the ACR_REGISTRY registry... (skipped) "
7975
## Disabled to due images not available
8076
# docker tag "sonarqube:${SONARQUBE_IMAGE_VERSION}-enterprise" "${ACR_REGISTRY}/sonarqube:${SONARQUBE_IMAGE_VERSION}-enterprise"
8177
# docker push "${ACR_REGISTRY}/sonarqube:${SONARQUBE_IMAGE_VERSION}-enterprise"
82-
docker tag "bitnamilegacy/postgresql:${PSQL_VERSION}" "${ACR_REGISTRY}/bitnamilegacy/postgresql:${PSQL_VERSION}"
83-
docker push "${ACR_REGISTRY}/bitnamilegacy/postgresql:${PSQL_VERSION}"
8478

8579
# 6. Run CPA verify within the container
8680
echo "6. Running CPA verification (cpa verify)..."
@@ -93,7 +87,7 @@ echo "CPA verification complete."
9387
echo "7. Building the CPA bundle (cpa buildbundle)..."
9488
# This creates the .cnab directory and the bundle file (e.g., sonarqube.cnab)
9589
# in the current directory (mounted as /data in container).
96-
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$(pwd)":/data mcr.microsoft.com/container-package-app:latest sh -c "echo "${AZURE_ACR_PASSWORD}" | docker login "${AZURE_ACR_REGISTRY}" --username "${AZURE_ACR_USERNAME}" --password-stdin && cd /data && cpa buildbundle --force"
90+
# docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$(pwd)":/data mcr.microsoft.com/container-package-app:latest sh -c "echo "${AZURE_ACR_PASSWORD}" | docker login "${AZURE_ACR_REGISTRY}" --username "${AZURE_ACR_USERNAME}" --password-stdin && cd /data && cpa buildbundle --force"
9791
echo "CPA bundle built successfully."
9892
echo "CPA bundle pushed to ACR successfully!"
9993

.cirrus/tasks_azure_marketplace.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,25 @@ build_azure_app_template: &BUILD_AZURE_APP_TEMPLATE
22
ec2_instance:
33
<<: *VM_TEMPLATE
44
env:
5-
PSQL_VERSION: 11.14.0
65
SQ_VERSION: 2025.2.0
76
SQ_IMAGE_VERSION: 2025.2.0
7+
AZ_CHART_VERSION: 2025.5.1
88
install_helm_script:
99
- curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
1010
- chmod 700 get_helm.sh
1111
- ./get_helm.sh
1212
login_to_gcr_script:
1313
- echo "${AZURE_ACR_PASSWORD}" | docker login "${AZURE_ACR_REGISTRY}" --username "${AZURE_ACR_USERNAME}" --password-stdin
14-
pull_required_images_script:
15-
# - docker pull "docker.io/sonarqube:${SQ_IMAGE_VERSION}-enterprise" # Disabled to due images not available
16-
- docker pull "docker.io/bitnamilegacy/postgresql:${PSQL_VERSION}"
1714
build_app_script:
1815
- ./.cirrus/azure_app_verify_and_publish.sh
1916

2017
build_azure_staging_app_task:
2118
<<: *BUILD_AZURE_APP_TEMPLATE
2219
only_if: $TRIGGER == "PUSH_AZURE_STAGING" || $TRIGGER == "PUSH_AZURE_PRODUCTION"
2320
env:
24-
PSQL_VERSION: 11.14.0
2521
SQ_VERSION: 2025.5.0
2622
SQ_IMAGE_VERSION: 2025.5.0
23+
AZ_CHART_VERSION: 2025.5.1
2724
AZURE_ACR_REGISTRY: "${AZURE_ACR_REGISTRY_STAGING}"
2825
AZURE_ACR_USERNAME: "${AZURE_ACR_USERNAME_STAGING}"
2926
AZURE_ACR_PASSWORD: "${AZURE_ACR_PASSWORD_STAGING}"
@@ -34,9 +31,9 @@ build_azure_prod_app_task:
3431
depends_on:
3532
- build_azure_staging_app
3633
env:
37-
PSQL_VERSION: 11.14.0
3834
SQ_VERSION: 2025.5.0
3935
SQ_IMAGE_VERSION: 2025.5.0
36+
AZ_CHART_VERSION: 2025.5.1
4037
AZURE_ACR_REGISTRY: "${AZURE_ACR_REGISTRY_PRODUCTION}"
4138
AZURE_ACR_USERNAME: "${AZURE_ACR_USERNAME_PRODUCTION}"
4239
AZURE_ACR_PASSWORD: "${AZURE_ACR_PASSWORD_PRODUCTION}"

azure-marketplace-k8s-app/manifest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
applicationName: sonarqube
22
publisher: "SonarSource"
33
description: "SonarQube Server is a self-managed, automatic code review tool that systematically helps you deliver clean code. As a core element of our Sonar solution, SonarQube integrates into your existing workflow and detects issues in your code to help you perform continuous code inspections of your projects. The tool analyses 30+ different programming languages and integrates into your CI pipeline and DevOps platform to ensure that your code meets high-quality standards."
4-
version: 2025.5.1
4+
version: __AZURE_VERSION_PLACEHOLDER__
55
helmChart: "./sonarqube-azure"
66
clusterArmTemplate: "./mainTemplate.json"
77
uiDefinition: "./createUIDefinition.json"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
apiVersion: v2 # Or v1 depending on your Helm version
22
name: sonarqube-azure
3-
version: 2025.5.1
4-
appVersion: 2025.5.0
3+
version: __AZURE_VERSION_PLACEHOLDER__
4+
appVersion: __SONARQUBE_IMAGE_VERSION_PLACEHOLDER__
55
description: "SonarQube Server is a self-managed, automatic code review tool that systematically helps you deliver clean code. As a core element of our Sonar solution, SonarQube integrates into your existing workflow and detects issues in your code to help you perform continuous code inspections of your projects. The tool analyses 30+ different programming languages and integrates into your CI pipeline and DevOps platform to ensure that your code meets high-quality standards."
66
type: application
77
dependencies:
88
- name: sonarqube
9-
version: 2025.5.0
9+
version: __SONARQUBE_CHART_VERSION_PLACEHOLDER__
1010
repository: "file://../../charts/sonarqube" # Reference to the local SonarQube chart

azure-marketplace-k8s-app/sonarqube-azure/values.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ sonarqube:
66
env:
77
- name: MARKETPLACE_AZURE_BILLING
88
value: "true"
9+
postgresql:
10+
enabled: false
911

1012
global:
1113
azure:
@@ -23,7 +25,3 @@ global:
2325
registry: __ACR_REGISTRY_PLACEHOLDER__
2426
image: sonarqube
2527
tag: 2025.5.0-enterprise
26-
postgresql:
27-
registry: __ACR_REGISTRY_PLACEHOLDER__
28-
image: bitnamilegacy/postgresql
29-
tag: 11.14.0

0 commit comments

Comments
 (0)