balena-io / balena-cli

The official balena CLI tool.
Apache License 2.0
455 stars 143 forks source link

Build emulation does not work on non standard Dockerfile names in compose files #1707

Open mwohlert opened 4 years ago

mwohlert commented 4 years ago

The build emulation now works for dockerfiles, however if this is referenced in a Dockerfile build emulation will not be used.

Dockerfile.debug:

FROM balenalib/armv7hf-debian:latest
RUN echo 'hello world'

docker-compose.yml:

version: '2.1'
services:
  hello:
    container_name: hello
    build:
      context: .
      dockerfile: Dockerfile.debug
mwohlert commented 4 years ago

Related to #1624

jellyfish-bot commented 4 years ago

[jimsynz] This issue has attached support thread https://jel.ly.fish/757ef169-a9ec-4437-b892-dee5df28f72a

jimsynz commented 4 years ago

As per the above linked support thread; this bug also affects users which set the build's dockerfile value to anything at all.

For example, the following docker-compose.yml fails:

version: "2"

services:
  with_template:
    build:
      context: .
      dockerfile: ./services/with_template/Dockerfile.template

  without_template:
    build:
      context: .
      dockerfile: ./services/without_template/Dockerfile
Info]    Building for aarch64/raspberrypi4-64
[Build]   Building services...
[Build]   with_template    Preparing...
[Build]   without_template Preparing...
[Info]    Emulation is enabled
[Build]   with_template    Step 1/3 : FROM balenalib/raspberrypi4-64-debian:latest
[Build]   with_template     ---> 772fa2eae48a
[Build]   with_template    Step 2/3 : RUN "Dockerfile.template" > /wat
[Build]   with_template     ---> Running in 3163eafeb5e8
[Build]   with_template    standard_init_linux.go:211: exec user process caused "exec format error"
[Build]   without_template Step 1/3 : FROM balenalib/rpi-debian:latest
[Build]   without_template  ---> 4b18c0dfa46b
[Build]   without_template Step 2/3 : RUN echo "Dockerfile" > /tmp/wat
[Build]   without_template  ---> Running in 3300b50680cb
[Build]   without_template standard_init_linux.go:211: exec user process caused "exec format error"
[Build]   Built 2 services in 0:21
[Error]   Build failed
The command '/bin/sh -c "Dockerfile.template" > /wat' returned a non-zero code: 1