I have a secret file secret.json:
{
"key1": "value_1",
"key2": "value_2"
}
and a simple Dockerfile ./src/Dockerfile:
# syntax=docker/dockerfile:1
FROM debian:stable-20230904-slim AS downloader
RUN apt update && apt install -y jq
RUN --mount=type=secret,id=secrets \
cat /run/secrets/secrets | jq -r '.key1'
When I call the GitHub action
- name: Build
uses: docker/build-push-action@v5
with:
context: './src/'
tags: foo/bar:latest
secret-files: |
"secrets=./secret.json"
I receive the following error:
parse error: Invalid numeric literal at line 2, column 7
I tried to base64 encode the json file before passing it to the action and then decode and parse it inside the Dockerfile, but the result is the same. It seems like the double quote characters disappear when the file is read from inside the Docker build and push action
[stage-0 2/2] RUN --mount=type=secret,id=secrets cat /run/secrets/secrets | sed 's/./&/g'
{
key1: value_1,
key2: value_2
}
