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

docker-compose: Support absolute path to Dockerfile in docker-compose build #4775

Merged
merged 1 commit into from Jul 20, 2021

Conversation

meshulam
Copy link
Contributor

The Docker Compose V2 beta (enabled by default in the latest Docker for Mac) resolves absolute paths for build Dockerfiles in the output of docker-compose config.

Old behavior:

❯ cat docker-compose.yml
version: '3'
services:
  foo:
    build:
      context: ../foo
      dockerfile: Dockerfile

❯ docker-compose disable-v2
❯ docker-compose version
docker-compose version 1.29.2, build 5becea4c
docker-py version: 5.0.0
CPython version: 3.9.0
OpenSSL version: OpenSSL 1.1.1h  22 Sep 2020
❯ docker-compose config
services:
  foo:
    build:
      context: /Users/mattm/dev/foo
      dockerfile: Dockerfile
version: '3'

New behavior:

❯ docker-compose enable-v2
❯ docker-compose version
Docker Compose version v2.0.0-beta.6
❯ docker-compose config
services:
  foo:
    build:
      context: /Users/mattm/dev/foo
      dockerfile: /Users/mattm/dev/foo/Dockerfile
    networks:
      default: null
networks:
  default:
    name: tilt_default

This was always allowed according to the Compose File spec, but Tilt assumes the Dockerfile is relative and unconditionally joins it to the context dir.

This PR adds support for absolute paths to Dockerfiles, whether explicitly configured in the docker-compose.yml or as emitted by Compose V2.

@ebenoist
Copy link
Contributor

@meshulam thanks for doing this!

Copy link
Member

@nicks nicks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@nicks nicks merged commit 477aad4 into tilt-dev:master Jul 20, 2021
@meshulam meshulam deleted the absolute-dockerfile-paths branch July 20, 2021 21:13
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

Successfully merging this pull request may close these issues.

None yet

3 participants