Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Wrong build context path in existing container template #280

@holms

Description

@holms
  • VSCode Version:
holms@debian ~/D/c/s/app-prebid-config> code-insiders --version
1.44.0-insider
2aae1f26c72891c399f860409176fe435a154b13
x64
  • Local OS Version: Debian latest
  • Name of Dev Container Definition with Issue: go

Steps to Reproduce:

  1. Create custom Dockerfile in .devcontainer folder.
  2. Uncomment step which says context: . in .devcontainer/docker-compose.yml
    # Uncomment if you want to add a different Dockerfile in the .devcontainer folder
    # build:
    # context: .
    # dockerfile: Dockerfile
  3. Launch docker-compose -f docker-compose.yml -f .devcontainer/docker-compose.yml build
  4. See the world burn: ERROR: Cannot locate specified Dockerfile: Dockerfile

This seems to be a bug in a docker-compose. I've already registered in here: docker/compose#7350

I'm not sure is this indented behavior, or not. What is happening is that if you'd do docker-compose -f docker-compose.yml -f .devcontainer/docker-compose.yml config you'd see build context showing to a folder where docker-compose.yml is located, although in my opinion context should point to CWD of the config which overrides previous one. I'm pretty sure you've though it's using CWD (or maybe it was working this way before).
This is an issue on RC and also latest stable release. So if I use your provided build context: . this won't work, Dockerfile won't be found, you need to put into build context this:./.devcontainer/, then it works fine.

Here's first config docker-compose.yml

 app-prebid-config:
        container_name: app-prebid-config
        build:
            context: app 
            dockerfile: Dockerfile
        volumes:
            - ./app:/app/prebid-config

Here's .devcontainer/docker-compose.yml

version: '3.7'
services:
    app-prebid-config:
        build:
            context: .
            dockerfile: Dockerfile
        volumes:
            - ./app:/workspace:cached
        cap_add:
            - SYS_PTRACE
        security_opt:
            - seccomp:unconfined
        command: /bin/sh -c "while sleep 1000; do:; done"

Now let's see what config command shows:

$ docker-compose  --project-name app-prebid-config -f docker-compose.yml -f .devcontainer/docker-compose.extend.yml  config
....
  app-prebid-config:
    build:
      context: /home/holms/Dev/contracts/setupad/app-prebid-config
      dockerfile: Dockerfile
...

And of course the build would fail:

holms@debian ~/D/c/s/app-prebid-config> docker-compose  --project-name app-prebid-config -f docker-compose.yml -f .devcontainer/docker-compose.extend.yml  build
Building app-prebid-config
ERROR: Cannot locate specified Dockerfile: Dockerfile

As no Dockerfile exist near docker-compose.yml. And I believe anyone would want to use .devcontainer/Dockerfile in the first place in your overriden docker-compose config, as it contains all custom tools for debuging golang specifically for vscode. In docker-compose.yml I'm using default Dockerfile location which is a Dockerfile for CI only, and checking it it's builds locally is quite healthy for a developer I believe after coding job is done, at least checking does it compile on a build stage is extremely useful.

Also created this issue in release microsoft/vscode-remote-release#2681 but I'm not sure if it's their fault, it's this template fault or docker-compose itself.
This btw might be related: #247

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions