Create Stack
under
-Important! Before running the stack it is manadatory to create the OCI Registry repository for the OCI Function container and upload a dummy X86 architecture container to it. The name of the OCIR repo needs to match to the image_name
of the Stack variables e.g. helloworldai-java. The image tag must be '1'.
-
-The reason for this is that the Stack cannot create the Function without pointing to an image in OCIR.
-
-This can be done by doing the following in OCI Cloud Shell (assuming the image name is 'helloworldai-java'): -
-oci artifacts container repository create --display-name helloworldai-java --compartment-id ocid1.compartment.oc1.....gq -docker pull hello-world -docker tag hello-world fra.ocir.io/<YOUR_TENANCY_NAMESPACE>/helloworldai-java:1 -docker push fra.ocir.io/<YOUR_TENANCY_NAMESPACE>/helloworldai-java:1 --Unless doing this the Stack will run into an error: -
-Error: 400-InvalidParameter, Invalid Image fra.ocir.io/<YOUR_TENANCY_NAMESPACE>/<image_name>:1 does not exist or you do not have access to use it --After doing this the Stack can be run to create the OCI DevOps project. After the project creation the build pipelines can be run to build and deploy the OCI Function with real Function code like this one (the dummy hello-world image won't run properly). + +### Stack settings + +Before applying the Stack fill in the vars: + + + +
tenancy namespace
. oracleidentitycloudservice
is only used for federated domains/users, not local
The Stack creates only a private subnet in the VCN and hence the Function cannot be called outside the tenancy by default after the build and deploy.
diff --git a/app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/artifacts.tf b/app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/artifacts.tf
index 1a57cbad1..170fdffed 100644
--- a/app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/artifacts.tf
+++ b/app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/artifacts.tf
@@ -2,15 +2,18 @@
resource oci_artifacts_container_configuration export_container_configuration {
compartment_id = var.compartment_ocid
- is_repository_created_on_first_push = "true"
+ is_repository_created_on_first_push = "false"
}
resource oci_artifacts_container_repository export_project {
compartment_id = oci_artifacts_container_configuration.export_container_configuration.compartment_id
- display_name = "${var.project_name}-image"
+ display_name = "${var.image_name}"
freeform_tags = {
}
is_immutable = "false"
is_public = "false"
+ provisioner "local-exec" {
+ command = "docker login ${var.registry} -u '${var.docker_user}' -p '${var.docker_pwd}' && docker pull ${var.initial_image} && docker tag ${var.initial_image} ${var.registry}/${data.oci_objectstorage_namespace.tenancy_namespace.namespace}/${var.image_name}:1 && docker push ${var.registry}/${data.oci_objectstorage_namespace.tenancy_namespace.namespace}/${var.image_name}:1"
+ }
}
diff --git a/app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/functions.tf b/app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/functions.tf
index b6a783562..4d3894ecd 100644
--- a/app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/functions.tf
+++ b/app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/functions.tf
@@ -40,5 +40,5 @@ resource oci_functions_function export_project_2 {
trace_config {
is_enabled = "false"
}
+ depends_on = [oci_artifacts_container_repository.export_project]
}
-
diff --git a/app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/stack.jpg b/app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/stack.jpg
new file mode 100644
index 000000000..05ef261d3
Binary files /dev/null and b/app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/stack.jpg differ
diff --git a/app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/vars.tf b/app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/vars.tf
index 4d984e12b..680d3f868 100644
--- a/app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/vars.tf
+++ b/app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/vars.tf
@@ -2,10 +2,20 @@ variable region { default = "eu-frankfurt-1" }
variable registry { default = "fra.ocir.io" }
variable compartment_ocid { }
variable project_name {
- default = "helloworldai-java-project"
+ default = "helloworldai-java"
description = "Name of the OCI DevOps project and related resources"
}
variable image_name {
- default = "helloworldai-java"
- description = "Name of the Docker image in OCIR. Important! Create/Push this into the OCIR repo for this before running this Stack, otherwise the stack will fail due to empty image in the function definition You can do this in OCI Cloud Shell using hello-world image from Docker Hub and then tagging and pushing it accordingly."
+ default = "helloworldai"
+ description = "Name of the image that is built by the pipelines and deployed in the target OCI Function"
+}
+variable docker_user {
+ description = "Your docker user to login OCIR to create the initial Function image"
+}
+variable docker_pwd {
+ description = "Your docker password (auth token) to login OCIR to create the initial Function image"
+}
+variable initial_image {
+ default = "docker.io/mikarinneoracle/hello-world-java-graalvm"
+ description = "Intial native X86 Hello-world public image that is used to deploy the initial OCI Function"
}
\ No newline at end of file