loft-sh / devpod

Codespaces but open-source, client-only and unopinionated: Works with any IDE and lets you use any cloud, kubernetes or just localhost docker.
https://devpod.sh
Mozilla Public License 2.0
8.44k stars 311 forks source link

devpod build fails when using docker compose files #955

Closed dustinblackman closed 3 months ago

dustinblackman commented 4 months ago

What happened?

When using devpod build against a devcontainer that uses docker compose, the command fails with the following:

18:19:31 info #28 [oatmeal] exporting to image
18:19:31 info #28 exporting layers done
18:19:31 info #28 writing image sha256:1e6ca7c93e590a69d0d90760d90e2d8fd4d1de8ea52aeb13fee14aa894273241 done
18:19:31 info #28 naming to ghcr.io/dustinblackman/devcontainer-oatmeal:latest done
18:19:31 info #28 DONE 0.0s
18:19:31 debug Running docker command: docker push ghcr.io/dustinblackman/devcontainer-oatmeal:
18:19:31 info invalid reference format
18:19:31 error Error building image: push image: push image: exit status 1
18:19:31 info exit status 1
18:19:31 info push image

The error looks to come from here where when docker compose is used, the PrebuildHash isn't generated.

Looking at how the hash is generated, I believe a decision has to be made whether the hash generated with a docker compose file should match when built against the same file without docker compose, or I've misunderstood the logic due to lack of context.

What did you expect to happen instead?

devpod build should be able to generate a hash when using docker-compose, and then run successfully.

How can we reproduce the bug? (as minimally and precisely as possible)

I have a branch on an open source project that can be used to reproduce here.

devpod build --platform linux/arm64 --debug .

Otherwise, the important parts:

My devcontainer.json:

{
  "name": "oatmeal",
  "dockerComposeFile": "./docker-compose.yml",
  "service": "oatmeal",
  "workspaceFolder": "/workspace",
  "shutdownAction": "stopCompose",
  "postCreateCommand": "/workspace/.devcontainer/start.sh",
  "remoteUser": "oatmeal",
  "features": {
    "ghcr.io/dustinblackman/devcontainer-features/base:latest": {}
  },
  "customizations": {
    "devpod": {
      "prebuildRepository": "ghcr.io/dustinblackman/devcontainer-oatmeal"
    }
  }
}

docker-compose.yml

version: "3"
services:
  oatmeal:
    build:
      context: .
      dockerfile: ./Dockerfile
    command: /bin/sh -c "trap :; TERM INT; sleep infinity & wait"
    environment:
      OATMEAL_OLLAMA_URL: http://host.docker.internal:11434
    volumes:
      - ..:/workspace
      - cargo_target:/workspace/target
volumes:
  cargo_target:

Local Environment:

DevPod Provider:

Anything else we need to know?

Happy to put up a PR for this during any free time I can make if I can get some guidance on the right solution. :)

pascalbreuninger commented 4 months ago

Hey @dustinblackman, thanks for reporting the issue, we'll look into it!

edulix commented 3 months ago

I'm getting the same error BTW

89luca89 commented 3 months ago

Hi @dustinblackman @edulix

I've opened a draft PR for a quick fix of this https://github.com/loft-sh/devpod/pull/967 Can you test if this fixes your situation?

Thanks!