build-arg not support multiline variable
See original GitHub issueTroubleshooting
I need to save a multiline variable to a file. But the result is a file with only one line. secrets.DEPLOY_KEY
- multiline variable.
- name: Build SCM container image
uses: docker/build-push-action@v2
with:
push: true
build-args: |
VAULT_PASSWORD=${{ secrets.ANSIBLE_VAULT_PASSWORD }}
PRIVATE_KEY=${{ secrets.DEPLOY_KEY }}
Dockerfile:
ARG VAULT_PASSWORD
ARG PRIVATE_KEY
ENV PASSWORD $VAULT_PASSWORD
ENV KEY $PRIVATE_KEY
...
RUN echo "$PASSWORD" > /etc/vault.txt && \
chmod 0600 /etc/vault.txt
RUN echo "$KEY" > /root/.ssh/id_rsa && \
chmod 0600 /root/.ssh/id_rsa
Expected behaviour
cat /root/.ssh/id_rsa
-----BEGIN OPENSSH PRIVATE KEY-----
...
...
Actual behaviour
cat /root/.ssh/id_rsa
-----BEGIN OPENSSH PRIVATE KEY-----
One line only.
PS
Working version if done manually: https://github.com/concourse/docker-image-resource/issues/79#issuecomment-259812953
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Set Multiline Environment Variable with Dockerfile
I was able to get this working by passing the multiline environment variable as a build arg to docker build. Dockerfile
Read more >Multiple lines variable in Build and Release
Some tasks have the textboxes that support multiple line content, such as Delete task, but multiple lines variable is not supported, it's better...
Read more >Dockerfile reference - Docker Documentation
Environment variables are supported by the following list of instructions in the Dockerfile : ADD; COPY; ENV; EXPOSE; FROM; LABEL; STOPSIGNAL ...
Read more >Using multiline strings in GitLab YML file
Using multiline strings in GitLab YML file. Sometimes your script is too long and it doesn't fit on one line:
Read more >Add different condition in Dockerfile [5 Methods] | GoLinuxCloud
This means that the variable is accessible only while creating the docker image and NOT accessible for the docker container. Variable ENV: This...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@k0st1an Like secrets, you need to place the key-value pair between quotes:
Nevermind, it was a false alarm and I am sorry for polluting the thread. Two problems at the same time.