Skip to content

Commit

Permalink
use docker cloud build
Browse files Browse the repository at this point in the history
  • Loading branch information
davehorton committed May 2, 2024
1 parent 609abcc commit 4c3a7d0
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 38 deletions.
80 changes: 45 additions & 35 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ name: Docker

on:
push:
# Publish `master` as Docker `latest` image.
branches:
- master

# Publish `v1.2.3` tags as releases.
- jambonz
tags:
- v*

env:
IMAGE_NAME: rtpengine
- '*'

jobs:
push:
Expand All @@ -20,32 +14,48 @@ jobs:
if: github.event_name == 'push'

steps:
- uses: actions/checkout@v2

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME
- name: Checkout code
uses: actions/checkout@v4

- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image
- name: prepare tag
id: prepare_tag
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
IMAGE_ID=jambonz/rtpengine
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "jambonz" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
echo "image_id=$IMAGE_ID" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: "lab:latest"
driver: cloud
endpoint: "drachtio/freeswitch-builder"

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
tags: ${{ steps.prepare_tag.outputs.image_id }}:${{ steps.prepare_tag.outputs.version }}
build-args: BUILD_CPUS=16
# For pull requests, export results to the build cache.
# Otherwise, push to a registry.
outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry,push=true' }}
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM debian:bookworm-slim

ARG BUILD_CPUS=1
RUN apt-get update \
&& apt-get remove --auto-remove nftables \
&& apt-get purge nftables \
Expand All @@ -16,14 +16,14 @@ RUN apt-get update \
&& git clone https://github.com/BelledonneCommunications/bcg729.git \
&& cd bcg729 \
&& echo "building bcg729" \
&& cmake . -DCMAKE_INSTALL_PREFIX=/usr && make && make install \
&& cmake . -DCMAKE_INSTALL_PREFIX=/usr && make -j ${BUILD_CPUS} && make install \
&& cd /usr/local/src \
&& git clone https://github.com/warmcat/libwebsockets.git -b v4.3.2 \
&& cd /usr/local/src/libwebsockets \
&& mkdir -p build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo && make && make install \
&& git clone https://github.com/sipwise/rtpengine.git -b mr11.5.1.24 \
&& cd rtpengine/daemon \
&& make with_transcoding=yes \
&& make -j ${BUILD_CPUS} with_transcoding=yes \
&& find . -name rtpengine \
&& cp rtpengine /usr/local/bin/rtpengine \
&& rm -Rf /usr/local/src/rtpengine \
Expand Down

0 comments on commit 4c3a7d0

Please sign in to comment.