sst 2.21.0 → 2.21.1

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.
@@ -510,20 +510,15 @@ export interface JavaProps {
510
510
  }
511
511
  export interface ContainerProps {
512
512
  /**
513
- * Configure docker build options
514
- *
513
+ * Specify or override the CMD on the Docker image.
515
514
  * @example
516
515
  * ```js
517
516
  * container: {
518
- * docker: {
519
- * cmd: ["executable", "param1", "param2"]
520
- * }
517
+ * cmd: ["index.handler"]
521
518
  * }
522
519
  * ```
523
520
  */
524
- docker: {
525
- cmd?: string[];
526
- };
521
+ cmd?: string[];
527
522
  }
528
523
  /**
529
524
  * Used to configure additional files to copy into the function bundle
@@ -208,6 +208,7 @@ export class Function extends CDKFunction {
208
208
  ...(architecture?.dockerPlatform
209
209
  ? { platform: Platform.custom(architecture.dockerPlatform) }
210
210
  : {}),
211
+ ...(props.container?.cmd ? { cmd: props.container.cmd } : {}),
211
212
  }),
212
213
  handler: CDKHandler.FROM_IMAGE,
213
214
  runtime: CDKRuntime.FROM_IMAGE,
@@ -12,26 +12,32 @@ export interface JobNodeJSProps extends NodeJSProps {
12
12
  }
13
13
  export interface JobContainerProps {
14
14
  /**
15
- * Configure docker build options
16
- *
15
+ * Specify or override the CMD on the Docker image.
17
16
  * @example
18
17
  * ```js
19
18
  * container: {
20
- * docker: {
21
- * cmd: ["executable", "param1", "param2"]
22
- * }
19
+ * cmd: ["python3", "my_script.py"]
23
20
  * }
24
21
  * ```
25
22
  */
26
- docker: {
27
- cmd: string[];
28
- };
23
+ cmd: string[];
29
24
  }
30
25
  export interface JobProps {
26
+ /**
27
+ * The runtime environment for the job.
28
+ * @default "nodejs"
29
+ * @example
30
+ * ```js
31
+ * new Function(stack, "Function", {
32
+ * runtime: "container",
33
+ * handler: "src/job",
34
+ * })
35
+ *```
36
+ */
31
37
  runtime?: "nodejs" | "container";
32
38
  /**
33
- * Path to the entry point and handler function. Of the format:
34
- * `/path/to/file.function`.
39
+ * For "nodejs" runtime, point to the entry point and handler function.
40
+ * Of the format: `/path/to/file.function`.
35
41
  *
36
42
  * @example
37
43
  * ```js
@@ -39,6 +45,17 @@ export interface JobProps {
39
45
  * handler: "src/job.handler",
40
46
  * })
41
47
  *```
48
+ *
49
+ * For "container" runtime, point the handler to the directory containing
50
+ * the Dockerfile.
51
+ *
52
+ * @example
53
+ * ```js
54
+ * new Job(stack, "MyJob", {
55
+ * runtime: "container",
56
+ * handler: "src/job", // Dockerfile is at "src/job/Dockerfile"
57
+ * })
58
+ *```
42
59
  */
43
60
  handler: string;
44
61
  /**
@@ -281,5 +298,4 @@ export declare class Job extends Construct implements SSTConstruct {
281
298
  private normalizeMemorySize;
282
299
  private normalizeTimeout;
283
300
  private convertJobRuntimeToFunctionRuntime;
284
- private convertJobContainerToFunctionContainer;
285
301
  }
package/constructs/Job.js CHANGED
@@ -47,7 +47,6 @@ export class Job extends Construct {
47
47
  this.id = id;
48
48
  this.props = props;
49
49
  const isLiveDevEnabled = app.mode === "dev" && (this.props.enableLiveDev === false ? false : true);
50
- // TODO add test
51
50
  this.validateContainerProps();
52
51
  this.job = this.createCodeBuildJob();
53
52
  if (!stack.isActive) {
@@ -169,7 +168,6 @@ export class Job extends Construct {
169
168
  const fn = new Function(this, this.node.id, {
170
169
  ...this.props,
171
170
  runtime: this.convertJobRuntimeToFunctionRuntime(),
172
- container: this.convertJobContainerToFunctionContainer(),
173
171
  memorySize: 1024,
174
172
  timeout: "10 seconds",
175
173
  environment: {
@@ -223,7 +221,7 @@ export class Job extends Construct {
223
221
  "phases:",
224
222
  " build:",
225
223
  " commands:",
226
- ` - ${container.docker.cmd
224
+ ` - ${container.cmd
227
225
  .map((arg) => (arg.includes(" ") ? `"${arg}"` : arg))
228
226
  .join(" ")}`,
229
227
  ].join("\n"),
@@ -379,14 +377,4 @@ export class Job extends Construct {
379
377
  const { runtime } = this.props;
380
378
  return runtime === "container" ? "container" : "nodejs16.x";
381
379
  }
382
- convertJobContainerToFunctionContainer() {
383
- const { runtime, container } = this.props;
384
- if (runtime !== "container")
385
- return;
386
- return {
387
- docker: {
388
- cmd: container?.docker.cmd,
389
- },
390
- };
391
- }
392
380
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.21.0",
4
+ "version": "2.21.1",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },
@@ -133,7 +133,9 @@ export const useContainerHandler = Context.memo(async () => {
133
133
  containers.set(input.workerID, name);
134
134
  }
135
135
  function startLambdaWorker(input) {
136
+ const fn = useFunctions().fromID(input.functionID);
136
137
  dockerRun(input, {
138
+ cmd: fn?.container?.cmd,
137
139
  envs: {
138
140
  AWS_LAMBDA_RUNTIME_API: `host.docker.internal:${server.port}/${input.workerID}`,
139
141
  },
@@ -147,14 +149,14 @@ export const useContainerHandler = Context.memo(async () => {
147
149
  // - on `sst deploy`, the CodeBuild job is started with `SST_PAYLOAD` env var
148
150
  // - on `sst dev`, set `SST_DEBUG_JOB` env var here
149
151
  // 2. Worker exits at the end of the run.
150
- const fn = useFunctions().fromID(input.functionID);
151
152
  // Fetch request
152
153
  const result = await init();
153
154
  const awsRequestId = result.headers["lambda-runtime-aws-request-id"];
155
+ const fn = useFunctions().fromID(input.functionID);
154
156
  try {
155
157
  dockerRun(input, {
156
158
  entrypoint: "",
157
- cmd: fn?.container?.docker.cmd,
159
+ cmd: fn?.container?.cmd,
158
160
  envs: {
159
161
  SST_PAYLOAD: result.body,
160
162
  },
package/sst.mjs CHANGED
@@ -5853,9 +5853,11 @@ var init_container = __esm({
5853
5853
  containers.set(input.workerID, name);
5854
5854
  }
5855
5855
  function startLambdaWorker(input) {
5856
+ const fn = useFunctions3().fromID(input.functionID);
5856
5857
  dockerRun(
5857
5858
  input,
5858
5859
  {
5860
+ cmd: fn?.container?.cmd,
5859
5861
  envs: {
5860
5862
  AWS_LAMBDA_RUNTIME_API: `host.docker.internal:${server.port}/${input.workerID}`
5861
5863
  }
@@ -5866,15 +5868,15 @@ var init_container = __esm({
5866
5868
  );
5867
5869
  }
5868
5870
  async function startJobWorker(input) {
5869
- const fn = useFunctions3().fromID(input.functionID);
5870
5871
  const result = await init();
5871
5872
  const awsRequestId = result.headers["lambda-runtime-aws-request-id"];
5873
+ const fn = useFunctions3().fromID(input.functionID);
5872
5874
  try {
5873
5875
  dockerRun(
5874
5876
  input,
5875
5877
  {
5876
5878
  entrypoint: "",
5877
- cmd: fn?.container?.docker.cmd,
5879
+ cmd: fn?.container?.cmd,
5878
5880
  envs: {
5879
5881
  SST_PAYLOAD: result.body
5880
5882
  }