Skip to content

Commit

Permalink
Added container build workflow (#94)
Browse files Browse the repository at this point in the history
* added container build workflow

* remove unneeded env var
  • Loading branch information
hellt authored Jun 3, 2023
1 parent 92561f4 commit 9fa14cc
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/images/alpine:3.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# to build the image locally tagged with the short commit hash:
# docker build -t bgpq4:$(git rev-parse --short HEAD) -f .github/images/alpine:3.Dockerfile .
ARG IMAGE=alpine:3
FROM $IMAGE as builder

# Install dependencies
RUN apk upgrade
RUN apk add autoconf automake file gcc gzip libtool make musl-dev

# Add source code
ADD . /src
WORKDIR /src

# Run steps
RUN ./bootstrap
RUN ./configure
RUN make
RUN make check
RUN make distcheck

FROM alpine:3
COPY --from=builder /src/bgpq4 /bgp/
WORKDIR /bgp
ENTRYPOINT [ "./bgpq4" ]
64 changes: 64 additions & 0 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Container build
"on":
push:
tags:
- "*" # Push events to any tag
branches:
- "main"

workflow_dispatch:
inputs:
tag:
description: "Container tag to use for the build"
required: true
default: "test"

jobs:
test:
uses: ./.github/workflows/unit-tests.yml

build:
name: Build container
runs-on: ubuntu-22.04
needs: test

steps:
- name: Checkout
uses: actions/checkout@v3

- # Add support for more platforms with QEMU
# https://github.com/docker/setup-qemu-action
name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository_owner }}/bgpq4
tags: |
# pick up tag provided from workflow_dispatch user's input
type=raw,value=${{ inputs.tag }}
type=ref,event=tag
type=ref,event=branch
# git short commit
type=sha
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
file: .github/images/alpine:3.Dockerfile
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
1 change: 1 addition & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- reopened
- ready_for_review
- synchronize
workflow_call:

jobs:
output-unit-tests:
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,31 @@ Linux can be tuned in the following way:

sysctl -w net.ipv4.tcp_wmem="4096 65536 2097152"

# CONTAINER IMAGE

A multi-arch (linux/amd64 and linux/arm64) container image is built automatically for all tagged releases and `main` branch. The image is based on Alpine Linux and is available on [GitHub Container Registry](https://github.com/bgp/bgpq4/pkgs/container/bgpq4).

Using the image is as simple as:

```
docker run --rm ghcr.io/bgp/bgpq4:latest -Jl eltel AS20597
policy-options {
replace:
prefix-list eltel {
81.9.0.0/20;
81.9.32.0/20;
81.9.96.0/20;
81.222.128.0/20;
81.222.160.0/20;
81.222.192.0/18;
85.249.8.0/21;
85.249.224.0/19;
89.112.0.0/17;
217.170.64.0/19;
}
}
```

# BUILDING

This project uses autotools. If you are building from the repository,
Expand Down

0 comments on commit 9fa14cc

Please sign in to comment.