Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dwilkie committed Sep 20, 2024
1 parent 1fb554f commit 3c6b668
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 24 deletions.
56 changes: 44 additions & 12 deletions .github/workflows/media_proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
[
{
"identifier": "media-proxy-staging",
"branch": "develop",
"branch": "fix_docker_build",
"friendly_image_tag": "beta",
"image_tag": "stag-${{ github.sha }}",
"ecs_service": "media-proxy-staging",
Expand Down Expand Up @@ -85,17 +85,49 @@ jobs:
export DOCKER_BUILDKIT=1
docker buildx build --cache-from ${{ secrets.ECR_REGISTRY }}/${{ env.REPOSITORY_NAME }}:${{ matrix.friendly_image_tag }}-${{ matrix.platform }} --tag ${{ secrets.ECR_REGISTRY }}/${{ env.REPOSITORY_NAME }}:${{ matrix.friendly_image_tag }}-${{ matrix.platform }} --push components/media_proxy
- name: Build and push Media Proxy
uses: docker/build-push-action@v6
build-manifest:
name: Build Manifest
runs-on: ubuntu-latest

needs:
- build
- build-packages

strategy:
matrix: ${{fromJSON(needs.build.outputs.matrix)}}

steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
context: components/media_proxy
push: true
cache-from: type=gha,scope=${{ matrix.identifier }}
cache-to: type=gha,mode=max,scope=${{ matrix.identifier }}
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.ECR_REGISTRY }}/${{ env.REPOSITORY_NAME }}:${{ matrix.image_tag }}
${{ secrets.GHCR_REGISTRY }}/${{ env.REPOSITORY_NAME }}:${{ matrix.friendly_image_tag }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-skip-session-tagging: true
role-duration-seconds: 3600
aws-region: ap-southeast-1

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

- name: Build Manifest
run: |
declare -a platforms=("amd64" "arm64")
source_images=$(printf "${{ env.ECR_REGISTRY }}/${{ env.REPOSITORY_NAME }}:${{ matrix.friendly_image_tag }}-%s " "${platforms[@]}")
docker buildx imagetools create -t ${{ env.ECR_REGISTRY }}/${{ env.REPOSITORY_NAME }}:${{ matrix.friendly_image_tag }} -t ${{ env.ECR_REGISTRY }}/${{ env.REPOSITORY_NAME }}:${{ matrix.image_tag }} $source_images
- name: Publish Images
run: |
declare -a platforms=("amd64" "arm64")
for platform in "${platforms[@]}"
do
docker image pull ${{ env.ECR_REGISTRY }}/${{ env.REPOSITORY_NAME }}:${{ matrix.friendly_image_tag }}-$platform
docker tag ${{ env.ECR_REGISTRY }}/${{ env.REPOSITORY_NAME }}:${{ matrix.friendly_image_tag }}-$platform ${{ env.GHCR_REGISTRY }}/${{ env.REPOSITORY_NAME }}:${{ matrix.friendly_image_tag }}-$platform
docker push ${{ env.GHCR_REGISTRY }}/${{ env.REPOSITORY_NAME }}:${{ matrix.friendly_image_tag }}-$platform
done
source_images=$(printf "${{ env.GHCR_REGISTRY }}/${{ env.REPOSITORY_NAME }}:${{ matrix.friendly_image_tag }}-%s " "${platforms[@]}")
docker buildx imagetools create -t ${{ env.GHCR_REGISTRY }}/${{ env.REPOSITORY_NAME }}:${{ matrix.friendly_image_tag }} $source_images
deploy:
name: Deploy
Expand All @@ -104,7 +136,7 @@ jobs:

needs:
- build
- build-packages
- build-manifest

strategy:
matrix: ${{fromJson(needs.build.outputs.matrix)}}
Expand Down
19 changes: 7 additions & 12 deletions .github/workflows/switch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,9 @@ jobs:
for component in "${components[@]}"
do
if [ "$component" = "${{ env.FREESWITCH_REPOSITORY_NAME }}" ]; then
echo "Building manifiest for: $component"
echo "docker buildx imagetools create -t ${{ secrets.ECR_REGISTRY }}/$component:${{ matrix.friendly_image_tag }} -t ${{ secrets.ECR_REGISTRY }}/$component:${{ matrix.image_tag }} ${{ secrets.ECR_REGISTRY }}/$component:${{ matrix.friendly_image_tag }}-amd64"
docker buildx imagetools create -t ${{ secrets.ECR_REGISTRY }}/$component:${{ matrix.friendly_image_tag }} -t ${{ secrets.ECR_REGISTRY }}/$component:${{ matrix.image_tag }} ${{ secrets.ECR_REGISTRY }}/$component:${{ matrix.friendly_image_tag }}-amd64
else
echo "Building manifiest for: $component" with source images
source_images=$(printf "${{ secrets.ECR_REGISTRY }}/$component:${{ matrix.friendly_image_tag }}-%s " "${platforms[@]}")
echo "docker buildx imagetools create -t ${{ secrets.ECR_REGISTRY }}/$component:${{ matrix.friendly_image_tag }} -t ${{ secrets.ECR_REGISTRY }}/$component:${{ matrix.image_tag }} $source_images"
docker buildx imagetools create -t ${{ secrets.ECR_REGISTRY }}/$component:${{ matrix.friendly_image_tag }} -t ${{ secrets.ECR_REGISTRY }}/$component:${{ matrix.image_tag }} $source_images
fi
done
Expand Down Expand Up @@ -229,25 +225,24 @@ jobs:
run: |
declare -a platforms=("amd64" "arm64")
declare -a components=("${{ env.APP_REPOSITORY_NAME }}" "${{ env.WEBSERVER_REPOSITORY_NAME }}" "${{ env.FREESWITCH_REPOSITORY_NAME }}" "${{ env.FREESWITCH_EVENT_LOGGER_REPOSITORY_NAME }}")
for platform in "${platforms[@]}"
do
for component in "${components[@]}"
do
[ "$component" = "${{ env.FREESWITCH_REPOSITORY_NAME }}" ] && [ "$platform" = "arm64" ] && continue
docker image pull ${{ secrets.ECR_REGISTRY }}/$component:${{ env.IMAGE_ALIAS }}-$platform
docker tag ${{ secrets.ECR_REGISTRY }}/$component:${{ env.IMAGE_ALIAS }}-$platform ${{ secrets.GHCR_REGISTRY }}/$component:${{ env.IMAGE_ALIAS }}-$platform
docker push ${{ secrets.GHCR_REGISTRY }}/$component:${{ env.IMAGE_ALIAS }}-$platform
[ "$component" = "${{ env.FREESWITCH_REPOSITORY_NAME }}" ] && [ $platform = "arm64" ] && continue
docker image pull ${{ env.ECR_REGISTRY }}/$component:${{ matrix.friendly_image_tag }}-$platform
docker tag ${{ env.ECR_REGISTRY }}/$component:${{ matrix.friendly_image_tag }}-$platform ${{ env.GHCR_REGISTRY }}/$component:${{ matrix.friendly_image_tag }}-$platform
docker push ${{ env.GHCR_REGISTRY }}/$component:${{ matrix.friendly_image_tag }}-$platform
done
done
for component in "${components[@]}"
do
if [ "$component" = "${{ env.FREESWITCH_REPOSITORY_NAME }}" ]; then
docker buildx imagetools create -t ${{ secrets.GHCR_REGISTRY }}/$component:${{ env.IMAGE_ALIAS }} "${{ secrets.GHCR_REGISTRY }}/$component:${{ env.IMAGE_ALIAS }}-amd64
docker buildx imagetools create -t ${{ secrets.GHCR_REGISTRY }}/$component:${{ matrix.friendly_image_tag }} ${{ secrets.GHCR_REGISTRY }}/$component:${{ matrix.friendly_image_tag }}-amd64
else
source_images=$(printf "${{ secrets.GHCR_REGISTRY }}/$component:${{ env.IMAGE_ALIAS }}-%s " "${platforms[@]}")
docker buildx imagetools create -t ${{ secrets.GHCR_REGISTRY }}/$component:${{ env.IMAGE_ALIAS }} $source_images
source_images=$(printf "${{ env.GHCR_REGISTRY }}/$component:${{ matrix.friendly_image_tag }}-%s " "${platforms[@]}")
docker buildx imagetools create -t ${{ env.GHCR_REGISTRY }}/$component:${{ matrix.friendly_image_tag }} $source_images
fi
done
Expand Down

0 comments on commit 3c6b668

Please sign in to comment.