BEAM Docker Release
ActionsTags
(1)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:
- Elixir with the Phoenix Framework using mix to build;
- Erlang/OTP with erlang.mk;
- Erlang/OTP with rebar3
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:
- Erlang/OTP memcached server and client
- Erlang/OTP real-time in memory database replication cache, with a memcached and REST API
Ensure that your workflow has sufficent permissions to write to ghcr by including in your workflow:
permissions:
packages: write
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
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
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/[email protected]
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
Required The container repository being used, e.g., ghcr.io
.
Required The username used to authenticate with the container
repository, e.g., ${{ github.actor }}
.
Required The password used to authenticate with the container
repository, e.g., ${{ secrets.GITHUB_TOKEN }}
.
Required The build image used. Typically this should be the
appropriate version of erlang
or elixir
.
Required The command used to build the release. Examples for each mix, erlang.mk or rebar3 are above.
The platforms that are used for the build. This defaults to
linux/amd64,linux/arm64
.
Required The tags applied to the release.
The Git URL to the repository. For example, git://github.com/codertocat/hello-world.git.
None.
BEAM Docker Release is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.