Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

functions deploy uses container path in host resulting in files not found and failure to deploy #2535

Closed
alita-moore opened this issue Jul 19, 2024 · 2 comments

Comments

@alita-moore
Copy link

Describe the bug
When you develop a supabase project inside of a devcontainer volume functions deploy will fail to deploy because it attempts to find the files on the host under the same path. However, because these are not necessarily the same it causes it to fail. Local development appears to work normally.

To Reproduce
See the following codesandbox. You may setup a sample project to test deployment, but the project demonstrates the devcontainer layout I'm referring to. If you deploy in this environment it will fail to find the files in the host's filesystem.

Expected behavior
I expect the deploy script to either pull files from the devcontainer directly or find the respective mapping from the docker container's volume.

System information
Rerun the failing command with --create-ticket flag.

  • Version of OS: Ubuntu 23.10
  • Version of CLI: v1.183.5
  • Version of Docker: Docker version 27.0.3, build 7d4bcd8
  • Versions of services:
    SERVICE IMAGE │ LOCAL │ LINKED
    ─────────────────────────┼──────────────────┼────────────
    supabase/postgres │ 15.1.1.78 │ 15.1.1.78
    supabase/gotrue │ v2.155.3 │ v2.155.3
    postgrest/postgrest │ v12.2.2 │ v12.2.2
    supabase/realtime │ v2.29.15 │ -
    supabase/storage-api │ v1.6.8 │ v1.6.8
    supabase/edge-runtime │ v1.54.10 │ -
    supabase/studio │ 20240701-05dfbec │ -
    supabase/postgres-meta │ v0.83.2 │ -
    supabase/logflare │ 1.4.0 │ -
    supabase/supavisor │ 1.1.56 │ -
    darthsim/imgproxy │ v3.8.0 │ -

Here's the debugging output:

 npx supabase functions deploy --create-ticket --debug
Supabase CLI 1.183.5
Bundling api-consumers
2024/07/19 07:44:03 Sent Header: Host [api.moby.localhost]
2024/07/19 07:44:03 Sent Header: User-Agent [Docker-Client/unknown-version (linux)]
2024/07/19 07:44:03 Send Done
2024/07/19 07:44:03 Recv First Byte
2024/07/19 07:44:03 Sent Header: Host [api.moby.localhost]
2024/07/19 07:44:03 Sent Header: User-Agent [Docker-Client/unknown-version (linux)]
2024/07/19 07:44:03 Sent Header: Content-Length [333]
2024/07/19 07:44:03 Sent Header: Content-Type [application/json]
2024/07/19 07:44:03 Send Done
2024/07/19 07:44:03 Recv First Byte
2024/07/19 07:44:03 Sent Header: Host [api.moby.localhost]
2024/07/19 07:44:03 Sent Header: User-Agent [Docker-Client/unknown-version (linux)]
2024/07/19 07:44:03 Sent Header: Content-Length [158]
2024/07/19 07:44:03 Sent Header: Content-Type [application/json]
2024/07/19 07:44:03 Send Done
2024/07/19 07:44:03 Recv First Byte
2024/07/19 07:44:03 Sent Header: Host [api.moby.localhost]
2024/07/19 07:44:03 Sent Header: User-Agent [Docker-Client/unknown-version (linux)]
2024/07/19 07:44:03 Sent Header: Content-Length [2812]
2024/07/19 07:44:03 Sent Header: Content-Type [application/json]
2024/07/19 07:44:03 Send Done
2024/07/19 07:44:03 Recv First Byte
2024/07/19 07:44:03 Sent Header: Host [api.moby.localhost]
2024/07/19 07:44:03 Sent Header: User-Agent [Docker-Client/unknown-version (linux)]
2024/07/19 07:44:03 Sent Header: Content-Length [0]
2024/07/19 07:44:03 Send Done
2024/07/19 07:44:03 Recv First Byte
2024/07/19 07:44:03 Sent Header: Host [api.moby.localhost]
2024/07/19 07:44:03 Sent Header: User-Agent [Docker-Client/unknown-version (linux)]
2024/07/19 07:44:03 Send Done
2024/07/19 07:44:03 Recv First Byte
Error: entrypoint path does not exist (/Users/alitamoore/workspaces2/monorepo/infra/supabase-platform/supabase/functions/api-consumers/index.ts)
2024/07/19 07:44:03 Sent Header: Host [api.moby.localhost]
2024/07/19 07:44:03 Sent Header: User-Agent [Docker-Client/unknown-version (linux)]
2024/07/19 07:44:03 Send Done
2024/07/19 07:44:03 Recv First Byte
error running container: exit 1
@sweatybridge
Copy link
Contributor

Unfortunately it's not possible to support this on every OS because the edge runtime binary is only built for linux. So mounting functions directory into the edge runtime container is the least we can do.

But since you are using Ubuntu, an alternative is to write some custom go code to deploy using the edge runtime binary natively. We have published an example here in case you are interested
https://github.com/supabase/cli/blob/develop/examples/functions-deploy/main.go

@sweatybridge sweatybridge closed this as not planned Won't fix, can't repro, duplicate, stale Aug 6, 2024
@alita-moore
Copy link
Author

alita-moore commented Aug 8, 2024

For reference my work-around for this has been to make the working directory within my devcontainer match the directory in the host, due to mac's System Integrity Protection (SIP) it's not possible to create a directory on the host that matches within the container (for example, if you had mounted to path /workspaces/app). So instead you'll need to create a directory in the mac user folder and mount off of that within the devcontainer.

# docker-compose.yaml
services:
  workstation:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - ${HOME}/workspaces:${HOME}/workspaces

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants