Skip to content

shortishly/beam-docker-release-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BEAM Docker Release action

A GitHub action that builds BEAM releases into a from scratch container.

When packaging an application as a docker container it is too easy to just put FROM debian (other distributions are available, replace debian with your distribution of choice). For sure it is going to work, but you have just included dozens of libraries and binaries that your application just does not need. An image that could be tens of megabytes is now at least several hundred - we are building containers not virtual machines here!

Using a multi-stage, multi-platform, build coping only the release and its runtime dependencies into a scratch base image. There is no shell, or any executable other than those required to run the BEAM.

This is a composite action that:

  • Logs into a container repository
  • Creates a minimal docker image of a BEAM release from scratch
  • Pushes the image to the container repository

Supporting:

Platforms:

  • linux/amd64
  • linux/arm64

The default will create a multi-platform image for both amd64 and arm64.

Hello World! Simple examples for both Elixir and Erlang can be found at:

Some real examples:

Typical Usage

Ensure that your workflow has sufficent permissions to write to ghcr by including in your workflow:

permissions:
  packages: write

Elixir

The following example is triggered by a push event to build an Elixir Mix Prod Release.

---
on: [push]
permissions:
  packages: write
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Beam Docker Release
        uses: shortishly/beam-docker-release-action@v1
        with:
          registry: ghcr.io
          username: ${{github.actor}}
          password: ${{secrets.GITHUB_TOKEN}}
          build-command: >-
            mix do local.hex --force +
            deps.get +
            local.rebar --force +
            compile +
            assets.deploy +
            phx.digest +
            release --overwrite
          build-image: elixir:1.14.2
          build-tags: ghcr.io/${{github.repository}}:elixir-phx

Erlang/OTP with erlang.mk

The following example is triggered by a push event to build an Erlang/OTP Release with erlang.mk.

---
on: [push]
permissions:
  packages: write
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Beam Docker Release
        uses: shortishly/beam-docker-release-action@v1
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
          build-image: erlang:25.1
          build-platforms: linux/amd64
          build-tags: ghcr.io/${{ github.repository }}:erlang.mk

Erlang/OTP with rebar3

The following example is triggered by a push event to build an Erlang/OTP Release with rebar3.

---
on: [push]
permissions:
  packages: write
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Beam Docker Release
        uses: shortishly/beam-docker-release-action@v1.22
        with:
          registry: ghcr.io
          username: ${{github.actor}}
          password: ${{secrets.GITHUB_TOKEN}}
          build-command: rebar3 release
          build-platforms: linux/amd64
          build-tags: ghcr.io/${{github.repository}}:rebar3

Inputs

registry

Required The container repository being used, e.g., ghcr.io.

username

Required The username used to authenticate with the container repository, e.g., ${{ github.actor }}.

password

Required The password used to authenticate with the container repository, e.g., ${{ secrets.GITHUB_TOKEN }}.

build-image

Required The build image used. Typically this should be the appropriate version of erlang or elixir.

build-command

Required The command used to build the release. Examples for each mix, erlang.mk or rebar3 are above.

build-platforms

The platforms that are used for the build. This defaults to linux/amd64,linux/arm64.

build-tags

Required The tags applied to the release.

image-source

The Git URL to the repository. For example, git://github.com/codertocat/hello-world.git.

image-description

image-license

Outputs

None.