docker-build-with-cache-action
docker-build-with-cache-action copied to clipboard
build_extra_args json syntax does not handle multiple args
Using this Dockerfile
:
FROM ubuntu:20.04 as test_image
ARG BRANCH
ARG ENV_NAME
RUN echo "${BRANCH}"
RUN echo "${ENV_NAME}"
And this workflow:
name: Test
on:
push:
paths:
- ".github/workflows/test.yml"
- "build/Dockerfile"
jobs:
build-test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build test image
uses: whoan/docker-build-with-cache-action@v5
with:
image_name: test_image
build_extra_args: '{"--build-arg": "BRANCH=foo", "--build-arg": "ENV_NAME=haha"}'
dockerfile: build/Dockerfile
push_image_and_stages: false
It seems that the build arguments are not passed correctly: only the last one is kept. Below is the docker command line issued from the run of this workflow.
docker build --tag my_awesome_image --file ./build/Dockerfile --build-arg ENV_NAME=haha .
Is it because of a wrong syntax in the json
description of arguments ? It seems to be working fine for a single argument but I haven't been able to make it work for more than one.
Thanks for your help.
I wrote something to fix the issue (see https://github.com/jschmidtnj/docker-build-with-cache-action/commit/562d9b5fb9d7816f93a3526a4aaa79859b850403). It's sort of a hack, but I couldn't figure out a way to get jq to accept duplicate keys (see https://github.com/stedolan/jq/issues/1636). to use it, just append -0
, or a dash followed by any unique number, to the end of a duplicated flag. for 2 build-args, it would be --build-arg-0
and --build-arg-1
, etc.
Hi guys I'm facing the same error, Do we have any update on this?
- INPUT:
- OUTPUT:
Using --build-arg-0
is not either working:
- INPUT:
- OUTPUT: