mirror of
https://github.com/redhat-actions/buildah-build.git
synced 2025-04-19 16:51:23 +00:00
Add Layers input for in build using dockerfile
Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
parent
54ff9945b9
commit
751aaff532
8 changed files with 24 additions and 7 deletions
5
.github/workflows/dockerfile_build.yml
vendored
5
.github/workflows/dockerfile_build.yml
vendored
|
@ -31,12 +31,13 @@ jobs:
|
|||
uses: ./buildah-build/
|
||||
with:
|
||||
image: ${{ env.IMAGE_NAME }}
|
||||
layers: false
|
||||
tags: 'latest ${{ github.sha }}'
|
||||
dockerfiles: |
|
||||
./Dockerfile
|
||||
|
||||
|
||||
- name: Echo Outputs
|
||||
run: |
|
||||
run: |
|
||||
echo "Image: ${{ steps.build_image.outputs.image }}"
|
||||
echo "Tags: ${{ steps.build_image.outputs.tags }}"
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ After building your image, use [push-to-registry](https://github.com/redhat-acti
|
|||
| context | Path to directory to use as the build context. | `.`
|
||||
| dockerfiles | The list of Dockerfile paths to perform a build using docker instructions. This is a multiline input to allow multiple Dockerfiles. | **Must be provided**
|
||||
| image | Name to give to the output image. | **Must be provided**
|
||||
| layers | Set to true to cache intermediate layers during the build process. | None
|
||||
| oci | Build the image using the OCI format, instead of the Docker format. By default, this is `false`, because images built using the OCI format have issues when published to Dockerhub. | `false`
|
||||
| tags | The tags of the image to build. For multiple tags, separate by a space. For example, `latest ${{ github.sha }}` | `latest`
|
||||
|
||||
|
|
|
@ -28,6 +28,9 @@ inputs:
|
|||
entrypoint:
|
||||
description: 'The entry point to set for containers based on image'
|
||||
required: false
|
||||
layers:
|
||||
description: 'Set to true to cache intermediate layers during build process'
|
||||
required: false
|
||||
port:
|
||||
description: 'The port to expose when running containers based on image'
|
||||
required: false
|
||||
|
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
@ -13,7 +13,8 @@ export interface BuildahConfigSettings {
|
|||
|
||||
interface Buildah {
|
||||
buildUsingDocker(
|
||||
image: string, context: string, dockerFiles: string[], buildArgs: string[], useOCI: boolean, archs: string,
|
||||
image: string, context: string, dockerFiles: string[], buildArgs: string[],
|
||||
useOCI: boolean, archs: string, layers: string
|
||||
): Promise<CommandResult>;
|
||||
from(baseImage: string): Promise<CommandResult>;
|
||||
copy(container: string, contentToCopy: string[]): Promise<CommandResult | undefined>;
|
||||
|
@ -33,7 +34,8 @@ export class BuildahCli implements Buildah {
|
|||
}
|
||||
|
||||
async buildUsingDocker(
|
||||
image: string, context: string, dockerFiles: string[], buildArgs: string[], useOCI: boolean, archs: string
|
||||
image: string, context: string, dockerFiles: string[], buildArgs: string[],
|
||||
useOCI: boolean, archs: string, layers: string
|
||||
): Promise<CommandResult> {
|
||||
const args: string[] = [ "bud" ];
|
||||
if (archs) {
|
||||
|
@ -49,6 +51,9 @@ export class BuildahCli implements Buildah {
|
|||
args.push(buildArg);
|
||||
});
|
||||
args.push(...BuildahCli.getImageFormatOption(useOCI));
|
||||
if (layers) {
|
||||
args.push(`--layers=${layers}`);
|
||||
}
|
||||
args.push("-t");
|
||||
args.push(image);
|
||||
args.push(context);
|
||||
|
|
|
@ -55,6 +55,12 @@ export enum Inputs {
|
|||
* Default: None.
|
||||
*/
|
||||
IMAGE = "image",
|
||||
/**
|
||||
* Set to true to cache intermediate layers during build process
|
||||
* Required: false
|
||||
* Default: None.
|
||||
*/
|
||||
LAYERS = "layers",
|
||||
/**
|
||||
* Set to true to build using the OCI image format instead of the Docker image format
|
||||
* Required: false
|
||||
|
|
|
@ -61,7 +61,8 @@ async function doBuildUsingDockerFiles(
|
|||
const context = path.join(workspace, core.getInput(Inputs.CONTEXT));
|
||||
const buildArgs = getInputList(Inputs.BUILD_ARGS);
|
||||
const dockerFileAbsPaths = dockerFiles.map((file) => path.join(workspace, file));
|
||||
await cli.buildUsingDocker(newImage, context, dockerFileAbsPaths, buildArgs, useOCI, archs);
|
||||
const layers = core.getInput(Inputs.LAYERS);
|
||||
await cli.buildUsingDocker(newImage, context, dockerFileAbsPaths, buildArgs, useOCI, archs, layers);
|
||||
}
|
||||
|
||||
async function doBuildFromScratch(
|
||||
|
|
Loading…
Reference in a new issue