create-svc 0.1.40 → 0.1.41

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-svc",
3
- "version": "0.1.40",
3
+ "version": "0.1.41",
4
4
  "description": "Local microservice bootstrap CLI for Cloud Run and Workers services with Neon-backed data.",
5
5
  "module": "index.ts",
6
6
  "type": "module",
@@ -6,6 +6,12 @@ export type DeployArgs = {
6
6
  name?: string;
7
7
  };
8
8
 
9
+ export const CLOUD_RUN_LOCAL_BUILD_PLATFORM = "linux/amd64";
10
+
11
+ export function localDockerBuildArgs(image: string) {
12
+ return ["build", "--platform", CLOUD_RUN_LOCAL_BUILD_PLATFORM, "-t", image, "."];
13
+ }
14
+
9
15
  export function parseDeployArgs(argv: string[]): DeployArgs {
10
16
  const parsed: DeployArgs = {
11
17
  build: parseBuildStrategy(process.env.SERVICE_BUILD_STRATEGY || process.env.SERVICE_BUILD),
@@ -87,4 +93,3 @@ function parseBuildStrategy(value: string | undefined): DeployArgs["build"] {
87
93
  }
88
94
  throw new Error(`Unknown build strategy: ${value}`);
89
95
  }
90
-
@@ -12,6 +12,7 @@ import {
12
12
  gcloudStreaming,
13
13
  gcloudWithRetry,
14
14
  imageUrl,
15
+ localDockerBuildArgs,
15
16
  parseDeployArgs,
16
17
  requireCommand,
17
18
  resolveDeploymentTarget,
@@ -84,7 +85,7 @@ export async function deploy(args = Bun.argv.slice(2), deployOptions: DeployOpti
84
85
  await runStep("Authenticating Docker to Artifact Registry", () =>
85
86
  gcloud(["auth", "configure-docker", `${config.region}-docker.pkg.dev`, "--quiet"])
86
87
  );
87
- await runStep("Building container image locally", () => dockerStreaming(["build", "-t", image, "."]));
88
+ await runStep("Building container image locally", () => dockerStreaming(localDockerBuildArgs(image)));
88
89
  await runStep("Pushing container image to Artifact Registry", () => dockerStreaming(["push", image]));
89
90
  }
90
91
 
@@ -1,5 +1,5 @@
1
1
  import { afterEach, expect, test } from "bun:test";
2
- import { parseDeployArgs } from "./deploy-args";
2
+ import { localDockerBuildArgs, parseDeployArgs } from "./deploy-args";
3
3
 
4
4
  const originalBuild = process.env.SERVICE_BUILD;
5
5
  const originalBuildStrategy = process.env.SERVICE_BUILD_STRATEGY;
@@ -27,3 +27,14 @@ test("parseDeployArgs accepts build strategy from env", () => {
27
27
 
28
28
  expect(parseDeployArgs([]).build).toBe("cloudbuild");
29
29
  });
30
+
31
+ test("local Docker builds target Cloud Run's runtime platform", () => {
32
+ expect(localDockerBuildArgs("us-west1-docker.pkg.dev/example/services/api:latest")).toEqual([
33
+ "build",
34
+ "--platform",
35
+ "linux/amd64",
36
+ "-t",
37
+ "us-west1-docker.pkg.dev/example/services/api:latest",
38
+ ".",
39
+ ]);
40
+ });
@@ -2,7 +2,7 @@ import { intro, log, outro, spinner } from "@clack/prompts";
2
2
  import { join } from "node:path";
3
3
  import { config } from "./config";
4
4
  import { serviceRoot } from "../runtime";
5
- import { parseDeployArgs, type DeployArgs } from "./deploy-args";
5
+ import { localDockerBuildArgs, parseDeployArgs, type DeployArgs } from "./deploy-args";
6
6
 
7
7
  type CommandOptions = {
8
8
  allowFailure?: boolean;
@@ -452,7 +452,7 @@ export function imageUrl(tag = imageTag()) {
452
452
  return `${artifactImageBase()}:${tag}`;
453
453
  }
454
454
 
455
- export { parseDeployArgs };
455
+ export { localDockerBuildArgs, parseDeployArgs };
456
456
 
457
457
  export function parseCleanupArgs(argv: string[]): CleanupArgs {
458
458
  const parsed: CleanupArgs = {
@@ -74,6 +74,8 @@ Local provisioning intentionally prefers known-good CLIs over SDKs for Google Cl
74
74
  Cloud Run deploys build and push the container image locally by default. Use
75
75
  `service deploy --build cloudbuild` only when you explicitly want Google Cloud
76
76
  Build to build the image remotely.
77
+ Local Docker builds target `linux/amd64` so images built on Apple Silicon run on
78
+ Cloud Run.
77
79
 
78
80
  Authenticate `gcloud` on the machine before running provisioning commands:
79
81