Git repo build URL with Docker compose

Viewed 774

I'm trying to use a git repo URL in my docker-compose.yml file, as described here. The service looks like this:

  app:
    build: "https://[MY_GITHUB_OAUTH_TOKEN]@github.com/org/repo.git#develop"

I get the following error:

$ docker-compose up
[+] Running 0/1
 ⠿ app Error                                                                   0.5s
[+] Building 0.0s (1/1) FINISHED                                                    
 => CACHED [internal] load git source https://[MY_GITHUB_OAUTH_TOKEN]  0.0s
failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount730635615/https:/[MY_GITHUB_OAUTH_TOKEN]@github.com/org/repo.git#develop/Dockerfile: no such file or directory

BUT, when I copy the exact URL from my docker-compose.yml file, I can use it with Docker build successfully. I can see all steps of the Dockerfile being executed.

$ docker build https://[MY_GITHUB_OAUTH_TOKEN]@github.com/org/repo.git#develop

There is a develop branch, [MY_GITHUB_OAUTH_TOKEN] is my actual GitHub token, and there is a valid Dockerfile (with a capital D) in the repo root. Why would this work with docker build but not docker-compose? It can't be an issue with the token, since it works with docker build.

If it matters, I'm on an M1 Mac with Docker for Mac installed. docker-compose is working fine with other services.

1 Answers

Try# - removal of double quotes

  app:
    build: https://[MY_GITHUB_OAUTH_TOKEN]@github.com/org/repo.git#develop

or this with or without double quotes

  app:
    build:
      context: https://[MY_GITHUB_OAUTH_TOKEN]@github.com/org/repo.git#develop

or this with or without double quotes

  app:
    build:
      context: https://[MY_GITHUB_OAUTH_TOKEN]@github.com/org/repo.git#develop
      dockerfile: Dockerfile
Related