'Secret: GutHub actions -> docker compose -> docker
Trying to pass a secret from GH actions through docker-compose to dockerfile:
workflow.yml
run: |
echo "$NPM_AUTH" > auth
echo "$NPM_EMAIL" > email
docker-compose up -d
docker-compose.yml
version: '3.9'
secrets:
auth:
file: ./auth
email:
file: ./email
services:
service-name:
build:
context: ./
dockerfile: Dockerfile
secrets:
- email
- auth
Dockerfile
# syntax = docker/dockerfile-upstream:master-experimental
RUN --mount=type=secret,id=email --mount=type=secret,id=auth \
NPM_CONFIG__AUTH=$(cat /run/secrets/auth) \
NPM_CONFIG_EMAIL=$(cat /run/secrets/email)@gmail.com \
yarn install --frozen-lockfile \
&& yarn build
And it fails with below:
#17 0.336 cat: /run/secrets/auth: No such file or directory
#17 0.336 cat: /run/secrets/email: No such file or directory
I am not using a docker swarm. My secrets are in files. Is it possible to do so? If yes, what is wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
