onec-docker icon indicating copy to clipboard operation
onec-docker copied to clipboard

Передавать ONEC_USERNAME и ONEC_PASSWORD в docker build через build secret

Open ovcharenko-di opened this issue 3 months ago • 0 comments

Спасибо кролику за подсказку:

 docker build \
-    --build-arg ONEC_USERNAME=$ONEC_USERNAME \
-    --build-arg ONEC_PASSWORD=$ONEC_PASSWORD \
+    --secret id=onec_credentials,env=ONEC_USERNAME \
+    --secret id=onec_password,env=ONEC_PASSWORD \
     --build-arg EDT_VERSION="$EDT_VERSION" \

Update the Dockerfile to use secrets instead of build arguments:

RUN --mount=type=secret,id=onec_credentials \
    --mount=type=secret,id=onec_password \
    export ONEC_USERNAME=$(cat /run/secrets/onec_credentials) && \
    export ONEC_PASSWORD=$(cat /run/secrets/onec_password) && \
    # Use credentials here

ovcharenko-di avatar Nov 16 '24 10:11 ovcharenko-di