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

stringified boolean build arg not working in docker-compose.yml; must be a string, number or null #842

Closed
Evesy opened this issue Nov 16, 2021 · 2 comments

Comments

@Evesy
Copy link

Evesy commented Nov 16, 2021

We have a docker-compose.yml that specifies a build argument that is pulled from a boolean environment variable of false, but is explicitly quoted in docker-compose.yml.

When running a build with docker buildx bake we receive an error that the argument must be a string, number of null

Below is a minimal reproducible example that outlines the issue:

Dockerfile

FROM centos:8

ARG TEST_BOOLEAN
RUN echo $TEST_BOOLEAN

docker-compose.yml

version: '3.2'

services:
  app:
    image: "test-boolean"
    restart: always
    user: root
    build:
      context: .
      dockerfile: Dockerfile
      args:
        TEST_BOOLEAN: "${TEST_BOOLEAN}"

If we set export TEST_BOOLEAN=false and then run docker buildx bake it fails with the below:

[+] Building 0.0s (0/0)
error: services.app.build.args.TEST_BOOLEAN must be a string, number or null

This is the same if we export it as false, 'false' or "false".

Exporting export TEST_BOOLEAN='"false"' appears to work.

If we instead change docker-compose.yml to hardcode the false value (rather than pull from env var) as per below, the build succeeds:

version: '3.2'

services:
  app:
    image: "test-boolean"
    restart: always
    user: root
    build:
      context: .
      dockerfile: Dockerfile
      args:
        TEST_BOOLEAN: "false"

We are seeing the error on buildx version 0.6.3. On an older version, 0.5.1, the issue is not present

Perhaps related to either https://github.com/docker/buildx/pull/669/files or https://github.com/docker/buildx/pull/704/files

@crazy-max
Copy link
Member

crazy-max commented Nov 16, 2021

@Evesy Looking at the compose-spec, args is a list_or_dict so can be string, number, boolean or null. Previously boolean was not part of it but has been fixed since compose-spec/compose-go#162. So it should be available since buildx 0.7.0 (#832). Can you try with the latest release?

@Evesy
Copy link
Author

Evesy commented Nov 16, 2021

Thanks @crazy-max -- You're correct, 0.7.0 looks to fix it, appreciate the help

@Evesy Evesy closed this as completed Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants