Skip to content

optimize: using identity to detect whether to use serverless or local… #223

optimize: using identity to detect whether to use serverless or local…

optimize: using identity to detect whether to use serverless or local… #223

Workflow file for this run

name: Build and Push Daemon
on:
push:
branches:
- "main"
- "deploy/dev"
release:
types: [published]
concurrency:
group: build-push-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DIFY_DAEMON_IMAGE_NAME: ${{ vars.DIFY_DAEMON_IMAGE_NAME || 'langgenius/dify-plugin-daemon' }}
jobs:
build:
runs-on: ${{ matrix.platform == 'linux/arm64' && 'arm64_runner' || 'ubuntu-latest' }}
if: github.repository == 'langgenius/dify-plugin-daemon'
strategy:
matrix:
include:
- service_name: "build-serverless-daemon-amd64"
image_name_env: "DIFY_DAEMON_IMAGE_NAME"
platform: linux/amd64
scope: serverless
- service_name: "build-serverless-daemon-arm64"
image_name_env: "DIFY_DAEMON_IMAGE_NAME"
platform: linux/arm64
scope: serverless
- service_name: "build-local-daemon-amd64"
image_name_env: "DIFY_DAEMON_IMAGE_NAME"
platform: linux/amd64
scope: local
- service_name: "build-local-daemon-arm64"
image_name_env: "DIFY_DAEMON_IMAGE_NAME"
platform: linux/arm64
scope: local
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USER }}
password: ${{ env.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DIFY_DAEMON_IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=ref,event=branch
type=sha,enable=true,priority=100,prefix=,suffix=,format=long
type=raw,value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/') }}
- name: Run Build Docker Image
run: docker build -t dify-plugin-daemon -f ./docker/${{ matrix.scope }}/Dockerfile .
- name: Tag Docker Images
run:
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n');
do
docker tag dify-plugin-daemon "$tag-${{ matrix.scope }}-${{ env.PLATFORM_PAIR }}";
done
- name: Push Docker Image
run:
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n');
do
docker push $tag-${{ matrix.scope }}-${{ env.PLATFORM_PAIR }};
done
create-manifest:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
scope: [serverless, local]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USER }}
password: ${{ env.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ vars.DIFY_DAEMON_IMAGE_NAME || 'langgenius/dify-plugin-daemon' }}
tags: |
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=ref,event=branch
type=sha,enable=true,priority=100,prefix=,suffix=,format=long
type=raw,value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/') }}
- name: Build Universal Docker Images
run:
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n');
do
docker manifest create $tag-${{ matrix.scope }} $tag-${{ matrix.scope }}-linux-amd64 $tag-${{ matrix.scope }}-linux-arm64;
docker manifest push $tag-${{ matrix.scope }};
done