GoogleCloudPlatform / functions-framework-dart

FaaS (Function as a service) framework for writing portable Dart functions
https://pub.dev/packages/functions_framework
Apache License 2.0
535 stars 54 forks source link

Docker images failing when deployed to cloud run when using apple silicon #332

Closed jimmyff closed 2 years ago

jimmyff commented 2 years ago

I'm using functions framework (and have been for about a year), I have build scripts that I use to deploy various cloud run images. However when I run them on my apple silicon macbook they fail to deploy:

Deploying container to Cloud Run service [test-pubsub] in project [foobar] region [us-central1]
⠛ Deploying... Cloud Run error: The user-provided container failed to start and listen on the 
port defined provided by the PORT=8080 environment variable. Logs for this revision might cont
ain more information.                                                                         
  ✓ Setting IAM Policy...                                                                     
Logs URL: https://console.cloud.google.com/logs/...
X Deploying... Cloud Run error: The user-provided container failed to start and listen on the 
port defined provided by the PORT=8080 environment variable. Logs for this revision might cont
ain more information.                                                                         

Deployment failed                                                                             
ERROR: (gcloud.beta.run.deploy) Cloud Run error: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information.

Logs URL: https://console.cloud.google.com/logs/...
For more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start
ERROR: Deploy to cloud run failed.

The logs show:


{
insertId: "62b2f38d0009fb26bc42424d"
labels: {1}
logName: "projects/foobar/logs/run.googleapis.com%2Fvarlog%2Fsystem"
receiveTimestamp: "2022-06-22T10:48:45.658708610Z"
resource: {2}
severity: "ERROR"
textPayload: "terminated: Application failed to start: Failed to create init process: failed to load /app/os_cloud_functions/bin/server: exec format error"
timestamp: "2022-06-22T10:48:45.654046480Z"
}

Before the images are deployed the script compiles and tests them. I can also run them locally and see that they do in fact startup and work as expected.

I've been back to my linux setup and confirmed that the scripts do still build and deploy correctly. The obvious discrepancy is the CPU architecture but I don't see how that should affect this?

(using Dart SDK version: 2.17.3 (stable) (Wed Jun 1 11:06:41 2022 +0200) on "macos_arm64")

kevmoo commented 2 years ago

This is likely NOT a bug here, but an issue w/ platforms. Sounds like you should build using Cloud Build. When you build locally you're building an ARM binary – then trying to deploy to x64 server.

At least that's what it appears!