From 0c1d3d77d8a8bb3e31c72dec7b799b3dc922c869 Mon Sep 17 00:00:00 2001 From: Luca Stocchi Date: Wed, 18 Nov 2020 09:06:11 +0100 Subject: [PATCH] update readme Signed-off-by: Luca Stocchi --- README.md | 83 ++++++++++++++++++++++++++++++++++++++++++++---------- action.yml | 2 +- 2 files changed, 69 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 8d14ec3..d075521 100644 --- a/README.md +++ b/README.md @@ -15,48 +15,103 @@ Note that GitHub's [Ubuntu Environments](https://github.com/actions/virtual-envi - + + - - + + + - + + + + + + + + + + + + + + - + + - + + - + + - + + - + +
Action inputinputRequired Description
new-image-name(Required) Name to give to the image that will be eventually created.imageYesName 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.NoThe 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)
dockerfilesNoThe list of Dockerfile paths to perform a build using docker instructions. This is a multiline input to add multiple values.
contextNoThe 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
NoThe 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
NoThe 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.NoThe port to expose when running the container.
working-dir(Optional) The working directory to use within the container.NoThe 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
NoThe 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 712a006..dad49a5 100644 --- a/action.yml +++ b/action.yml @@ -15,7 +15,7 @@ inputs: description: 'List of Dockerfile paths (eg: ./Dockerfile)' required: false context: - description: 'Path to the directory to use as context (default: .)' + description: 'Path of the directory to use as context (default: .)' required: false default: '.' content: