Build + Publish Docker image #11
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Docker Image | |
| on: | |
| pull_request | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Free up disk space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /usr/local/lib/android | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /opt/hostedtoolcache/CodeQL | |
| sudo docker image prune --all --force | |
| sudo docker builder prune -a --force | |
| df -h | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/ribera-ai/morphik-core | |
| tags: | | |
| type=ref,event=pr | |
| type=sha,prefix=pr-{{branch}}- | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./dockerfile | |
| push: false | |
| load: true | |
| tags: | | |
| ${{ steps.meta.outputs.tags }} | |
| morphik-core:test | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| # Remove cache-to for PR builds to save disk space | |
| - name: Test Docker container | |
| run: | | |
| # Use the local test tag instead of the registry tag | |
| IMAGE_TAG="morphik-core:test" | |
| echo "Testing image: $IMAGE_TAG" | |
| # Create a minimal config file for testing | |
| cat > morphik.toml.test << 'EOF' | |
| [api] | |
| host = "0.0.0.0" | |
| port = 8000 | |
| reload = false | |
| [auth] | |
| jwt_algorithm = "HS256" | |
| dev_mode = true | |
| dev_entity_id = "dev_user" | |
| dev_entity_type = "developer" | |
| dev_permissions = ["read", "write", "admin"] | |
| [completion] | |
| provider = "ollama" | |
| model_name = "llama2" | |
| base_url = "http://localhost:11434" | |
| [database] | |
| provider = "postgres" | |
| [embedding] | |
| provider = "ollama" | |
| model_name = "nomic-embed-text" | |
| dimensions = 768 | |
| similarity_metric = "cosine" | |
| base_url = "http://localhost:11434" | |
| [parser] | |
| chunk_size = 1000 | |
| chunk_overlap = 200 | |
| use_unstructured_api = false | |
| [reranker] | |
| use_reranker = false | |
| [storage] | |
| provider = "local" | |
| storage_path = "/app/storage" | |
| [vector_store] | |
| provider = "pgvector" | |
| EOF | |
| # Start container in detached mode with config mounted | |
| CONTAINER_ID=$(docker run -d -p 8000:8000 \ | |
| -e POSTGRES_URI="" \ | |
| -v "$(pwd)/morphik.toml.test:/app/morphik.toml" \ | |
| "$IMAGE_TAG") | |
| echo "Started container: $CONTAINER_ID" | |
| # Wait for server to be ready with 60 second timeout | |
| timeout=60 | |
| interval=2 | |
| elapsed=0 | |
| echo "Waiting for server to be ready..." | |
| while [ $elapsed -lt $timeout ]; do | |
| if curl -f -s http://localhost:8000/ping > /dev/null 2>&1; then | |
| echo "✅ Server is responding to /ping endpoint" | |
| break | |
| fi | |
| echo "⏳ Waiting for server... (${elapsed}s/${timeout}s)" | |
| sleep $interval | |
| elapsed=$((elapsed + interval)) | |
| done | |
| # Check if we timed out | |
| if [ $elapsed -ge $timeout ]; then | |
| echo "❌ Server failed to respond within ${timeout} seconds" | |
| echo "Container logs:" | |
| docker logs "$CONTAINER_ID" | |
| docker stop "$CONTAINER_ID" | |
| docker rm "$CONTAINER_ID" | |
| exit 1 | |
| fi | |
| # Verify the response is actually 200 | |
| HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/ping) | |
| if [ "$HTTP_CODE" = "200" ]; then | |
| echo "✅ Health check passed - /ping returned HTTP $HTTP_CODE" | |
| else | |
| echo "❌ Health check failed - /ping returned HTTP $HTTP_CODE" | |
| docker logs "$CONTAINER_ID" | |
| docker stop "$CONTAINER_ID" | |
| docker rm "$CONTAINER_ID" | |
| exit 1 | |
| fi | |
| # Clean up | |
| echo "🧹 Cleaning up container" | |
| docker stop "$CONTAINER_ID" | |
| docker rm "$CONTAINER_ID" | |
| echo "✅ Test completed successfully" |