Git Product home page Git Product logo

Comments (4)

djpugh avatar djpugh commented on May 30, 2024

The method creds = keyring.get_credential(index_url, None) seems to create a username/token combo that works on that feed, so if you are building on e.g. a windows laptop where you are using artifacts-keyring, then that can give you a token to pass into your docker build, but if you are e.g. building on a non-interactive machine (apart from azure devops pipeline build agents with the PipAuthenticateTask), I think you'll need to create a PAT in devops directly and use that as an environment variable into the build - see #8

from artifacts-keyring.

drcrook1 avatar drcrook1 commented on May 30, 2024

expanding on this, I have two use cases:

  1. docker containers are built on an ephemeral build server in a server pool.
  2. docker containers built by a script that runs a bunch of stuff including building the container on a dev's local box.

I used to just use a token which was injected into the extra-index-url. This was then introduced and it appears that likely whatever token I was using must have expired. I was hoping to figure out how to use this in those scenarios OR figure out how to use this to get a new token and prefferably how to generate a token with a headless build agent.


SOLVED:
make a new personal access token. In the top right of your Azure Dev Ops browser page.
image

This goes in your requirements.txt

--extra-index-url https://{{YOUR_FEED}}:{{YOUR_TOKEN}}@pkgs.dev.azure.com/{{YOUR_ORG}}/_packaging/{{YOUR_FEED}}/pypi/simple/
{{YOUR_PACKAGE_NAME}}=={{YOUR_VERSION}}

in your docker file:
Copy ./requirements.txt ./
RUN pip install -r requirements.txt

from artifacts-keyring.

johnterickson avatar johnterickson commented on May 30, 2024

Using secrets in Docker is ... tricky. You'll need to do something analogous to this: https://github.com/dotnet/dotnet-docker/blob/master/documentation/scenarios/nuget-credentials.md

from artifacts-keyring.

johnterickson avatar johnterickson commented on May 30, 2024

The above link is really the master cookbook. For some context, this tool is just a wrapper around https://github.com/microsoft/artifacts-credprovider so you can pass it the secret via VSS_NUGET_EXTERNAL_FEED_ENDPOINTS (yes it says NuGet, but don't worry about that 😊 ) see https://github.com/microsoft/artifacts-credprovider#environment-variables

You may also be interested in NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED

Some more info on tokens:
https://docs.microsoft.com/en-us/azure/devops/pipelines/process/access-tokens?view=azure-devops&tabs=yaml
https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#systemaccesstoken

from artifacts-keyring.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.