Skip to content

Commit da1c527

Browse files
Merge pull request #8 from xoxys/master
Add option to pass config as environment variables
2 parents 36a703c + e466fe8 commit da1c527

File tree

4 files changed

+237
-144
lines changed

4 files changed

+237
-144
lines changed

README-containers.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ Let's dissect this a bit:
3838
- we set `--debug` to get additional log output (optional)
3939
- we set the short description for the Dockerhub repo with `--short <string>` (optional)
4040

41+
**Alternatively all params can also get set with environment variables:**
42+
43+
```
44+
$ docker run --rm -t \
45+
-v $(pwd):/myvol \
46+
-e DOCKER_USER='my-user' -e DOCKER_PASS='my-pass' \
47+
-e PUSHRM_PROVIDER=dockerhub -e PUSHRM_FILE=/myvol/README.md \
48+
-e PUSHRM_SHORT='my short description' \
49+
-e PUSHRM_TARGET=docker.io/my-user/my-repo -e PUSHRM_DEBUG=1 \
50+
chko/docker-pushrm:1
51+
```
52+
4153
#### Push a README file to a Harbor v2 registry server
4254

4355
Use the `--provider harbor2` flag:
@@ -55,8 +67,9 @@ chko/docker-pushrm:1 --file /myvol/README.md \
5567

5668
#### Push a README file to Quay.io or a Quay registry server
5769

70+
5871
- use the `--provider quay` flag
59-
- use env var `APIKEY__<SERVER>_<DOMAIN>` for apikey credentials
72+
- use env var `APIKEY__<SERVER>_<DOMAIN>` or `DOCKER_APIKEY` for apikey credentials
6073

6174
```
6275
$ ls
@@ -69,5 +82,26 @@ chko/docker-pushrm:1 --file /myvol/README.md \
6982
--provider quay --debug quay.io/my-user/my-repo
7083
```
7184

85+
### env vars
86+
87+
| env var | example value | description
88+
| --------------------------- | ------------------------------ | ----------------------------------------
89+
| `DOCKER_USER` | `my-user` | login username
90+
| `DOCKER_PASS` | `my-password` | login password
91+
| `DOCKER_APIKEY` | `my-quay-api-key` | quay api key
92+
| `APIKEY__<SERVER>_<DOMAIN>` | `my-quay-api-key` | quay api key (alternative)
93+
| `PUSHRM_PROVIDER` | `dockerhub`, `quay`, `harbor2` | repo provider type
94+
| `PUSHRM_SHORT` | `my short description` | set/update repo short description
95+
| `PUSHRM_FILE` | `/myvol/README.md` | path to the README file
96+
| `PUSHRM_DEBUG` | `1` | enable verbose output
97+
| `PUSHRM_CONFIG` | `/myvol/.docker/config.json` | Docker config file (for credentials)
98+
| `PUSHRM_TARGET` | `docker.io/my-user/my-repo` | container repo ref
99+
100+
Presedence:
101+
- Params specified with flags take precedence over env vars.
102+
- Login env vars take precedence over credentials from a Docker config file
103+
104+
105+
72106

73107

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,16 @@ To install the plugin for all users of a system copy it to the following path (i
207207

208208
On Mac/Linux make it executable and readable for all users: `chmod a+rx <path>/docker-pushrm`
209209

210+
## Using env vars instead of cmdline params
211+
212+
All cmdline parameters can also be set as env vars with prefix `PUSHRM_`.
213+
214+
Cmdline parameters take precedence over env vars. (Except for login env vars, which take precedence over the local credentials store).
215+
216+
This is mainly intended for running this tool in a container in [12fa](https://12factor.net/config) style.
217+
218+
A list of all supported env vars is [here](README-containers.md#env-vars).
219+
210220
## Limitations
211221

212222
### Conflict with Dockerhub personal access tokens and 2FA auth

0 commit comments

Comments
 (0)