diff --git a/.github/images/alpine:3.Dockerfile b/.github/images/alpine:3.Dockerfile new file mode 100644 index 0000000..66e1c30 --- /dev/null +++ b/.github/images/alpine:3.Dockerfile @@ -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" ] \ No newline at end of file diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml new file mode 100644 index 0000000..dd4f093 --- /dev/null +++ b/.github/workflows/build-container.yml @@ -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 }} diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index c4bd6fa..a038b17 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -8,6 +8,7 @@ on: - reopened - ready_for_review - synchronize + workflow_call: jobs: output-unit-tests: diff --git a/README.md b/README.md index 820d8c9..3a04547 100644 --- a/README.md +++ b/README.md @@ -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,