add support for building images with docker files (#4) (#5)

* add support for building images with docker files (#4)

Signed-off-by: Luca Stocchi <lstocchi@redhat.com>

* fix issues when building image with dockerfile

Signed-off-by: Luca Stocchi <lstocchi@redhat.com>

* update readme

Signed-off-by: Luca Stocchi <lstocchi@redhat.com>

* Update README.md

Co-authored-by: Divyanshu Agrawal <diagrawa@redhat.com>

Co-authored-by: Divyanshu Agrawal <diagrawa@redhat.com>
This commit is contained in:
Luca Stocchi 2020-11-19 09:19:57 +01:00 committed by GitHub
parent 329be0a470
commit deaddbe502
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 137 additions and 43 deletions

View file

@ -3,6 +3,7 @@ import * as exec from "@actions/exec";
import { CommandResult } from "./types";
interface Buildah {
buildUsingDocker(image: string, context: string, dockerFiles: string[]): Promise<CommandResult>;
from(baseImage: string): Promise<CommandResult>;
copy(container: string, contentToCopy: string[]): Promise<CommandResult>;
config(container: string, setting: {}): Promise<CommandResult>;
@ -24,6 +25,18 @@ export class BuildahCli implements Buildah {
this.executable = executable;
}
async buildUsingDocker(image: string, context: string, dockerFiles: string[]): Promise<CommandResult> {
const args: string[] = ['bud'];
dockerFiles.forEach(file => {
args.push('-f');
args.push(file);
});
args.push('-t');
args.push(image);
args.push(context);
return await this.execute(args);
}
async from(baseImage: string): Promise<CommandResult> {
return await this.execute(['from', baseImage]);
}