chore: remove pipecat version check from docker build process

This commit is contained in:
Sabiha Khan 2025-10-03 14:03:12 +05:30
parent c7e75819f4
commit d55205fd67
7 changed files with 181 additions and 103 deletions

View file

@ -28,23 +28,14 @@ jobs:
with:
submodules: true # Only for version check, not used in build
- name: Check pipecat version sync
id: version-check
- name: Get pipecat commit SHA
id: pipecat-version
run: |
chmod +x scripts/check_pipecat_sync.sh
# Capture the output for version details
if OUTPUT=$(./scripts/check_pipecat_sync.sh 2>&1); then
echo "version_mismatch=false" >> $GITHUB_OUTPUT
else
echo "version_mismatch=true" >> $GITHUB_OUTPUT
# Extract version info from the output
SUBMODULE_VERSION=$(echo "$OUTPUT" | grep "Submodule commit:" | awk '{print $3}')
DOCKERFILE_VERSION=$(echo "$OUTPUT" | grep "Dockerfile commit:" | awk '{print $3}')
echo "submodule_version=${SUBMODULE_VERSION}" >> $GITHUB_OUTPUT
echo "dockerfile_version=${DOCKERFILE_VERSION}" >> $GITHUB_OUTPUT
# Don't fail the build, just note the mismatch
fi
# Extract the pipecat commit SHA from submodule
chmod +x scripts/get_pipecat_commit.sh
PIPECAT_COMMIT=$(./scripts/get_pipecat_commit.sh)
echo "pipecat_commit=${PIPECAT_COMMIT}" >> $GITHUB_OUTPUT
echo "📦 Pipecat commit SHA: ${PIPECAT_COMMIT}"
- name: Set up QEMU # Enables cross-platform builds (e.g., arm64)
uses: docker/setup-qemu-action@v3
@ -89,6 +80,7 @@ jobs:
# Build and push multi-arch Docker image to DockerHub and GHCR
docker buildx build \
-f "$DOCKERFILE" \
--build-arg PIPECAT_COMMIT=${{ steps.pipecat-version.outputs.pipecat_commit }} \
--platform linux/amd64,linux/arm64 \
--tag ${{ secrets.DOCKERHUB_USERNAME }}/$IMAGE_NAME:$SHORT_SHA \
--tag ${{ secrets.DOCKERHUB_USERNAME }}/$IMAGE_NAME:latest \
@ -133,7 +125,7 @@ jobs:
"elements": [
{
"type": "mrkdwn",
"text": "${{ steps.version-check.outputs.version_mismatch == 'true' && format('⚠️ Warning: Pipecat version mismatch detected - <@{0}> <@{1}> please sync versions', secrets.SLACK_DEV1_ID, secrets.SLACK_DEV2_ID) || '✅ Pipecat versions in sync' }}"
"text": "✅ Pipecat commit: `${{ steps.pipecat-version.outputs.pipecat_commit }}`"
}
]
}
@ -169,7 +161,7 @@ jobs:
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ steps.version-check.outputs.version_mismatch == 'true' && format('*🔴 Pipecat Version Mismatch:*\n• Submodule: `{0}`\n• Dockerfile: `{1}`\n\n_This may have caused the build failure._\n\n<@{2}> <@{3}> Please update api/Dockerfile to use commit {0}', steps.version-check.outputs.submodule_version, steps.version-check.outputs.dockerfile_version, secrets.SLACK_DEV1_ID, secrets.SLACK_DEV2_ID) || '*Failure Reason:* Check workflow logs for details' }}"
"text": "*Failure Reason:* Check workflow logs for details\n*Pipecat commit:* `${{ steps.pipecat-version.outputs.pipecat_commit }}`"
}
}
]

78
DOCKER_BUILD.md Normal file
View file

@ -0,0 +1,78 @@
# Docker Build Instructions
## Pipecat Submodule Integration
The Dograh project uses pipecat as a git submodule. The Docker build process automatically synchronizes the pipecat version between the submodule and the Docker image.
### How It Works
1. **Automatic Version Sync**: The Dockerfile accepts `PIPECAT_COMMIT` as a build argument
2. **CI/CD**: GitHub Actions automatically extract the submodule commit and pass it during build
3. **Local Development**: Use the provided scripts or set the environment variable
### Building Locally
#### Option 1: Using the Helper Script (Recommended)
```bash
# From the dograh directory
./scripts/docker-build-local.sh
```
This script automatically:
- Extracts the pipecat commit from the submodule
- Sets the PIPECAT_COMMIT environment variable
- Runs docker-compose build with the correct version
#### Option 2: Manual Build with docker-compose
```bash
# From the dograh directory
export PIPECAT_COMMIT=$(./scripts/get_pipecat_commit.sh)
docker-compose build
```
#### Option 3: Direct Docker Build
```bash
# From the dograh directory
PIPECAT_COMMIT=$(./scripts/get_pipecat_commit.sh)
docker build --build-arg PIPECAT_COMMIT=$PIPECAT_COMMIT -f api/Dockerfile ./api
```
### Updating Pipecat
When you update the pipecat submodule:
1. Update the submodule to the desired commit:
```bash
cd pipecat
git checkout <desired-commit>
cd ..
git add pipecat
git commit -m "Update pipecat submodule"
```
2. **No Dockerfile changes needed!** The build process automatically uses the new commit.
3. Push your changes - the CI/CD pipeline will automatically build with the correct version.
### Troubleshooting
If you encounter build errors related to PIPECAT_COMMIT:
1. Ensure the pipecat submodule is initialized:
```bash
git submodule update --init --recursive
```
2. Verify the submodule has a valid commit:
```bash
./scripts/get_pipecat_commit.sh
```
3. For local builds, ensure you're using one of the methods above that sets PIPECAT_COMMIT.
### Benefits
- ✅ No manual Dockerfile updates when pipecat is updated
- ✅ Guaranteed synchronization between submodule and Docker image
- ✅ Eliminates version mismatch errors
- ✅ Simpler workflow for developers

View file

@ -18,10 +18,15 @@ RUN pip install --user --no-cache-dir -r requirements.txt && \
# Clean up pip cache after installation
rm -rf /root/.cache/pip
# Force reinstall of pipecat on every build (cache bust)
# Accept pipecat commit SHA as build argument
ARG PIPECAT_COMMIT
RUN if [ -z "$PIPECAT_COMMIT" ]; then \
echo "ERROR: PIPECAT_COMMIT build argument is required" >&2; \
exit 1; \
fi
ARG CACHEBUST=1
RUN pip install --user 'git+https://github.com/dograh-hq/pipecat.git@f88c8a0#egg=pipecat-ai[cartesia,deepgram,openai,elevenlabs,groq,google,azure,soundfile,silero,webrtc]' && \
# Install pipecat using the commit SHA from build argument
RUN pip install --user "git+https://github.com/dograh-hq/pipecat.git@${PIPECAT_COMMIT}#egg=pipecat-ai[cartesia,deepgram,openai,elevenlabs,groq,google,azure,soundfile,silero,webrtc]" && \
# Clean up pip cache after pipecat installation
rm -rf /root/.cache/pip

View file

@ -0,0 +1,13 @@
# Docker Compose Override for Local Development
# This file automatically provides the pipecat commit SHA when building locally
# It's automatically merged with docker-compose.yaml
services:
api:
build:
context: ./api
dockerfile: Dockerfile
args:
# Dynamically get pipecat commit SHA from submodule
# This will be evaluated when docker-compose build is run
PIPECAT_COMMIT: ${PIPECAT_COMMIT}

View file

@ -2,89 +2,21 @@
#
# check_pipecat_sync.sh
#
# Verifies that the pipecat submodule commit SHA matches the one in Dockerfile.
# Used by CI/CD to ensure versions are synchronized before merging.
# Exit code 0 = versions match, 1 = mismatch or error
# DEPRECATED: This script is no longer needed as pipecat version is now
# automatically synchronized during Docker build using build arguments.
#
# The Dockerfile now accepts PIPECAT_COMMIT as a build argument, and the
# GitHub workflow automatically extracts and passes the correct commit SHA.
#
# For local development, use scripts/docker-build-local.sh or set the
# PIPECAT_COMMIT environment variable before running docker-compose build.
#
set -euo pipefail
# Colors for output (work in both terminal and CI)
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
echo "🔍 Checking pipecat version synchronization..."
# Check if pipecat submodule exists
if [ ! -d "$PROJECT_ROOT/pipecat" ]; then
echo -e "${RED}❌ ERROR: pipecat submodule not found at $PROJECT_ROOT/pipecat${NC}"
echo "Please run: git submodule update --init --recursive"
exit 1
fi
# Get the commit from the submodule (use short form - 7 chars)
cd "$PROJECT_ROOT/pipecat"
SUBMODULE_COMMIT=$(git rev-parse HEAD)
SUBMODULE_SHORT=$(git rev-parse --short=7 HEAD)
echo "📦 Submodule commit: $SUBMODULE_SHORT"
# Check if Dockerfile exists
DOCKERFILE="$PROJECT_ROOT/api/Dockerfile"
if [ ! -f "$DOCKERFILE" ]; then
echo -e "${RED}❌ ERROR: Dockerfile not found at $DOCKERFILE${NC}"
exit 1
fi
# Check if pipecat is installed in Dockerfile
if ! grep -q 'pipecat\.git@' "$DOCKERFILE"; then
echo -e "${RED}❌ ERROR: No pipecat installation found in api/Dockerfile${NC}"
echo "Expected to find a line like: RUN pip install 'git+https://github.com/dograh-hq/pipecat.git@<commit>'"
exit 1
fi
# Get the commit from the Dockerfile (extract whatever length is there)
DOCKERFILE_COMMIT=$(grep -oE 'pipecat\.git@[a-f0-9]+' "$DOCKERFILE" | cut -d'@' -f2)
# Normalize to 7 chars for comparison
DOCKERFILE_SHORT=$(echo "$DOCKERFILE_COMMIT" | cut -c1-7)
echo "🐳 Dockerfile commit: $DOCKERFILE_SHORT"
# Compare the short commits (7 chars)
if [ "$SUBMODULE_SHORT" != "$DOCKERFILE_SHORT" ]; then
echo ""
echo -e "${RED}❌ ERROR: Version mismatch detected!${NC}"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "${YELLOW}Submodule:${NC} $SUBMODULE_SHORT"
echo -e "${YELLOW}Dockerfile:${NC} $DOCKERFILE_SHORT"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo -e "${BLUE}👉 TO FIX: Update the pipecat commit in api/Dockerfile to match the submodule${NC}"
echo ""
echo "Update api/Dockerfile line with pipecat installation to use commit: $SUBMODULE_SHORT"
echo "Then commit and push the updated api/Dockerfile"
echo ""
# For GitHub Actions, output in annotation format for PR checks
if [ "${GITHUB_ACTIONS:-false}" == "true" ]; then
echo "::error file=api/Dockerfile,title=Pipecat Version Mismatch::Dockerfile has pipecat@$DOCKERFILE_SHORT but submodule is at $SUBMODULE_SHORT. Please update api/Dockerfile to use commit $SUBMODULE_SHORT"
fi
exit 1
fi
# Success!
echo "⚠️ This script is deprecated!"
echo ""
echo -e "${GREEN}✅ SUCCESS: Pipecat versions are synchronized!${NC}"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "${GREEN}Both using commit: $SUBMODULE_SHORT${NC}"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Pipecat version synchronization is now automatic:"
echo "• GitHub Actions: Automatically extracts and uses submodule commit"
echo "• Local builds: Use scripts/docker-build-local.sh"
echo ""
echo "No manual Dockerfile updates are needed anymore! 🎉"
exit 0

34
scripts/docker-build-local.sh Executable file
View file

@ -0,0 +1,34 @@
#!/usr/bin/env bash
#
# docker-build-local.sh
#
# Helper script for building Docker images locally with correct pipecat commit.
# This ensures local builds use the same pipecat version as the submodule.
#
set -euo pipefail
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo "🔨 Building Docker images with pipecat submodule..."
# Get the pipecat commit SHA
PIPECAT_COMMIT=$("$SCRIPT_DIR/get_pipecat_commit.sh")
echo -e "${BLUE}📦 Using pipecat commit: ${PIPECAT_COMMIT}${NC}"
# Export for docker-compose
export PIPECAT_COMMIT
# Run docker-compose build with the commit SHA
cd "$PROJECT_ROOT"
docker-compose build "$@"
echo -e "${GREEN}✅ Docker build completed successfully!${NC}"
echo -e "${GREEN} Pipecat commit: ${PIPECAT_COMMIT}${NC}"

24
scripts/get_pipecat_commit.sh Executable file
View file

@ -0,0 +1,24 @@
#!/usr/bin/env bash
#
# get_pipecat_commit.sh
#
# Gets the current pipecat submodule commit SHA.
# Used by Docker build process to ensure Dockerfile always uses the correct version.
#
set -euo pipefail
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
# Check if pipecat submodule exists
if [ ! -d "$PROJECT_ROOT/pipecat/.git" ]; then
echo "ERROR: pipecat submodule not initialized at $PROJECT_ROOT/pipecat" >&2
echo "Run: git submodule update --init --recursive" >&2
exit 1
fi
# Get the commit SHA from the submodule
cd "$PROJECT_ROOT/pipecat"
git rev-parse HEAD