GitHub Action to use 'buildah' to build a container image.
Find a file
Tim Etchells 27067e030d Fix OCI input detection
Signed-off-by: Tim Etchells <tetchell@redhat.com>
2020-11-30 14:45:05 -05:00
.github/workflows Fix verify build test 2020-11-25 12:53:04 +05:30
dist Fix OCI input detection 2020-11-30 14:45:05 -05:00
src Fix OCI input detection 2020-11-30 14:45:05 -05:00
.gitignore add language recognizer 2020-11-13 12:38:29 +01:00
action.yml Update action.yml 2020-11-28 00:24:05 +05:30
language-image.json add language recognizer 2020-11-13 12:38:29 +01:00
LICENSE add missing files for the action 2020-11-06 22:48:47 +01:00
package-lock.json Rename to buildah-build 2020-11-23 13:27:19 -05:00
package.json Rename to buildah-build 2020-11-23 13:27:19 -05:00
README.md Fix OCI input detection 2020-11-30 14:45:05 -05:00
tsconfig.json add support for building images with docker files (#4) (#5) 2020-11-19 09:19:57 +01:00

buildah-build

Verify Build Verify Bundle

tag badge license badge size badge

Buildah is a GitHub Action for building Docker and Kubernetes-compatible images quickly and easily.

Buildah only works on Linux. GitHub's Ubuntu Environments (ubuntu-18.04 and newer) come with buildah installed. If you are not using these environments, or if you want to use a different version, you must first install buildah.

After building your image, use push-to-registry to push the image and make it pullable.

Action Inputs

Input Required Description
image Yes Name to give the output image.
tag No Tag to give to the output image.
Default: latest
base-image 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 allow multiple Dockerfiles.
oci No 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.
context No Path to directory to use as the build context.
Default: .
build-args No Build arguments to pass to the Docker build using --build-arg, if using a Dockerfile that requires ARGs.
Uses the form arg_name=arg_value, and separate arguments with newlines.
content 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.
content: |
  target/spring-petclinic-2.3.0.BUILD-SNAPSHOT.jar
entrypoint No The entry point to set for the container. This is a multiline input; split arguments across lines.
entrypoint: |
  java
  -jar
  spring-petclinic-2.3.0.BUILD-SNAPSHOT.jar
port No The port to expose when running the container.
workdir No The working directory to use within the container.
envs No The environment variables to be set when running the container. This is a multiline input to add multiple environment variables.
envs: |
  GOPATH=/root/buildah/go

Build Types

You can configure the buildah action to build your image using one or more Dockerfiles, or from scratch.

Building using Docker

If you have been using Docker and have an existing Dockerfile, buildah can reuse your dockerfile.

In this case the inputs needed are image and dockerfiles. tag is also recommended. If your Dockerfile requires ARGs, these can be passed using build-arg.

name: Build Image using Dockerfile
on: [push]

jobs:
  build:
    name: Build image
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Buildah Action
      uses: redhat-actions/buildah-build@v1
      with:
        image: my-new-image
        tag: v1
        dockerfiles: |
          ./Dockerfile          
        build-args: |
          some_arg=some_value          

Building from scratch

Building from scratch requires more inputs, that would normally be specified in the Dockerfile.

Do not set dockerfiles if you are doing a build from scratch, or a docker build will be performed, and the other inputs will be ignored.

  • An output image name and usually a tag.
  • base-image
    • In a Dockerfile, this would be the FROM directive.
  • content to copy into the new image
    • In a Dockerfile, this would be COPY directives.
  • entrypoint so the container knows what command to run.
    • In a Dockerfile, this would be the ENTRYPOINT.
  • All other optional configuration inputs, such as port, envs, and workdir.

Example of building a Spring Boot Java app image:

name: Build Image
on: [push]

jobs:
  build-image:
    name: Build image
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - run: mvn package

    - name: Build Image
      uses: redhat-actions/buildah-build@v1
      with:
        base-image: docker.io/fabric8/java-alpine-openjdk11-jre
        image: my-new-image
        tag: v1
        content: |
          target/spring-petclinic-2.3.0.BUILD-SNAPSHOT.jar          
        entrypoint: java -jar spring-petclinic-2.3.0.BUILD-SNAPSHOT.jar
        port: 8080

Contributing

This is an open source project open to anyone. This project welcomes contributions and suggestions!

Feedback & Questions

If you discover an issue please file a bug in GitHub issues and we will fix it as soon as possible.

License

MIT, See LICENSE for more information.