11#!/usr/bin/env zx
2- import {
3- getNamespace ,
4- setVariableFromEnvOrPrompt ,
5- writeEnvJson ,
6- generateRandomString ,
7- readEnvJson ,
8- } from "./lib/utils.mjs" ;
9- import {
10- getRegions ,
11- getTenancyId ,
12- } from "./lib/oci.mjs" ;
13- import {
14- containerLogin ,
15- whichContainerEngine ,
16- checkPodmanMachineRunning ,
17- } from "./lib/container.mjs" ;
2+ import { readEnvJson } from "./lib/utils.mjs" ;
183
19- const shell = process . env . SHELL | "/bin/zsh" ;
20- $ . shell = shell ;
21- $ . verbose = true ;
22-
23- const {
24- containerRegistryURL,
25- containerRegistryUser,
26- containerRegistryToken,
27- namespace,
28- regionKey,
29- adbCompartmentId,
30- adbName,
31- adbPassword,
32- } = await readEnvJson ( ) ;
4+ $ . verbose = true ;
5+
6+ const { containerRegistryURL, containerRegistryUser, containerRegistryToken } =
7+ await readEnvJson ( ) ;
338
349// const region = env.REGION || await setVariableFromEnvOrPrompt("REGION", "Enter the region: ", getRegions);
3510
3611const createContainerInstances = async ( attributes ) => {
37-
38- const output = await $ `oci container-instances container-instance create \
12+ const output = await $ `oci container-instances container-instance create \
3913 --display-name "${ attributes . displayName } " \
4014 --availability-domain "${ attributes . ad_ocid } " \
4115 --compartment-id "${ attributes . compartment_ocid } " \
@@ -45,62 +19,60 @@ const createContainerInstances = async (attributes) => {
4519 --containers ${ JSON . stringify ( containersArgs ) } \
4620 --image-pull-secrets ${ JSON . stringify ( secretsArgs ) } \
4721 --vnics ${ JSON . stringify ( vnicsArgs ) } --debug` ;
48- return output ;
49- } ;
22+ return output ;
23+ } ;
5024
51- const attributes = {
52- " displayName" : "autoDeploTest" ,
53- " compartment_ocid" : "xxx" ,
54- " ad_ocid" : "xxx" ,
55- " subnet_ocid" : "xxx" ,
56- " containerRegistryURL" : containerRegistryURL ,
57- " containerRegistryUser" : containerRegistryUser ,
58- " region" : "xxx" ,
59- " servercontainerURL" : "xxx.ocir.io/xxx/save-the-wildlife/server:0.0.8" ,
60- " webcontainerURL" : "xxx.ocir.io/xxx/save-the-wildlife/web:0.0.8" ,
61- } ;
25+ const attributes = {
26+ displayName : "autoDeploTest" ,
27+ compartment_ocid : "xxx" ,
28+ ad_ocid : "xxx" ,
29+ subnet_ocid : "xxx" ,
30+ containerRegistryURL : containerRegistryURL ,
31+ containerRegistryUser : containerRegistryUser ,
32+ region : "xxx" ,
33+ servercontainerURL : "xxx.ocir.io/xxx/save-the-wildlife/server:0.0.8" ,
34+ webcontainerURL : "xxx.ocir.io/xxx/save-the-wildlife/web:0.0.8" ,
35+ } ;
6236
63- const vnicsArgs = [
64- { displayName : "multiplayer vcn" , subnetId : `${ attributes . subnet_ocid } ` } ,
65- ] ;
37+ const vnicsArgs = [
38+ { displayName : "multiplayer vcn" , subnetId : `${ attributes . subnet_ocid } ` } ,
39+ ] ;
6640
67- const secretsArgs = [
68- {
69- password :btoa ( containerRegistryToken ) ,
70- registryEndpoint :containerRegistryURL ,
71- secretType :"BASIC" ,
72- username :btoa ( containerRegistryUser )
73- }
74- ] ;
41+ const secretsArgs = [
42+ {
43+ password : btoa ( containerRegistryToken ) ,
44+ registryEndpoint : containerRegistryURL ,
45+ secretType : "BASIC" ,
46+ username : btoa ( containerRegistryUser ) ,
47+ } ,
48+ ] ;
7549
7650const containersArgs = [
77- {
78- displayName : "ServerContainer2" ,
79- imageUrl : `${ attributes . servercontainerURL } ` ,
80- resourceConfig : {
81- memoryLimitInGBs : 8 ,
82- vcpusLimit : 1.5 ,
83- } ,
51+ {
52+ displayName : "ServerContainer2" ,
53+ imageUrl : `${ attributes . servercontainerURL } ` ,
54+ resourceConfig : {
55+ memoryLimitInGBs : 8 ,
56+ vcpusLimit : 1.5 ,
8457 } ,
85- {
86- displayName : "WebContainer2" ,
87- imageUrl : ` ${ attributes . webcontainerURL } ` ,
88- resourceConfig : {
89- memoryLimitInGBs : 8 ,
90- vcpusLimit : 1.5 ,
91- } ,
58+ } ,
59+ {
60+ displayName : "WebContainer2" ,
61+ imageUrl : ` ${ attributes . webcontainerURL } ` ,
62+ resourceConfig : {
63+ memoryLimitInGBs : 8 ,
64+ vcpusLimit : 1.5 ,
9265 } ,
93- ] ;
66+ } ,
67+ ] ;
68+
69+ const output = await createContainerInstances ( attributes ) ;
9470
95-
96- const output = await createContainerInstances ( attributes ) ;
97-
98- console . log ( output ) ;
99-
71+ console . log ( output ) ;
10072
101- const display_name = "test" ;
102- const compartment_ocid = "xx" ;
103- const ad_ocid = "xxx" ;
104- // const subnet_ocid = await setVariableFromEnvOrPrompt("SUBNET_OCID", "Enter the OCID of the subnet: ");
73+ const display_name = "test" ;
74+ const compartment_ocid = "xx" ;
75+ const ad_ocid = "xxx" ;
76+ // const subnet_ocid = await setVariableFromEnvOrPrompt("SUBNET_OCID", "Enter the OCID of the subnet: ");
10577
10678createContainerInstances ( ) ;
0 commit comments