Skip to content

Simplify Docker login and fix workflow configuration #6

Simplify Docker login and fix workflow configuration

Simplify Docker login and fix workflow configuration #6

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main, master ]
paths-ignore:
- '**/*.md'
- '.gitignore'
pull_request:
branches: [ main, master ]
env:
DOCKER_USERNAME: tuandung12092002
SEARCH_SERVER_IMAGE: tuandung12092002/semantic-search-server
DEMO_APP_IMAGE: tuandung12092002/semantic-search-demo
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Create environment files
run: |
echo "${{ secrets.OPENAI_API_KEY }}" > openai_api_key.txt
echo "${{ secrets.WEAVIATE_API_KEY }}" > weaviate_api_key.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest
- name: Install package in development mode
run: |
pip install -e .
- name: Run tests
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
WEAVIATE_API_KEY: ${{ secrets.WEAVIATE_API_KEY }}
run: |
pytest src/test_connection.py -v
build-and-push:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: tuandung12092002
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push Search Server Image
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/search_server.Dockerfile
push: true
tags: tuandung12092002/semantic-search-server:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and Push Demo App Image
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/demo_app.Dockerfile
push: true
tags: tuandung12092002/semantic-search-demo:latest
cache-from: type=gha
cache-to: type=gha,mode=max
test-deployment:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Create environment files
run: |
mkdir -p secrets
echo "${{ secrets.OPENAI_API_KEY }}" > secrets/openai_api_key.txt
echo "${{ secrets.WEAVIATE_API_KEY }}" > secrets/weaviate_api_key.txt
- name: Deploy application
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
WEAVIATE_API_KEY: ${{ secrets.WEAVIATE_API_KEY }}
run: |
docker-compose -f docker/docker-compose.full.yml up -d
- name: Wait for services to start
run: |
sleep 30
docker-compose -f docker/docker-compose.full.yml ps
- name: Test Search API
run: |
# Wait for the API to be ready
sleep 10
curl -X POST http://localhost:8000/process-text \
-H "Content-Type: application/json" \
-d '{"text": "This is a test document for CI/CD pipeline."}'
curl -X POST http://localhost:8000/ask-question \
-H "Content-Type: application/json" \
-d '{"question": "What is semantic search?", "num_search_results": 3, "num_generations": 1}'
- name: Cleanup
if: always()
run: docker-compose -f docker/docker-compose.full.yml down