@mikarinneoracle/oci-cdk-code-only-preview 0.0.22 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/bin/deploy-code-only.js +7 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -124,14 +124,14 @@ export OCI_FUNCTION_HANDLER='func.handler'
|
|
|
124
124
|
npx ocdk deploy --auto-approve --code-only
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
-
For a Node.js function, use the
|
|
127
|
+
For a Node.js function, use the JavaScript file as the handler (not `fdk.handle` or `node func.js`):
|
|
128
128
|
|
|
129
129
|
```bash
|
|
130
130
|
export OCI_CODE_ONLY_RUNTIME_NAME='node24.ol9'
|
|
131
|
-
export OCI_FUNCTION_HANDLER='
|
|
131
|
+
export OCI_FUNCTION_HANDLER='func.js'
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
-
The equivalent `func.yaml` configuration is supported too
|
|
134
|
+
The equivalent conventional `func.yaml` configuration is supported too. OCDK converts `entrypoint: node func.js` to the required code-only handler `func.js`:
|
|
135
135
|
|
|
136
136
|
```yaml
|
|
137
137
|
schema_version: 20180708
|
|
@@ -167,7 +167,7 @@ export OCI_FUNCTION_APP_NAME='my-existing-function-app'
|
|
|
167
167
|
|
|
168
168
|
These settings are optional: `OCI_CODE_ONLY_SOURCE_DIR` (defaults to the current directory), `OCI_FUNCTION_MEMORY_MB` (from `func.yaml`, otherwise `256`), and `OCI_FUNCTION_TIMEOUT_SECONDS` (from `func.yaml`, otherwise `30`). `OCI_TENANCY_ID`, `OCI_REGION`, and `OCI_NAMESPACE` are also optional when they can be resolved from the active OCI CLI profile.
|
|
169
169
|
|
|
170
|
-
Each deploy re-builds `<function-name>.zip` in the project root and uploads that file. The ZIP has the required `function/` directory at its root, includes source files, and excludes `node_modules`, `.git`, `.tools`, `.terraform`, and `
|
|
170
|
+
Each deploy re-builds `<function-name>.zip` in the project root and uploads that file. The ZIP has the required `function/` directory at its root, includes source files, and excludes `node_modules`, `.git`, `.tools`, `.terraform`, `cdktf.out`, and the generated `tail-function-logs.js`. For Node.js functions, keep `package.json` and `package-lock.json` in the archive so OCI can install the FDK and other dependencies. A successful code-only destroy removes this ZIP after Terraform has destroyed the Function App and infrastructure. With the default `OCI_STACK_ACTION=full-stack`, OCDK creates the API Gateway and uses a Terraform data source to resolve the CLI-managed function OCID for its route. The first code-only deploy therefore runs Terraform once to create the Function App, uploads the function, then runs Terraform again to create the Gateway deployment. Set `OCI_STACK_ACTION=function-only` to omit API Gateway.
|
|
171
171
|
|
|
172
172
|
After a successful code-only deploy, OCDK writes the log IDs for `npx ocdk tail:execution-log` automatically.
|
|
173
173
|
|
package/bin/deploy-code-only.js
CHANGED
|
@@ -54,8 +54,13 @@ function readFunctionMetadata() {
|
|
|
54
54
|
const yaml = fs.existsSync(funcYamlPath) ? fs.readFileSync(funcYamlPath, 'utf8') : '';
|
|
55
55
|
const functionName = (process.env.OCI_FUNCTION_NAME || yamlValue(yaml, 'name')).trim();
|
|
56
56
|
const appName = (process.env.OCI_FUNCTION_APP_NAME || functionName).trim();
|
|
57
|
-
const handler = (process.env.OCI_FUNCTION_HANDLER || yamlValue(yaml, 'cmd') || yamlValue(yaml, 'entrypoint')).trim();
|
|
58
57
|
const runtimeName = (process.env.OCI_CODE_ONLY_RUNTIME_NAME || '').trim();
|
|
58
|
+
const configuredHandler = (process.env.OCI_FUNCTION_HANDLER || yamlValue(yaml, 'cmd') || yamlValue(yaml, 'entrypoint')).trim();
|
|
59
|
+
// The managed Node runtime already invokes `node`; its handler is the script
|
|
60
|
+
// path, whereas a conventional func.yaml entrypoint is `node func.js`.
|
|
61
|
+
const handler = runtimeName.toLowerCase().startsWith('node')
|
|
62
|
+
? configuredHandler.replace(/^node\s+/, '')
|
|
63
|
+
: configuredHandler;
|
|
59
64
|
const memory = integerValue(process.env.OCI_FUNCTION_MEMORY_MB || yamlValue(yaml, 'memory'), 'OCI_FUNCTION_MEMORY_MB', 256);
|
|
60
65
|
const timeout = integerValue(process.env.OCI_FUNCTION_TIMEOUT_SECONDS || yamlValue(yaml, 'timeout'), 'OCI_FUNCTION_TIMEOUT_SECONDS', 30);
|
|
61
66
|
|
|
@@ -80,7 +85,7 @@ function createArchive(functionName) {
|
|
|
80
85
|
const archiveFileName = codeOnlyArchiveFileName(functionName);
|
|
81
86
|
const archivePath = path.join(projectDir, archiveFileName);
|
|
82
87
|
const archiveRoot = path.join(tempDir, 'function');
|
|
83
|
-
const excludedTopLevel = new Set(['node_modules', '.git', '.tools', '.terraform', 'cdktf.out']);
|
|
88
|
+
const excludedTopLevel = new Set(['node_modules', '.git', '.tools', '.terraform', 'cdktf.out', 'tail-function-logs.js']);
|
|
84
89
|
fs.cpSync(projectDir, archiveRoot, {
|
|
85
90
|
recursive: true,
|
|
86
91
|
filter: (sourcePath) => {
|