|
| 1 | +# with-cloudsmith |
| 2 | + |
| 3 | +**with-cloudsmith** is a CLI tool for temporarily injecting Cloudsmith package |
| 4 | +source configurations into an environment. This can be useful when you want |
| 5 | +to consume private packages as part of a Dockerfile build but do not want to |
| 6 | +leave credentials behind in the resulting image. |
| 7 | + |
| 8 | +## Use |
| 9 | + |
| 10 | +First, add **with-cloudsmith** to your Dockerfile: |
| 11 | +```dockerfile |
| 12 | +FROM debian:bookworm-slim |
| 13 | + |
| 14 | +ADD https://raw.githubusercontent.com/secondlife/with-cloudsmith/v0.1.0/with-cloudsmith /usr/bin/ |
| 15 | +``` |
| 16 | + |
| 17 | +## Use with debian packages |
| 18 | + |
| 19 | +To install debian packages from a private Cloudsmith repository: |
| 20 | +```dockerfile |
| 21 | +# Install cloudsmith apt source dependencies |
| 22 | +RUN apt-get update \ |
| 23 | + && apt-get install -y apt-transport-https ca-certificates curl gnupg \ |
| 24 | + && rm -rf /var/lib/apt/lists/* |
| 25 | + |
| 26 | +# Install private dependencies |
| 27 | +RUN --mount=type=secret,id=CLOUDSMITH_API_KEY \ |
| 28 | + with-cloudsmith -v --repo REPO --org ORG --deb \ |
| 29 | + apt-get install -y PACKAGE \ |
| 30 | + && rm -rf /var/lib/apt/lists/* |
| 31 | +``` |
| 32 | + |
| 33 | +Then, assuming you have the environment variable CLOUDSMITH_API_KEY available, build the image: |
| 34 | +``` |
| 35 | +$ docker build --secret id=CLOUDSMITH_API_KEY local/example . |
| 36 | +``` |
| 37 | + |
| 38 | +## Use with pip |
| 39 | + |
| 40 | +Private python packages can be installed using **with-cloudsmith** like so: |
| 41 | + |
| 42 | +```dockerfile |
| 43 | +RUN --mount=type=secret,id=CLOUDSMITH_API_KEY \ |
| 44 | + with-cloudsmith --repo REPO --org ORG --pip pip install ... |
| 45 | +``` |
| 46 | + |
| 47 | +Build the image the same as before, passing a build `--secret`. |
| 48 | + |
| 49 | +### Credentials |
| 50 | + |
| 51 | +**with-cloudsmith** desperately searches the following locations for credentials: |
| 52 | + |
| 53 | +- Environment variables: `CLOUDSMITH_API_KEY`, `CLOUDSMITH_TOKEN`, `CLOUDSMITH_USER`, `CLOUDSMITH_PASSWORD` |
| 54 | +- Ini files: `$HOME/.cloudsmith/credentials.ini`, `$HOME/.config/credentials.ini`, `$PWD/credentials.ini` |
| 55 | +- Docker build secrets: `/run/secrets/CLOUDSMITH_API_KEY`, et al. |
| 56 | + |
| 57 | +If you wish to use an OIDC token, you will want to use `CLOUDSMITH_TOKEN`. |
| 58 | + |
| 59 | +## Supported registry types |
| 60 | + |
| 61 | +- Debian packages |
| 62 | +- Python |
0 commit comments