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

Build Args do not work #14

Open
grab-a-byte opened this issue Mar 18, 2022 · 17 comments
Open

Build Args do not work #14

grab-a-byte opened this issue Mar 18, 2022 · 17 comments

Comments

@grab-a-byte
Copy link

grab-a-byte commented Mar 18, 2022

I am trying to pass build args to this action and it does not seem to want to work. I have tried with quotes, without quotes, nothing I try seems to be working.

Build here shows using linx-x86: https://github.com/parkeradam/DDNSUpdate/runs/5602781210?check_suite_focus=true
Action file has build arg specified as linux-arm : https://github.com/parkeradam/DDNSUpdate/blob/4683dbd1d51be6ec0c41cd98a5c421ba3be29044/.github/workflows/arm-build.yml

Am i missing something?

Thanks in advance.

@patrickserrano
Copy link

@parkeradam did you ever find a workaround for this?

@VaultVulp
Copy link
Owner

VaultVulp commented Oct 1, 2022

@patrickserrano @parkeradam Sorry for the late response.

I think the source of this issue is the spaces inside of the custom-args: value.

Ex: custom-args: "--build-arg arg='value'" should work, but custom-args: "--build-arg arg='va lue'" wouldn't.

@patrickserrano could you please share your custom-args: value?

@grab-a-byte
Copy link
Author

I dont think any of my custom args has spaces or does this include the soace etween the individual build args?

@VaultVulp
Copy link
Owner

Thanks for the response, @parkeradam!

My previous comment is a bit misleading - I should have provided a different example.

In any case:
I can acces the second link (https://github.com/parkeradam/DDNSUpdate/blob/4683dbd1d51be6ec0c41cd98a5c421ba3be29044/.github/workflows/arm-build.yml)
with the following custom-arg:

custom-args: --build-arg "APP_BUILD_RUNTIME=linux-arm" --build-arg "DOCKER_BUILD_RUNTIME=mcr.microsoft.com/dotnet/runtime:6.0.3-bullseye-slim-arm64v8" --build-arg "DOCKER_BUILD_SDK=mcr.microsoft.com/dotnet/sdk:6.0.201-bullseye-slim-arm64v8"

In this case, I think the correct value for the custom-args: should be:

custom-args: --build-arg=APP_BUILD_RUNTIME="linux-arm" --build-arg=DOCKER_BUILD_RUNTIME="mcr.microsoft.com/dotnet/runtime:6.0.3-bullseye-slim-arm64v8" --build-arg=DOCKER_BUILD_SDK="mcr.microsoft.com/dotnet/sdk:6.0.201-bullseye-slim-arm64v8"

Note that I've added = after each --build-arg and moved each opening quote to wrap values only.

I'm not 100% sure about this, but from my tests it should work.

Could you, @patrickserrano , please, update your pipeline and check this?

@VaultVulp
Copy link
Owner

If you want and when you have spare time, of course. No pressure.

@grab-a-byte
Copy link
Author

Apologies, just seen this! Will give this a try hopefully within the next couple of week, been busy! Will keep you uodated. Thanks for the help on this :)

@VaultVulp
Copy link
Owner

VaultVulp commented Oct 21, 2022

Btw, recently I published a new version of this action.
I tried to rework agruments pass-through in it to make it more reliable.

@grab-a-byte
Copy link
Author

I've tried with and without quotes on the build args and without quotes seemd to get me further but then failed to build the container, unsure if its actually picked up the dotnet build.
https://github.com/parkeradam/DDNSUpdate/blob/develop/.github/workflows/arm-build.yml ( See file previous commit for using the args you mentioned above, also failed)
I've also updated to the new version of the step.

@VaultVulp
Copy link
Owner

Thanks, @parkeradam !

As far as I understood, now there is the following error:

#12 ERROR: executor failed running [/bin/sh -c dotnet restore "DDNSUpdate/DDNSUpdate.csproj"]: exit code: 1

I think it's related to the build process itself, and not the action and/or arguments.

Maybe you could share any logs from the inside of a build stage? Are you able to build this Image locally?

@VaultVulp
Copy link
Owner

@parkeradam do you need more help with this issue or can I mark it as resolved?

@grab-a-byte
Copy link
Author

@VaultVulp feel free to close, apologies for ghosting, had a lot on atm! I'll open up another issue if i have problems when i get around to retrying. Thanks for your help :)

@mattvb91
Copy link

Hi @VaultVulp

I have the following issue. In my dockerfile:

ARG HOST_USER_UID=1000
ARG HOST_USER_GID=1000

RUN echo $HOST_USER_UID $HOST_USER_GID

in my action yml:

custom-args: --target=dev --build-arg=HOST_USER_UID=1001 --build-arg=HOST_USER_GID=123

I get the following output:

sh: --build-arg=HOST_USER_UID="1001": unknown operand

......

#6 [base 2/8] RUN echo 1000 1000
#6 0.128 1000 1000
#6 DONE 0.3s

So its not getting passed in as i would expect. Any ideas? Just checking here as I think im code blind at the moment. Ive tried wrapping the values in quotes too same error. Nothing comes through.

@VaultVulp
Copy link
Owner

Ho, @mattvb91!

Thanks for your question!

Sadly, it's a bit tricky to solve this issue w/o testing. Do you mind sharing the complete configuration for my action?

Btw, I have an example configuration with the custom-args here: https://github.com/VaultVulp/test-gp-docker-action/blob/master/.github/workflows/workflow.master.yml#L61-L72

@categulario
Copy link

Hi @VaultVulp I have the same problem that @mattvb91 describes. This is my config:

name: Build container image

on:
  push:
    tags:
      - '*'

jobs:
  container-image-dev:
    runs-on: ubuntu-latest
    environment: development

    steps:
      - uses: actions/checkout@v4

      - name: Build container image
        uses: VaultVulp/[email protected]
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          image-name: image-dev
          extract-git-tag: true
          additional-image-tags: latest
          dockerfile: Containerfile
          build-context: .
          custom-args: --build-arg=SOME_URL="${{ vars.DEV_SOME_URL }}" --build-arg=OTHER_URL="${{ vars.DEV_OTHER_URL }}"

  container-image-prod:
    runs-on: ubuntu-latest
    environment: production

    steps:
      - uses: actions/checkout@v4

      - name: Build container image
        uses: VaultVulp/[email protected]
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          image-name: image-prod
          extract-git-tag: true
          additional-image-tags: latest
          dockerfile: Containerfile
          build-context: .
          custom-args: --build-arg=SOME_URL="${{ vars.PROD_SMOME_URL }}" --build-arg=OTHER_URL="${{ vars.PROD_OTHER_URL }}"

which shows this in the job output:

sh: : unknown operand
sh: --build-arg=SOME_URL="http://the/url": unknown operand

@VaultVulp VaultVulp reopened this Mar 20, 2024
@VaultVulp
Copy link
Owner

VaultVulp commented Mar 20, 2024

@categulario Thanks for your attention to my project.

From my first impression it seems like your config should work and I'm not sure why action behaves in such way. I'll replicate your config and get back to you.

@VaultVulp
Copy link
Owner

@categulario sorry for the very late response.

I've done some research on this issue. It seems smth was altered on the GitHub's side and it changed the way docker-based actions are executed.
I'm still unsure how to handle this update properly, but I've tinkered with the action a bit and was able to pass arguments into the action:

Configuration: https://github.com/VaultVulp/test-gp-docker-action/actions/runs/8980317812/workflow#L86
CI runs:

Could you, please, try to run this 1.7.0 version of the action?

@categulario
Copy link

At the moment I had an urgent need to have images with arguments built using actions so I moved to docker/build-push-action.

I'll report back here if I manage to test the new version

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

No branches or pull requests

5 participants