Could you all help and try to understand what I missed here and getting permission denied error? I have a docker file like below.
FROM node-12221-alpine3.12 AS builder
ARG artifactory_usr
ARG artifactory_psw
COPY --chown=node . /src
WORKDIR /src
RUN curl -u ${artifactory_usr}:${artifactory_psw} https://myartifactory.com/npm/auth > .npmrc
RUN npm CI
Currently passing the credentials from Jenkins and building the Dockerfile and publishing the artifacts to artifactory. To enhance the security we would like to use –mount=secret in Dockerfile and passing the –secret “id=artifactory_usr” on docker build . our new docker file look like this.
FROM node-12221-alpine3.12 AS builder
COPY --chown=node . /src WORKDIR /src
RUN --mount=type=secret,id=artifactory_usr
--mount=type=secret,id=artifactory_psw
ARTIFACTORY_USR=$(cat /run/secrets/artifactory_usr)
ARTIFACTORY_PSW=$(cat /run/secrets/artifactory_psw)
curl -u ${ARTIFACTORY_USR}:${ARTIFACTORY_PSW} https://myartifactory.com/npm/auth > .npmrc
RUN npm CI
But it shows permission denied error during the docker build stage as below
can’t open /run/secrets/artifactory_usr” : permission denied
can’t open /run/secrets/artifactory_psw” : permission denied
Build happens on dynamically provisioned ec2 machines. Could you please help me understand the issue to make the deployment success with passing secret
I have tried running it adding USER root in dockerfile, but no goes,
Additionally applied chown node:node to secrets path, but not works.