Skip to content

Commit 51b5ff0

Browse files
author
Chris Dostert
committed
Container auth from opctl
1 parent c673bf1 commit 51b5ff0

File tree

3 files changed

+66
-58
lines changed

3 files changed

+66
-58
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ All notable changes will be documented in this file in accordance with
99

1010
### Added
1111

12+
- Ability to push built image to remote repositories via `isPushEnabled` and `namesCsv` inputs
1213
- Support for building multi-platform images via `platformsCsv` input
1314

1415
### Changed
1516

16-
- Authentication configuration is now provided via `authConfig` (in the same format as dockers config.json) in order to ease usage for docker users.
17+
- `cacheDir` renamed to `cache` for consistency
1718

1819
## \[1.3.0] - 2024-05-27
1920

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ op:
2828
inputs:
2929
instructions: # 👈 required; provide a value
3030
## uncomment to override defaults
31-
# authConfig: [object Object]
32-
# cacheDir: /default_cache
31+
# cache: /default_cache
3332
# context: /default_context
3433
# contextIgnore: /default_context_ignore
34+
# isPushEnabled: false
35+
# namesCsv: ""
3536
# platformsCsv: ""
37+
# registryCreds: $(opctl://./secrets/docker.io)
3638
outputs:
3739
image:
3840
```

op.yml

+60-55
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
11
description: Builds an open container initiative (OCI) image
22
name: github.com/opspec-pkgs/opencontainers.image.build
33
inputs:
4-
authConfig:
5-
object:
6-
default: {}
4+
registryCreds:
5+
array:
6+
default:
7+
- $(opctl://./secrets/docker.io)
78
description: |
8-
Auth config for image registries; same format as a docker config.json
9-
10-
Note that when using docker and a credential helper (e.g. the default with macOS docker desktop) ~/.docker/config.json will not directly contain credentials. If you need to provide auth in this case, you'll need to generate a configuration file with base64 encoded credentials. See https://github.com/docker/for-mac/issues/4100 for more discussion on the format of this file.
11-
constraints:
12-
properties:
13-
auths:
14-
type: object
15-
description: |
16-
Keys are registry hostname/urls and values contain authentication information
17-
additionalProperties:
18-
type: object
19-
properties:
20-
auth:
21-
description: Base64 encoded string of the format `{username}:{password}`
22-
type: string
23-
format: base64
24-
cacheDir:
9+
creds for image registries e.g. `["username": "xx", "password": "yy", "registry": "https://index.docker.io/v1/"]`
10+
constraints:
11+
items:
12+
type: object
13+
properties:
14+
username:
15+
type: string
16+
password:
17+
type: string
18+
registry:
19+
type: string
20+
cache:
2521
dir:
2622
default: /default_cache
27-
description: directory used to cache images/layers across runs. Must be formatted as an [image-layout](https://github.com/opencontainers/image-spec/blob/v1.0.1/image-layout.md)
23+
description: Directory used to cache images/layers across runs. Must be formatted as an [image-layout](https://github.com/opencontainers/image-spec/blob/v1.0.1/image-layout.md)
2824
context:
2925
dir:
30-
description: context for build
26+
description: Context for build
3127
default: /default_context
3228
contextIgnore:
3329
file:
34-
description: context ignore rules in the format of a .gitignore/.dockerignore
30+
description: Context ignore rules in the format of a .gitignore/.dockerignore
3531
default: /default_context_ignore
3632
instructions:
3733
file:
38-
description: build instructions in the format of a Containerfile/Dockerfile
34+
description: Build instructions in the format of a Containerfile/Dockerfile
35+
isPushEnabled:
36+
boolean:
37+
default: false
38+
description: Whether to push the named images (to remote registries) after they're created
39+
namesCsv:
40+
string:
41+
default: ''
42+
description: |
43+
Names the image will be tagged with in the form of comma separated "[registry/][username/][repository/][:tag]"
44+
45+
e.g. 'docker.io/my-org-name/my-repo-name:my-image-tag'
3946
platformsCsv:
4047
string:
4148
default: ''
@@ -49,35 +56,33 @@ outputs:
4956
dir:
5057
description: image in form of [v1.0.1 OCI (Open Container Initiative) `image-layout`](https://github.com/opencontainers/image-spec/blob/v1.0.1/image-layout.md)
5158
run:
52-
serial:
53-
- op:
54-
ref: github.com/opspec-pkgs/docker.config.clean#1.1.0
55-
inputs:
56-
dockerConfig: $(authConfig)
57-
outputs:
58-
dockerConfigCleaned: $(authConfig)
59-
- container:
60-
cmd:
61-
- sh
62-
- -ce
63-
- >
64-
buildctl-daemonless.sh
65-
build
66-
--frontend dockerfile.v0
67-
--local context=/buildContext
68-
--local dockerfile=/
69-
--output type=oci,tar=false,dest=/image
70-
--import-cache type=local,src=/cacheDir
71-
--export-cache type=local,dest=/cacheDir,mode=max
72-
--opt platform=$(platformsCsv)
73-
dirs:
74-
/buildContext: $(context)
75-
/cacheDir: $(cacheDir)
76-
/image: $(image)
77-
files:
78-
/root/.docker/config.json: $(authConfig)
79-
/Dockerfile: $(instructions)
80-
/Dockerfile.dockerignore: $(contextIgnore)
81-
image:
82-
ref: moby/buildkit:master
59+
container:
60+
cmd:
61+
- sh
62+
- -ce
63+
-
64+
/setAuths &&
65+
66+
buildctl-daemonless.sh
67+
build
68+
--frontend dockerfile.v0
69+
--local context=/context
70+
--local dockerfile=/
71+
--import-cache type=local,src=/cache
72+
--export-cache type=local,dest=/cache,mode=max
73+
--opt platform=$(platformsCsv)
74+
--output type=image,name=$(namesCsv),push=$(isPushEnabled)
75+
--output type=oci,'name=$(namesCsv)',tar=false,dest=/image
76+
dirs:
77+
/context: $(context)
78+
/cache: $(cache)
79+
/image: $(image)
80+
envVars:
81+
registryCreds:
82+
files:
83+
/Dockerfile: $(instructions)
84+
/Dockerfile.dockerignore: $(contextIgnore)
85+
/setAuths:
86+
image:
87+
ref: moby/buildkit:latest
8388
version: 2.0.0

0 commit comments

Comments
 (0)