diff --git a/README.md b/README.md
index 8d14ec3..e092a57 100644
--- a/README.md
+++ b/README.md
@@ -15,48 +15,103 @@ Note that GitHub's [Ubuntu Environments](https://github.com/actions/virtual-envi
- Action input |
+ Input |
+ Required |
Description |
- new-image-name |
- (Required) Name to give to the image that will be eventually created. |
+ image |
+ Yes |
+ Name to give to the image that will be eventually created. |
base-name |
- (Optional) The base image to use to create the initial container. If not specified, the action will try to pick one automatically. Only Java language is supported at this time. |
+ No |
+ The base image to use to create the initial container. If not specified, the action will try to pick one automatically. (N.B: At this time the action is only able to auto select Java base image) |
+
+
+
+ dockerfiles |
+ No |
+ The list of Dockerfile paths to perform a build using docker instructions. This is a multiline input to add multiple values. |
+
+
+
+ context |
+ No |
+ The path of the directory to use as context (default: .) |
content |
- (Required) The content to copy inside the container to create the final image. This is a multiline input to allow you to copy more than one file/directory. For example - content: | target/spring-petclinic-2.3.0.BUILD-SNAPSHOT.jar |
+ No |
+ The content to copy inside the container to create the final image. This is a multiline input to allow you to copy more than one file/directory. For example - content: | target/spring-petclinic-2.3.0.BUILD-SNAPSHOT.jar |
entrypoint |
- (Required) The entry point to set for the container. This is a multiline input to add multiple values. For example - entrypoint: | java -jar spring-petclinic-2.3.0.BUILD-SNAPSHOT.jar |
+ No |
+ The entry point to set for the container. This is a multiline input to add multiple values. For example - entrypoint: | java -jar spring-petclinic-2.3.0.BUILD-SNAPSHOT.jar |
port |
- (Required) The port to expose when running the container. |
+ No |
+ The port to expose when running the container. |
working-dir |
- (Optional) The working directory to use within the container. |
+ No |
+ The working directory to use within the container. |
envs |
- (Optional) The environment variables to be set when running the container. This is a multiline input to add multiple environment variables.For example - envs: | GOPATH=/root/buildah |
+ No |
+ The environment variables to be set when running the container. This is a multiline input to add multiple environment variables.For example - envs: | GOPATH=/root/buildah |
-## Examples
+## Build an image using Dockerfile or from scratch
+
+One of the advantages of using the `buildah` action is that you can decide the way you want to build your image.
+
+If you have been using Docker and have some existing Dockerfiles, `buildah` is able to build images by using them.
+In this case the inputs needed are just `image`, `dockerfiles` and `content`.
+
+An example below
+
+```yaml
+name: Build Image using Dockerfile
+on: [push]
+
+jobs:
+ build:
+ name: Build image
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Buildah Action
+ uses: redhat-actions/buildah-action@v1
+ with:
+ image: awesome-name:v1
+ dockerfiles: |
+ ./Dockerfile
+```
+
+On the other hand, a build from scratch may require more inputs as it needs to execute a series of steps that can be summarized in:
+- Create a new container by using the base image (input: `base-image`)
+- Copy all files/directories inside the newly-created container (input: `content`)
+- Set up the image configuration values (inputs: `entrypoint`,`port`,`envs`)
+- Build an optimized image
+
+Example of building a Spring Boot Java app image below
```yaml
name: Build Image
@@ -72,13 +127,11 @@ jobs:
uses: actions/checkout@v2
- name: Maven
- run: |
- cd ${GITHUB_WORKSPACE}
- mvn package
+ run: mvn package
- name: Build Action
- uses: redhat-actions/buildah-action@0.0.1
+ uses: redhat-actions/buildah-action@v1
with:
- new-image-name: petclinic
+ image: awesome-name:v1
content: |
target/spring-petclinic-2.3.0.BUILD-SNAPSHOT.jar
entrypoint: |
diff --git a/action.yml b/action.yml
index ab394b0..dad49a5 100644
--- a/action.yml
+++ b/action.yml
@@ -5,26 +5,33 @@ branding:
icon: circle
color: red
inputs:
- new-image-name:
- description: 'Name of the new image that will be created'
+ image:
+ description: 'The name (reference) of the image to build'
required: true
base-image:
- description: 'Base image to use'
+ description: 'The base image to use to create a new container image'
required: false
+ dockerfiles:
+ description: 'List of Dockerfile paths (eg: ./Dockerfile)'
+ required: false
+ context:
+ description: 'Path of the directory to use as context (default: .)'
+ required: false
+ default: '.'
content:
- description: 'The content to copy inside the base image'
- required: true
+ description: 'List of files/directories to copy inside the base image'
+ required: false
entrypoint:
- description: 'Entrypoint'
- required: true
+ description: 'The entry point to set for containers based on image'
+ required: false
port:
- description: 'Port'
- required: true
+ description: 'The port to expose when running containers based on image'
+ required: false
working-dir:
- description: 'Working directory'
+ description: 'The working directory to use within the container'
required: false
envs:
- description: 'envs'
+ description: 'List of environment variables to be set when running containers based on image'
required: false
runs:
using: 'node12'
diff --git a/dist/index.js b/dist/index.js
index f0d149d..948b19a 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1,2 +1,2 @@
-require('./sourcemap-register.js');module.exports=(()=>{var r={7351:function(r,n,i){"use strict";var e=this&&this.__importStar||function(r){if(r&&r.__esModule)return r;var n={};if(r!=null)for(var i in r)if(Object.hasOwnProperty.call(r,i))n[i]=r[i];n["default"]=r;return n};Object.defineProperty(n,"__esModule",{value:true});const o=e(i(2087));const t=i(5278);function issueCommand(r,n,i){const e=new Command(r,n,i);process.stdout.write(e.toString()+o.EOL)}n.issueCommand=issueCommand;function issue(r,n=""){issueCommand(r,{},n)}n.issue=issue;const s="::";class Command{constructor(r,n,i){if(!r){r="missing.command"}this.command=r;this.properties=n;this.message=i}toString(){let r=s+this.command;if(this.properties&&Object.keys(this.properties).length>0){r+=" ";let n=true;for(const i in this.properties){if(this.properties.hasOwnProperty(i)){const e=this.properties[i];if(e){if(n){n=false}else{r+=","}r+=`${i}=${escapeProperty(e)}`}}}}r+=`${s}${escapeData(this.message)}`;return r}}function escapeData(r){return t.toCommandValue(r).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escapeProperty(r){return t.toCommandValue(r).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}},2186:function(r,n,i){"use strict";var e=this&&this.__awaiter||function(r,n,i,e){function adopt(r){return r instanceof i?r:new i(function(n){n(r)})}return new(i||(i=Promise))(function(i,o){function fulfilled(r){try{step(e.next(r))}catch(r){o(r)}}function rejected(r){try{step(e["throw"](r))}catch(r){o(r)}}function step(r){r.done?i(r.value):adopt(r.value).then(fulfilled,rejected)}step((e=e.apply(r,n||[])).next())})};var o=this&&this.__importStar||function(r){if(r&&r.__esModule)return r;var n={};if(r!=null)for(var i in r)if(Object.hasOwnProperty.call(r,i))n[i]=r[i];n["default"]=r;return n};Object.defineProperty(n,"__esModule",{value:true});const t=i(7351);const s=i(717);const u=i(5278);const c=o(i(2087));const f=o(i(5622));var l;(function(r){r[r["Success"]=0]="Success";r[r["Failure"]=1]="Failure"})(l=n.ExitCode||(n.ExitCode={}));function exportVariable(r,n){const i=u.toCommandValue(n);process.env[r]=i;const e=process.env["GITHUB_ENV"]||"";if(e){const n="_GitHubActionsFileCommandDelimeter_";const e=`${r}<<${n}${c.EOL}${i}${c.EOL}${n}`;s.issueCommand("ENV",e)}else{t.issueCommand("set-env",{name:r},i)}}n.exportVariable=exportVariable;function setSecret(r){t.issueCommand("add-mask",{},r)}n.setSecret=setSecret;function addPath(r){const n=process.env["GITHUB_PATH"]||"";if(n){s.issueCommand("PATH",r)}else{t.issueCommand("add-path",{},r)}process.env["PATH"]=`${r}${f.delimiter}${process.env["PATH"]}`}n.addPath=addPath;function getInput(r,n){const i=process.env[`INPUT_${r.replace(/ /g,"_").toUpperCase()}`]||"";if(n&&n.required&&!i){throw new Error(`Input required and not supplied: ${r}`)}return i.trim()}n.getInput=getInput;function setOutput(r,n){t.issueCommand("set-output",{name:r},n)}n.setOutput=setOutput;function setCommandEcho(r){t.issue("echo",r?"on":"off")}n.setCommandEcho=setCommandEcho;function setFailed(r){process.exitCode=l.Failure;error(r)}n.setFailed=setFailed;function isDebug(){return process.env["RUNNER_DEBUG"]==="1"}n.isDebug=isDebug;function debug(r){t.issueCommand("debug",{},r)}n.debug=debug;function error(r){t.issue("error",r instanceof Error?r.toString():r)}n.error=error;function warning(r){t.issue("warning",r instanceof Error?r.toString():r)}n.warning=warning;function info(r){process.stdout.write(r+c.EOL)}n.info=info;function startGroup(r){t.issue("group",r)}n.startGroup=startGroup;function endGroup(){t.issue("endgroup")}n.endGroup=endGroup;function group(r,n){return e(this,void 0,void 0,function*(){startGroup(r);let i;try{i=yield n()}finally{endGroup()}return i})}n.group=group;function saveState(r,n){t.issueCommand("save-state",{name:r},n)}n.saveState=saveState;function getState(r){return process.env[`STATE_${r}`]||""}n.getState=getState},717:function(r,n,i){"use strict";var e=this&&this.__importStar||function(r){if(r&&r.__esModule)return r;var n={};if(r!=null)for(var i in r)if(Object.hasOwnProperty.call(r,i))n[i]=r[i];n["default"]=r;return n};Object.defineProperty(n,"__esModule",{value:true});const o=e(i(5747));const t=e(i(2087));const s=i(5278);function issueCommand(r,n){const i=process.env[`GITHUB_${r}`];if(!i){throw new Error(`Unable to find environment variable for file command ${r}`)}if(!o.existsSync(i)){throw new Error(`Missing file at path: ${i}`)}o.appendFileSync(i,`${s.toCommandValue(n)}${t.EOL}`,{encoding:"utf8"})}n.issueCommand=issueCommand},5278:(r,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:true});function toCommandValue(r){if(r===null||r===undefined){return""}else if(typeof r==="string"||r instanceof String){return r}return JSON.stringify(r)}n.toCommandValue=toCommandValue},1514:function(r,n,i){"use strict";var e=this&&this.__awaiter||function(r,n,i,e){function adopt(r){return r instanceof i?r:new i(function(n){n(r)})}return new(i||(i=Promise))(function(i,o){function fulfilled(r){try{step(e.next(r))}catch(r){o(r)}}function rejected(r){try{step(e["throw"](r))}catch(r){o(r)}}function step(r){r.done?i(r.value):adopt(r.value).then(fulfilled,rejected)}step((e=e.apply(r,n||[])).next())})};var o=this&&this.__importStar||function(r){if(r&&r.__esModule)return r;var n={};if(r!=null)for(var i in r)if(Object.hasOwnProperty.call(r,i))n[i]=r[i];n["default"]=r;return n};Object.defineProperty(n,"__esModule",{value:true});const t=o(i(8159));function exec(r,n,i){return e(this,void 0,void 0,function*(){const e=t.argStringToArray(r);if(e.length===0){throw new Error(`Parameter 'commandLine' cannot be null or empty.`)}const o=e[0];n=e.slice(1).concat(n||[]);const s=new t.ToolRunner(o,n,i);return s.exec()})}n.exec=exec},8159:function(r,n,i){"use strict";var e=this&&this.__awaiter||function(r,n,i,e){function adopt(r){return r instanceof i?r:new i(function(n){n(r)})}return new(i||(i=Promise))(function(i,o){function fulfilled(r){try{step(e.next(r))}catch(r){o(r)}}function rejected(r){try{step(e["throw"](r))}catch(r){o(r)}}function step(r){r.done?i(r.value):adopt(r.value).then(fulfilled,rejected)}step((e=e.apply(r,n||[])).next())})};var o=this&&this.__importStar||function(r){if(r&&r.__esModule)return r;var n={};if(r!=null)for(var i in r)if(Object.hasOwnProperty.call(r,i))n[i]=r[i];n["default"]=r;return n};Object.defineProperty(n,"__esModule",{value:true});const t=o(i(2087));const s=o(i(8614));const u=o(i(3129));const c=o(i(5622));const f=o(i(7436));const l=o(i(1962));const a=process.platform==="win32";class ToolRunner extends s.EventEmitter{constructor(r,n,i){super();if(!r){throw new Error("Parameter 'toolPath' cannot be null or empty.")}this.toolPath=r;this.args=n||[];this.options=i||{}}_debug(r){if(this.options.listeners&&this.options.listeners.debug){this.options.listeners.debug(r)}}_getCommandString(r,n){const i=this._getSpawnFileName();const e=this._getSpawnArgs(r);let o=n?"":"[command]";if(a){if(this._isCmdFile()){o+=i;for(const r of e){o+=` ${r}`}}else if(r.windowsVerbatimArguments){o+=`"${i}"`;for(const r of e){o+=` ${r}`}}else{o+=this._windowsQuoteCmdArg(i);for(const r of e){o+=` ${this._windowsQuoteCmdArg(r)}`}}}else{o+=i;for(const r of e){o+=` ${r}`}}return o}_processLineBuffer(r,n,i){try{let e=n+r.toString();let o=e.indexOf(t.EOL);while(o>-1){const r=e.substring(0,o);i(r);e=e.substring(o+t.EOL.length);o=e.indexOf(t.EOL)}n=e}catch(r){this._debug(`error processing line. Failed with error ${r}`)}}_getSpawnFileName(){if(a){if(this._isCmdFile()){return process.env["COMSPEC"]||"cmd.exe"}}return this.toolPath}_getSpawnArgs(r){if(a){if(this._isCmdFile()){let n=`/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;for(const i of this.args){n+=" ";n+=r.windowsVerbatimArguments?i:this._windowsQuoteCmdArg(i)}n+='"';return[n]}}return this.args}_endsWith(r,n){return r.endsWith(n)}_isCmdFile(){const r=this.toolPath.toUpperCase();return this._endsWith(r,".CMD")||this._endsWith(r,".BAT")}_windowsQuoteCmdArg(r){if(!this._isCmdFile()){return this._uvQuoteCmdArg(r)}if(!r){return'""'}const n=[" ","\t","&","(",")","[","]","{","}","^","=",";","!","'","+",",","`","~","|","<",">",'"'];let i=false;for(const e of r){if(n.some(r=>r===e)){i=true;break}}if(!i){return r}let e='"';let o=true;for(let n=r.length;n>0;n--){e+=r[n-1];if(o&&r[n-1]==="\\"){e+="\\"}else if(r[n-1]==='"'){o=true;e+='"'}else{o=false}}e+='"';return e.split("").reverse().join("")}_uvQuoteCmdArg(r){if(!r){return'""'}if(!r.includes(" ")&&!r.includes("\t")&&!r.includes('"')){return r}if(!r.includes('"')&&!r.includes("\\")){return`"${r}"`}let n='"';let i=true;for(let e=r.length;e>0;e--){n+=r[e-1];if(i&&r[e-1]==="\\"){n+="\\"}else if(r[e-1]==='"'){i=true;n+="\\"}else{i=false}}n+='"';return n.split("").reverse().join("")}_cloneExecOptions(r){r=r||{};const n={cwd:r.cwd||process.cwd(),env:r.env||process.env,silent:r.silent||false,windowsVerbatimArguments:r.windowsVerbatimArguments||false,failOnStdErr:r.failOnStdErr||false,ignoreReturnCode:r.ignoreReturnCode||false,delay:r.delay||1e4};n.outStream=r.outStream||process.stdout;n.errStream=r.errStream||process.stderr;return n}_getSpawnOptions(r,n){r=r||{};const i={};i.cwd=r.cwd;i.env=r.env;i["windowsVerbatimArguments"]=r.windowsVerbatimArguments||this._isCmdFile();if(r.windowsVerbatimArguments){i.argv0=`"${n}"`}return i}exec(){return e(this,void 0,void 0,function*(){if(!l.isRooted(this.toolPath)&&(this.toolPath.includes("/")||a&&this.toolPath.includes("\\"))){this.toolPath=c.resolve(process.cwd(),this.options.cwd||process.cwd(),this.toolPath)}this.toolPath=yield f.which(this.toolPath,true);return new Promise((r,n)=>{this._debug(`exec tool: ${this.toolPath}`);this._debug("arguments:");for(const r of this.args){this._debug(` ${r}`)}const i=this._cloneExecOptions(this.options);if(!i.silent&&i.outStream){i.outStream.write(this._getCommandString(i)+t.EOL)}const e=new ExecState(i,this.toolPath);e.on("debug",r=>{this._debug(r)});const o=this._getSpawnFileName();const s=u.spawn(o,this._getSpawnArgs(i),this._getSpawnOptions(this.options,o));const c="";if(s.stdout){s.stdout.on("data",r=>{if(this.options.listeners&&this.options.listeners.stdout){this.options.listeners.stdout(r)}if(!i.silent&&i.outStream){i.outStream.write(r)}this._processLineBuffer(r,c,r=>{if(this.options.listeners&&this.options.listeners.stdline){this.options.listeners.stdline(r)}})})}const f="";if(s.stderr){s.stderr.on("data",r=>{e.processStderr=true;if(this.options.listeners&&this.options.listeners.stderr){this.options.listeners.stderr(r)}if(!i.silent&&i.errStream&&i.outStream){const n=i.failOnStdErr?i.errStream:i.outStream;n.write(r)}this._processLineBuffer(r,f,r=>{if(this.options.listeners&&this.options.listeners.errline){this.options.listeners.errline(r)}})})}s.on("error",r=>{e.processError=r.message;e.processExited=true;e.processClosed=true;e.CheckComplete()});s.on("exit",r=>{e.processExitCode=r;e.processExited=true;this._debug(`Exit code ${r} received from tool '${this.toolPath}'`);e.CheckComplete()});s.on("close",r=>{e.processExitCode=r;e.processExited=true;e.processClosed=true;this._debug(`STDIO streams have closed for tool '${this.toolPath}'`);e.CheckComplete()});e.on("done",(i,e)=>{if(c.length>0){this.emit("stdline",c)}if(f.length>0){this.emit("errline",f)}s.removeAllListeners();if(i){n(i)}else{r(e)}});if(this.options.input){if(!s.stdin){throw new Error("child process missing stdin")}s.stdin.end(this.options.input)}})})}}n.ToolRunner=ToolRunner;function argStringToArray(r){const n=[];let i=false;let e=false;let o="";function append(r){if(e&&r!=='"'){o+="\\"}o+=r;e=false}for(let t=0;t