From d1d047829b9bd57f884bda1234fbd6e61312ea45 Mon Sep 17 00:00:00 2001 From: Tony Wildish Date: Wed, 11 Dec 2024 14:55:03 +0000 Subject: [PATCH 1/2] Upgrade Nexus VM to larger machine. Update deployment of Nexus container to set Java VM memory limits based on available RAM. Bump version number by 0.0.1 --- .../shared_services/sonatype-nexus-vm/porter.yaml | 2 +- .../scripts/deploy_nexus_container.sh | 10 ++++++++++ .../shared_services/sonatype-nexus-vm/terraform/vm.tf | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/templates/shared_services/sonatype-nexus-vm/porter.yaml b/templates/shared_services/sonatype-nexus-vm/porter.yaml index f46a419468..79ea23c4be 100644 --- a/templates/shared_services/sonatype-nexus-vm/porter.yaml +++ b/templates/shared_services/sonatype-nexus-vm/porter.yaml @@ -1,7 +1,7 @@ --- schemaVersion: 1.0.0 name: tre-shared-service-sonatype-nexus -version: 3.0.0 +version: 3.0.1 description: "A Sonatype Nexus shared service" dockerfile: Dockerfile.tmpl registry: azuretre diff --git a/templates/shared_services/sonatype-nexus-vm/scripts/deploy_nexus_container.sh b/templates/shared_services/sonatype-nexus-vm/scripts/deploy_nexus_container.sh index 84e4d964b4..5246c5cc92 100644 --- a/templates/shared_services/sonatype-nexus-vm/scripts/deploy_nexus_container.sh +++ b/templates/shared_services/sonatype-nexus-vm/scripts/deploy_nexus_container.sh @@ -20,7 +20,17 @@ while true; do ((docker_pull_timeout--)); done +# Deduce memory available to Java. Either 3/4 of the system RAM, or a set minimum +mem_total_mb=$(( $(cat /proc/meminfo | head -1 | awk '{ print $2 }') / 1024 )) +java_mem=2703 +if [ $mem_total_mb -gt 4096 ]; then + java_mem=$(( $mem_total_mb * 3 / 4 )) +fi + +echo "System memory: ${mem_total_mb} MB. Java memory: ${java_mem} MB" + docker run -d -p 80:8081 -p 443:8443 -p 8083:8083 -v /etc/nexus-data:/nexus-data \ + -e INSTALL4J_ADD_VM_PARAMS="-Xmx${java_mem}m -Xms${java_mem}m" \ --restart always \ --name nexus \ --log-driver local \ diff --git a/templates/shared_services/sonatype-nexus-vm/terraform/vm.tf b/templates/shared_services/sonatype-nexus-vm/terraform/vm.tf index 79dfa04472..1d4ee13fcc 100644 --- a/templates/shared_services/sonatype-nexus-vm/terraform/vm.tf +++ b/templates/shared_services/sonatype-nexus-vm/terraform/vm.tf @@ -100,7 +100,7 @@ resource "azurerm_linux_virtual_machine" "nexus" { resource_group_name = local.core_resource_group_name location = data.azurerm_resource_group.rg.location network_interface_ids = [azurerm_network_interface.nexus.id] - size = "Standard_B2s" + size = "Standard_B8ms" disable_password_authentication = false admin_username = "adminuser" admin_password = random_password.nexus_vm_password.result From 3b771961213f7b2d14d2c6b0c853b29df8812d04 Mon Sep 17 00:00:00 2001 From: Tony Wildish Date: Wed, 11 Dec 2024 15:54:09 +0000 Subject: [PATCH 2/2] Fix linting issues --- .../sonatype-nexus-vm/scripts/deploy_nexus_container.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/shared_services/sonatype-nexus-vm/scripts/deploy_nexus_container.sh b/templates/shared_services/sonatype-nexus-vm/scripts/deploy_nexus_container.sh index 5246c5cc92..5fdc769c95 100644 --- a/templates/shared_services/sonatype-nexus-vm/scripts/deploy_nexus_container.sh +++ b/templates/shared_services/sonatype-nexus-vm/scripts/deploy_nexus_container.sh @@ -21,10 +21,11 @@ while true; do done # Deduce memory available to Java. Either 3/4 of the system RAM, or a set minimum +# shellcheck disable=SC2002 mem_total_mb=$(( $(cat /proc/meminfo | head -1 | awk '{ print $2 }') / 1024 )) java_mem=2703 if [ $mem_total_mb -gt 4096 ]; then - java_mem=$(( $mem_total_mb * 3 / 4 )) + java_mem=$(( mem_total_mb * 3 / 4 )) fi echo "System memory: ${mem_total_mb} MB. Java memory: ${java_mem} MB"