8000 YAML is not parsed correctly · Issue #98 · whoan/docker-build-with-cache-action · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
YAML is not parsed correctly #98
Closed
@blampe

Description

@blampe

I originally discovered this as a bug where a docker-compose file containing image: would also require setting build: context:

For example, this docker-compose file should build successfully:

version: "3"
services:
  nginx:
    image: registry.hub.docker.com/library/nginx

using this workflow:

name: foo
jobs:
  foo:
    steps:
      - uses: whoan/docker-build-with-cache-action@v5.11.1
        with:
          registry: registry.hub.docker.com
          compose_file: docker-compose.yml

however it fails with the following:

[Compose file] Building image: registry.hub.docker.com/library/nginx
Failed to get context

Expanding the docker-compose to

version: "3"
services:
  nginx:
    image: registry.hub.docker.com/library/nginx
    build:
      context: .

resolves the issue, but this should not be needed -- we have all of the information we need to build the image.

After poking around more I realized this is due to how the tool attempts to parse YAML, which ultimately creates a number of additional bugs:

  • Adding additional but valid spaces in front of the foo example above causes a failure with Failed to get service name, because the parser doesn't account for inconsistent indentation levels (valid in YAML).
  • Adding a comment anywhere after a key causes the entire line to be consumed by the tool. So for example image: nginx # ignore me attempts to fetch an image called nginx # ignore me from the registry.

Instead of trying to re-implement YAML parsing, the tool should instead consume the compose file via an existing YAML parser. This would simplify service & registry discovery and make for a more user-friendly API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0