Skip to content

Commit

Permalink
feat(dockerfile): added option to build images from dockerfiles
Browse files Browse the repository at this point in the history
Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
  • Loading branch information
eusebiu-constantin-petu-dbk committed Nov 13, 2023
1 parent 438bfcd commit d296bdd
Show file tree
Hide file tree
Showing 13 changed files with 9,509 additions and 20,290 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ jobs:
runs-on: ubuntu-latest
services:
registry:
image: registry:2
image: ghcr.io/project-zot/zot-linux-amd64:latest
ports:
- 5000:5000
name: Test stacker-build-push-action
steps:
- uses: actions/checkout@v2

- name: Run stacker-build with a Dockerfile
uses: ./
with:
dockerfile: 'test/Dockerfile'
tags: v1 latest
url: docker://localhost:5000/four/app
layer-type: 'tar squashfs'
skip-tls: true

- name: Run stacker-build with all build inputs
uses: ./
with:
Expand Down Expand Up @@ -53,7 +62,7 @@ jobs:
with:
file: 'test/stacker_wo_subs.yaml'
tags: v1 latest
url: docker://localhost:5000/name/app
url: docker://localhost:5000/one/app
skip-tls: true

- name: Run stacker-build with push, tags and build-args
Expand All @@ -65,7 +74,7 @@ jobs:
SUB2=VAR2
SUB3=VAR3
tags: v1 latest
url: docker://localhost:5000/name/app
url: docker://localhost:5000/two/app
skip-tls: true

- name: Run stacker-build with push, tags, build-args and layer-type
Expand All @@ -77,6 +86,15 @@ jobs:
SUB2=VAR2
SUB3=VAR3
tags: v1 latest
url: docker://localhost:5000/name/app
url: docker://localhost:5000/three/app
layer-type: 'tar squashfs'
skip-tls: true

- name: Run stacker recursive-build
uses: ./
with:
dir: 'test/builds'
tags: v2
url: docker://localhost:5000/five/app
layer-type: 'tar squashfs'
skip-tls: true
36 changes: 33 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,25 @@ For more information about stacker tool see: https://github.com/project-stacker/

## Action Inputs

<a id="dockerfile-build-inputs"></a>
<a id="build-inputs"></a>

| Input Name | Type | Description | Default |
| ---------- | ---- |----------- | ------- |
| file | string | the yaml file to be built as an OCI image, example: [stacker.yaml](./test/stacker.yaml) | stacker.yaml
| file | string | path to yaml file to be built as an OCI image, example: [stacker.yaml](./test/stacker.yaml) | stacker.yaml
| dockerfile| string | path to dockerfile to be build as an OCI image(instead of stacker.yaml) | None
| cache-dir | string | stacker's cache directory | ./.stacker
| dir | string | directory under which to recursive search for stackerfiles to build, use either file or dir | None
| file-pattern| string | regex pattern to use when searching for stackerfile paths, used only with dir arg | \\/stacker.yaml$
| layer-type | list | output layer type (supported values: tar, squashfs), ca be both separated by whitespace | tar
| build-args | list | the list of build-time arguments (subtitutes) separated by newline, see [stacker.yaml doc](https://github.com/project-stacker/stacker/blob/master/doc/stacker_yaml.md) | None
| build-args | list | the list of build-time arguments (subtitutes) separated by newline FOO=bar format, see [stacker.yaml doc](https://github.com/project-stacker/stacker/blob/master/doc/stacker_yaml.md) | None
| build-args-file | string | path to yaml file where build-args are set 'FOO: bar' yaml format | None
| url | string | remote OCI registry + repo name eg: docker://ghcr.io/project-stacker/ | None
| tags | list | one or more tags to give the new image, separated by whitespace | None
| username | string | used to login to registry | None
| password | string | used to login to registry | None
| skip-tls | bool | used with unsecure (http) registries | false
| token | string | github token used to authenticate against a repository for Git context | ${{ github.token }}
| version | string | stacker version, see [stacker releases](https://github.com/project-stacker/stacker/releases) | v1.0.0-rc8



Expand Down Expand Up @@ -93,3 +96,30 @@ Build and push example to localhost:
The above action will build test/stacker.yaml and push it to
1. docker://localhost:5000/test:test


Build and push a Dockerfile:

```
- name: Run stacker-build with a Dockerfile
uses: ./
with:
dockerfile: 'test/Dockerfile.yaml'
tags: v1 latest
url: docker://localhost:5000/four/app
layer-type: 'tar squashfs'
skip-tls: true
```


Build recursively all stacker files under dir/ and push all:

```
- name: Run stacker recursive-build
uses: ./
with:
dir: 'test/builds'
tags: v2
url: docker://localhost:5000/five/app
layer-type: 'tar squashfs'
skip-tls: true
```
9 changes: 6 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ branding:
color: 'blue'
inputs:
version:
description: 'Which stacker version to use'
description: 'Which stacker version to use, eg v0.40.3 see: https://github.com/project-stacker/stacker/releases'
required: false
default: 'latest'
default: 'v1.0.0-rc8'
file:
description: 'Which stacker file to build'
required: false
default: 'stacker.yaml'
dockerfile:
description: 'Which dockerfile to build(will be converted to stacker.yaml)'
required: false
cache-dir:
description: "stacker's cache directory"
required: false
default: '.stacker'
dir:
description: 'directory under which to recursive search for stackerfiles to build'
description: 'directory under which to recursively search for stackerfiles to build'
required: false
file-pattern:
description: 'regex pattern to use when searching for stackerfile paths, used with dir arg'
Expand Down
Loading

0 comments on commit d296bdd

Please sign in to comment.