container-source-policy-darwin-arm64 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -0
- package/bin/container-source-policy +0 -0
- package/package.json +20 -0
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# container-source-policy
|
|
2
|
+
|
|
3
|
+
Generate a Docker BuildKit **source policy** file (`docker buildx build --source-policy-file …`) by parsing Dockerfiles and pinning `FROM` images to immutable digests.
|
|
4
|
+
|
|
5
|
+
This helps make `docker buildx build` inputs reproducible without rewriting your Dockerfile.
|
|
6
|
+
|
|
7
|
+
## Quick start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
container-source-policy pin --stdout Dockerfile > source-policy.json
|
|
11
|
+
docker buildx build --source-policy-file source-policy.json -t my-image:dev .
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
### Go (build from source)
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
go install github.com/tinovyatkin/container-source-policy@latest
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### npm (prebuilt binary)
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm i -g container-source-policy
|
|
26
|
+
container-source-policy --help
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### PyPI (prebuilt binary)
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pipx install container-source-policy
|
|
33
|
+
container-source-policy --help
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### RubyGems (prebuilt binary)
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
gem install container-source-policy
|
|
40
|
+
container-source-policy --help
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
Generate a policy for one or more Dockerfiles:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
container-source-policy pin --stdout Dockerfile Dockerfile.ci > source-policy.json
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Read the Dockerfile from stdin:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
cat Dockerfile | container-source-policy pin --stdout -
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Write directly to a file:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
container-source-policy pin --output source-policy.json Dockerfile
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Then pass the policy to BuildKit / Buildx:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
docker buildx build --source-policy-file source-policy.json .
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Shell completion scripts are available via Cobra:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
container-source-policy completion zsh
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## What gets pinned
|
|
76
|
+
|
|
77
|
+
- Looks at `FROM …` instructions across all provided Dockerfiles.
|
|
78
|
+
- Skips:
|
|
79
|
+
- `FROM scratch`
|
|
80
|
+
- `FROM <stage>` references to a previous named build stage
|
|
81
|
+
- `FROM ${VAR}` / `FROM $VAR` (unexpanded ARG/ENV variables)
|
|
82
|
+
- images already written as `name@sha256:…`
|
|
83
|
+
- Resolves the image manifest digest from the registry and emits BuildKit `CONVERT` rules of the form:
|
|
84
|
+
- `docker-image://<as-written-in-Dockerfile>` → `docker-image://<normalized>@sha256:…`
|
|
85
|
+
|
|
86
|
+
## Development
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
make build
|
|
90
|
+
make test
|
|
91
|
+
make lint
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Update integration-test snapshots:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
UPDATE_SNAPS=true go test ./internal/integration/...
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Repository layout
|
|
101
|
+
|
|
102
|
+
- `cmd/container-source-policy/cmd/`: Cobra CLI commands
|
|
103
|
+
- `internal/dockerfile`: Dockerfile parsing (`FROM` extraction)
|
|
104
|
+
- `internal/registry`: registry client (digest resolution)
|
|
105
|
+
- `internal/policy`: BuildKit source policy types and JSON output
|
|
106
|
+
- `internal/pin`: orchestration logic for `pin`
|
|
107
|
+
- `internal/integration`: end-to-end tests with a mock registry and snapshots
|
|
108
|
+
- `packaging/`: wrappers for publishing prebuilt binaries to npm / PyPI / RubyGems
|
|
109
|
+
|
|
110
|
+
## Packaging
|
|
111
|
+
|
|
112
|
+
See `packaging/README.md` for how the npm/PyPI/Ruby packages are assembled from GoReleaser artifacts.
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "container-source-policy-darwin-arm64",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The darwin arm64 binary for container-source-policy",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/tinovyatkin/container-source-policy.git"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/tinovyatkin/container-source-policy/issues"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/tinovyatkin/container-source-policy#readme",
|
|
14
|
+
"os": [
|
|
15
|
+
"darwin"
|
|
16
|
+
],
|
|
17
|
+
"cpu": [
|
|
18
|
+
"arm64"
|
|
19
|
+
]
|
|
20
|
+
}
|