Skip to content

Commit a856ae4

Browse files
authored
Merge pull request #1585 from oracle-devrel/oci-devops-genai-fix
Oci devops genai fix
2 parents dc0bea4 + 5b46edc commit a856ae4

File tree

5 files changed

+34
-22
lines changed

5 files changed

+34
-22
lines changed

app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/README.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,21 @@ Clone this repo locally. In OCI Console click <code>Create Stack</code> under <c
5454
<p>
5555
OCI DevOps IAM Policies are not part of the stack, please refer to <a href="https://docs.oracle.com/en-us/iaas/Content/devops/using/devops_iampolicies.htm">docs</a> how to create them first.
5656
<p>
57-
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 <b>name</b> of the OCIR repo needs to match to the <code>image_name</code> of the Stack variables e.g. <b>helloworldai-java</b>. The image tag must be '<b>1</b>'.
58-
<br>
59-
The reason for this is that the Stack cannot create the Function without pointing to an image in OCIR.
60-
<p>
61-
This can be done by doing the following in OCI Cloud Shell (assuming the image name is 'helloworldai-java'):
62-
<pre>
63-
oci artifacts container repository create --display-name helloworldai-java --compartment-id ocid1.compartment.oc1.....gq
64-
docker pull hello-world
65-
docker tag hello-world fra.ocir.io/&lt;YOUR_TENANCY_NAMESPACE&gt;/helloworldai-java:1
66-
docker push fra.ocir.io/&lt;YOUR_TENANCY_NAMESPACE&gt;/helloworldai-java:1
67-
</pre>
68-
Unless doing this the Stack will run into an error:
69-
<pre>
70-
Error: 400-InvalidParameter, Invalid Image fra.ocir.io/&lt;YOUR_TENANCY_NAMESPACE&gt;/&lt;image_name&gt:1 does not exist or you do not have access to use it
71-
</pre>
72-
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 <a href="https://github.com/oracle-devrel/technology-engineering/blob/main/app-dev/devops-and-containers/functions/java-helloworld-AI-with-local-dev-and-oci-functions/README.md">this one</a> (the dummy hello-world image won't run properly).
57+
58+
### Stack settings
59+
60+
Before applying the Stack fill in the vars:
61+
62+
![Stack](./files/stack.jpg)
63+
64+
<ul>
65+
<li><i>initial_image</i> that is used to create the OCI Function as target environment for the OCI DevOps deployment pipeline.
66+
By default it is loaded from Dockerhub, but you can use any X86 arch image if want to replace this</li>
67+
<li><i>docker_user</i> is your OCIR Docker user to push the initial image (above) to OCIR repo for the Function. Replace &lt;namespace&gt; with your <code>tenancy namespace</code>. <code>oracleidentitycloudservice</code> is only used for federated domains/users, not local</li>
68+
<li><i>docker_password</i> is our OCIR Docker user password (your user profile auth token in OCI)</li>
69+
</ul>
70+
71+
Run Stacks's Apply to create the OCI DevOps project.
7372
<p>
7473
The Stack creates only a <i>private subnet</i> in the VCN and hence the Function cannot be called outside the tenancy by default after the build and deploy.
7574
<br>

app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/artifacts.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33
resource oci_artifacts_container_configuration export_container_configuration {
44
compartment_id = var.compartment_ocid
5-
is_repository_created_on_first_push = "true"
5+
is_repository_created_on_first_push = "false"
66
}
77

88
resource oci_artifacts_container_repository export_project {
99
compartment_id = oci_artifacts_container_configuration.export_container_configuration.compartment_id
1010

11-
display_name = "${var.project_name}-image"
11+
display_name = "${var.image_name}"
1212
freeform_tags = {
1313
}
1414
is_immutable = "false"
1515
is_public = "false"
16+
provisioner "local-exec" {
17+
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"
18+
}
1619
}

app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/functions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ resource oci_functions_function export_project_2 {
4040
trace_config {
4141
is_enabled = "false"
4242
}
43+
depends_on = [oci_artifacts_container_repository.export_project]
4344
}
44-

app-dev/devops-and-containers/devops/oci-devops-terraform-function-java-graalvm/files/vars.tf

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@ variable region { default = "eu-frankfurt-1" }
22
variable registry { default = "fra.ocir.io" }
33
variable compartment_ocid { }
44
variable project_name {
5-
default = "helloworldai-java-project"
5+
default = "helloworldai-java"
66
description = "Name of the OCI DevOps project and related resources"
77
}
88
variable image_name {
9-
default = "helloworldai-java"
10-
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."
9+
default = "helloworldai"
10+
description = "Name of the image that is built by the pipelines and deployed in the target OCI Function"
11+
}
12+
variable docker_user {
13+
description = "Your docker user to login OCIR to create the initial Function image"
14+
}
15+
variable docker_pwd {
16+
description = "Your docker password (auth token) to login OCIR to create the initial Function image"
17+
}
18+
variable initial_image {
19+
default = "docker.io/mikarinneoracle/hello-world-java-graalvm"
20+
description = "Intial native X86 Hello-world public image that is used to deploy the initial OCI Function"
1121
}

0 commit comments

Comments
 (0)