Skip to content

Commit 45cb786

Browse files
nicktrnericallam
authored andcommitted
add network flag for self-hosting
1 parent ebfffff commit 45cb786

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

docs/snippets/cli-commands-deploy.mdx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ These options are available on most commands.
8181

8282
These options are typically used when [self-hosting](/open-source-self-hosting) or for local development.
8383

84-
<ParamField body="Skip deploying the image" type="--skip-deploy | -D">
85-
Load the built image into your local docker.
86-
</ParamField>
87-
8884
<ParamField body="Self-hosted (builds locally)" type="--self-hosted">
8985
Builds and loads the image using your local docker. Use the `--registry` option to specify the
9086
registry to push the image to when using `--self-hosted`, or just use `--push` to push to the
9187
default registry.
9288
</ParamField>
9389

90+
<ParamField body="Skip deploying the image" type="--skip-deploy | -D">
91+
Load the built image into your local docker.
92+
</ParamField>
93+
9494
<ParamField body="Load image" type="--load-image">
9595
Loads the image into your local docker after building it.
9696
</ParamField>
@@ -108,6 +108,10 @@ These options are typically used when [self-hosting](/open-source-self-hosting)
108108
Hub, the namespace is your Docker Hub username.
109109
</ParamField>
110110

111+
<ParamField body="Network" type="--network">
112+
The networking mode for RUN instructions when using `--self-hosted`.
113+
</ParamField>
114+
111115
## Examples
112116

113117
### Push to Docker Hub (self-hosted)

packages/cli-v3/src/commands/deploy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const DeployCommandOptions = CommonCommandOptions.extend({
5555
skipUpdateCheck: z.boolean().default(false),
5656
noCache: z.boolean().default(false),
5757
envFile: z.string().optional(),
58+
network: z.enum(["default", "none", "host"]).optional(),
5859
});
5960

6061
type DeployCommandOptions = z.infer<typeof DeployCommandOptions>;
@@ -144,6 +145,7 @@ export function configureDeployCommand(program: Command) {
144145
"If provided, will save logs even for successful builds"
145146
).hideHelp()
146147
)
148+
.option("--network <mode>", "The networking mode for RUN instructions when using --self-hosted")
147149
.action(async (path, options) => {
148150
await handleTelemetry(async () => {
149151
await printStandloneInitialBanner(true);
@@ -349,6 +351,7 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) {
349351
authAccessToken: authorization.auth.accessToken,
350352
compilationPath: destination.path,
351353
buildEnvVars: buildManifest.build.env,
354+
network: options.network,
352355
});
353356

354357
logger.debug("Build result", buildResult);

packages/cli-v3/src/deploy/buildImage.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface BuildImageOptions {
1414
// Self-hosted specific options
1515
push: boolean;
1616
registry?: string;
17+
network?: string;
1718

1819
// Non-self-hosted specific options
1920
loadImage?: boolean;
@@ -84,6 +85,7 @@ export async function buildImage(options: BuildImageOptions) {
8485
apiUrl,
8586
apiKey,
8687
buildEnvVars,
88+
network: options.network,
8789
});
8890
}
8991

@@ -277,6 +279,7 @@ interface SelfHostedBuildImageOptions {
277279
noCache?: boolean;
278280
extraCACerts?: string;
279281
buildEnvVars?: Record<string, string | undefined>;
282+
network?: string;
280283
}
281284

282285
async function selfHostedBuildImage(
@@ -295,6 +298,7 @@ async function selfHostedBuildImage(
295298
options.noCache ? "--no-cache" : undefined,
296299
"--platform",
297300
options.buildPlatform,
301+
...(options.network ? ["--network", options.network] : []),
298302
"--build-arg",
299303
`TRIGGER_PROJECT_ID=${options.projectId}`,
300304
"--build-arg",

0 commit comments

Comments
 (0)