Skip to content

fix

fix #47

Workflow file for this run

name: API Docker
on:
push:
branches:
- "poetry-docker"
concurrency:
group: api-docker-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DIFY_API_IMAGE_NAME: ${{ vars.DIFY_API_IMAGE_NAME || 'langgenius/dify-api' }}
jobs:
api-docker:
runs-on: ${{ matrix.platform == 'linux/arm64' && 'arm64_runner' || 'ubuntu-latest' }}
if: github.repository == 'langgenius/dify'
strategy:
matrix:
include:
- platform: linux/amd64
- platform: linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@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: ${{ env.DIFY_API_IMAGE_NAME }}
tags: |
type=sha,enable=true,priority=100,prefix=poetry-,suffix=-${{ matrix.platform }},format=long
- name: Set platform variable
run: echo "PLATFORM_SANITIZED=${{ matrix.platform }}/" | sed 's/\//-/g' >> $GITHUB_ENV
- name: Build Docker image
uses: docker/build-push-action@v5
with:
push: false
context: ./api
file: ./api/poetry.Dockerfile
build-args: COMMIT_SHA=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=${{ matrix.platform }}
outputs: type=docker,dest=/tmp/${{ github.sha }}-${{ env.PLATFORM_SANITIZED }}.tar
create-manifest:
needs: api-docker
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USER }}
password: ${{ env.DOCKERHUB_TOKEN }}
- name: Set platform variable
run: echo "PLATFORM_SANITIZED=${{ matrix.platform }}/" | sed 's/\//-/g' >> $GITHUB_ENV
- name: Load images
run: |
docker load -i /tmp/${{ github.sha }}-linux-amd64.tar
docker load -i /tmp/${{ github.sha }}-linux-arm64.tar
- name: Create and Push Docker Manifest
run: |
docker buildx imagetools create \
--tag ${{ env.DIFY_API_IMAGE_NAME }}:poetry-${{ github.sha }} \
${{ env.DIFY_API_IMAGE_NAME }}:poetry-${{ github.sha }}-linux-amd64 \
${{ env.DIFY_API_IMAGE_NAME }}:poetry-${{ github.sha }}-linux-arm64
docker manifest inspect ${{ env.DIFY_API_IMAGE_NAME }}:poetry-${{ github.sha }}