Giter Site home page Giter Site logo

terrorizer1980 / buildah-build Goto Github PK

View Code? Open in Web Editor NEW

This project forked from redhat-actions/buildah-build

0.0 0.0 0.0 374 KB

GitHub Action to use 'buildah' to build a container image.

Home Page: https://github.com/marketplace/actions/buildah-build

License: MIT License

TypeScript 97.84% JavaScript 0.45% Shell 1.72%

buildah-build's Introduction

buildah-build

CI checks Build Build from dockerfile Link checker

tag badge license badge size badge

Buildah Build 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

Inputs for build from dockerfile

Input Name Description Default
archs Architecture(s) to build the image(s) for. For multiple architectures, separate by a comma. Refer to Multi arch builds to setup the qemu-user-static dependency. None (host architecture)
build-args Build arguments to pass to the Docker build using --build-arg, if using a Dockerfile that requires ARGs. Use the form arg_name=arg_value, and separate arguments with newlines. None
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
extra-args Extra args to be passed to buildah bud. Separate arguments by newline. Do not use quotes. None
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

Inputs for build without dockerfile

Input Name Description Default
archs Architecture(s) to build the image(s) for. For multiple architectures, separate by a comma. None (host architecture)
base-image The base image to use for the container. Must be provided
content Paths to files or directories to copy inside the container to create the file image. This is a multiline input to allow you to copy multiple files/directories. None
entrypoint The entry point to set for the container. This is a multiline input; split arguments across lines. None
envs The environment variables to be set when running the container. This is a multiline input to add multiple environment variables. None
image Name to give to the output image. Must be provided
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
port The port to expose when running the container. None
tags The tags of the image to build. For multiple tags, separate by a space. For example, latest ${{ github.sha }} latest
workdir The working directory to use within the container. None

Action Outputs

image: The name of the built image.
For example, spring-image.

tags: A list of the tags that were created, separated by spaces.
For example, latest ${{ github.sha }}.

Build Types

You can configure the buildah action to build your image using one or more Dockerfiles, or none at all.

Building using Dockerfiles

If you have been building your images with 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@v2
      with:
        image: my-new-image
        tags: v1 ${{ github.sha }}
        dockerfiles: |
          ./Dockerfile
        build-args: |
          some_arg=some_value

Building without a Dockerfile

Building without a Dockerfile requires additional inputs, that would normally be specified in the Dockerfile.

Do not set dockerfiles if you are doing a build from scratch. Otherwise those Dockerfiles will be used, and the inputs below 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 without Dockerfile
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - run: mvn package

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

Multi arch builds

Cross-architecture builds from dockerfiles containing RUN instructions require qemu-user-static emulation registered in the Linux kernel. Run sudo apt install -y qemu-user-static on Debian-based container hosts. Or run the following registration command for other distributions:

sudo podman run --rm --privileged docker.io/tonistiigi/binfmt --install all

The registration remains active until the container host reboots.

Using private images

If your build references a private image, run podman-login in a step before this action so you can pull the image. For example:

- name: Log in to Red Hat Registry
  uses: redhat-actions/podman-login@v1
  with:
    registry: registry.redhat.io
    username: ${{ secrets.REGISTRY_REDHAT_IO_USER }}
    password: ${{ secrets.REGISTRY_REDHAT_IO_PASSWORD }}

buildah-build's People

Contributors

agterdenbos avatar divyansh42 avatar k3rnelpan1c-dev avatar lcarva avatar lstocchi avatar tetchel avatar willhaines avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.