27
									
								
								modules/nexus_image/main.tf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								modules/nexus_image/main.tf
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
locals {
 | 
			
		||||
  tmp_dir = "${path.root}/tmp/nexus-casc-plugin"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
resource "null_resource" "nexus_image" {
 | 
			
		||||
  provisioner "local-exec" {
 | 
			
		||||
    command     = "mkdir -p ${local.tmp_dir}"
 | 
			
		||||
    working_dir = path.root
 | 
			
		||||
  }
 | 
			
		||||
  provisioner "local-exec" {
 | 
			
		||||
    command     = "git clone ${var.nexus_repo_url} ${local.tmp_dir}"
 | 
			
		||||
    working_dir = path.root
 | 
			
		||||
  }
 | 
			
		||||
  provisioner "local-exec" {
 | 
			
		||||
    command     = "git checkout v${var.nexus_version}-01.0"
 | 
			
		||||
    working_dir = local.tmp_dir
 | 
			
		||||
  }
 | 
			
		||||
  provisioner "local-exec" {
 | 
			
		||||
    command = "docker build --pull -t ${var.nexus_image} ${local.tmp_dir}"
 | 
			
		||||
  }
 | 
			
		||||
  provisioner "local-exec" {
 | 
			
		||||
    command = "docker push ${var.nexus_image}"
 | 
			
		||||
  }
 | 
			
		||||
  provisioner "local-exec" {
 | 
			
		||||
    command = "rm -rf ${local.tmp_dir}"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										4
									
								
								modules/nexus_image/output.tf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								modules/nexus_image/output.tf
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
output "nexus_image" {
 | 
			
		||||
  depends_on = [null_resource.nexus_image]
 | 
			
		||||
  value = var.nexus_image
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								modules/nexus_image/variables.tf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								modules/nexus_image/variables.tf
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
variable "nexus_repo_url" {
 | 
			
		||||
  type    = string
 | 
			
		||||
  default = "https://github.com/AdaptiveConsulting/nexus-casc-plugin"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable nexus_version {
 | 
			
		||||
  type    = string
 | 
			
		||||
  default = "3.41.1"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable nexus_image {
 | 
			
		||||
  type    = string
 | 
			
		||||
  default = "adphi/nexus3:3.41.1-casc"
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user