name: Docker Build and Push on: workflow_call: inputs: version: required: true type: string release_type: required: true type: string workflow_dispatch: inputs: version: required: true type: string release_type: required: true type: choice options: - base - main env: POETRY_VERSION: "1.8.2" jobs: setup: runs-on: ubuntu-latest outputs: base_tags: ${{ steps.set-vars.outputs.base_tags }} main_tags: ${{ steps.set-vars.outputs.main_tags }} steps: - uses: actions/checkout@v4 - name: Set Dockerfile and Tags id: set-vars run: | echo "::set-output name=base_tags::langflowai/langflow:base-${{ inputs.version }}" echo "::set-output name=main_tags::langflowai/langflow:${{ inputs.version }},langflowai/langflow:1.0-alpha" build_base: runs-on: ubuntu-latest needs: setup steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push Base Image uses: docker/build-push-action@v5 with: context: . push: true platforms: "linux/amd64,linux/arm64/v8" file: ./docker/build_and_push_base.Dockerfile tags: ${{ needs.setup.outputs.base_tags }} build_components: if: ${{ inputs.release_type == 'main' }} runs-on: ubuntu-latest needs: build_base strategy: matrix: component: [backend, frontend] include: - component: backend dockerfile: ./docker/build_and_push_backend.Dockerfile tags: langflowai/langflow-backend:${{ inputs.version }},langflowai/langflow-backend:1.0-alpha - component: frontend dockerfile: ./docker/frontend/build_and_push_frontend.Dockerfile tags: langflowai/langflow-frontend:${{ inputs.version }},langflowai/langflow-frontend:1.0-alpha steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push ${{ matrix.component }} uses: docker/build-push-action@v5 with: context: . push: true platforms: "linux/amd64,linux/arm64/v8" file: ${{ matrix.dockerfile }} tags: ${{ matrix.tags }} restart-space: name: Restart HuggingFace Spaces if: ${{ inputs.release_type == 'main' }} runs-on: ubuntu-latest needs: build_base strategy: matrix: python-version: - "3.12" steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }} uses: "./.github/actions/poetry_caching" with: python-version: ${{ matrix.python-version }} poetry-version: ${{ env.POETRY_VERSION }} cache-key: ${{ runner.os }}-poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }} - name: Install Python dependencies run: | poetry env use ${{ matrix.python-version }} poetry install - name: Restart HuggingFace Spaces Build run: | poetry run python ./scripts/factory_restart_space.py --space "Langflow/Langflow-Preview" --token ${{ secrets.HUGGINGFACE_API_TOKEN }}