Skip to content

Commit

Permalink
feat(sdk): add volumes prop to sim.Container
Browse files Browse the repository at this point in the history
Allows defining volume mount points for the container.
  • Loading branch information
skyrpex committed Apr 16, 2024
1 parent 3936dcd commit cf06b6c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libs/wingsdk/src/target-sim/container.inflight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ export class Container implements IContainerClient, ISimulatorResourceInstance {
}
}

for (const volume of this.props.volumes ?? []) {
dockerRun.push("-v");
dockerRun.push(volume);
}

dockerRun.push(this.imageTag);

for (const a of this.props.args ?? []) {
Expand Down
8 changes: 8 additions & 0 deletions libs/wingsdk/src/target-sim/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ export interface ContainerProps {
*/
readonly env?: Record<string, string>;

/**
* Volume mount points.
* @default []
* @example ['/host:/container']
*/
readonly volumes?: string[];

/**
* Container arguments
* @default []
Expand Down Expand Up @@ -105,6 +112,7 @@ export class Container extends Resource implements ISimulatorResource {
imageTag: this.imageTag,
containerPort: this.props.containerPort,
env: this.props.env,
volumes: this.props.volumes,
args: this.props.args,
cwd: App.of(this).entrypointDir,
};
Expand Down
1 change: 1 addition & 0 deletions libs/wingsdk/src/target-sim/schema-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ export interface ContainerSchema {
readonly image: string;
readonly containerPort?: number;
readonly env?: Record<string, string>;
readonly volumes?: string[];
readonly args?: string[];
readonly cwd: string;
}
Expand Down

0 comments on commit cf06b6c

Please sign in to comment.