Update architecture diagram and refactor the main workflow into multi… #13
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 and Push Docker Images | |
on: | |
push: | |
branches: [ main, master ] | |
paths-ignore: | |
- '**.md' | |
- '.gitignore' | |
pull_request: | |
branches: [ main, master ] | |
paths-ignore: | |
- '**.md' | |
- '.gitignore' | |
workflow_dispatch: | |
env: | |
DOCKER_USERNAME: tuandung12092002 | |
SEARCH_SERVER_IMAGE: tuandung12092002/semantic-search-server | |
DEMO_APP_IMAGE: tuandung12092002/semantic-search-demo | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up .env file | |
run: | | |
# Create .env file directly since .env.example might not exist | |
cat << EOF > .env | |
OPENAI_API_KEY=dummy-key-for-ci | |
WEAVIATE_URL=http://weaviate:8080 | |
API_HOST=0.0.0.0 | |
API_PORT=8000 | |
DEMO_PORT=8501 | |
LOG_LEVEL=INFO | |
LOAD_SAMPLE_DATA=true | |
EOF | |
echo ".env file created successfully" | |
- name: Create secret files for build context | |
run: | | |
# Create placeholder files for secrets | |
echo "placeholder" > openai_api_key.txt | |
echo "placeholder" > weaviate_api_key.txt | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ env.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Search Server | |
id: meta-search | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.SEARCH_SERVER_IMAGE }} | |
tags: | | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') || github.ref == format('refs/heads/{0}', 'master') }} | |
type=ref,event=branch | |
type=sha,format=short | |
- name: Build and push Search Server | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./docker/search_server.Dockerfile | |
push: true | |
tags: ${{ steps.meta-search.outputs.tags }} | |
labels: ${{ steps.meta-search.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Extract metadata (tags, labels) for Demo App | |
id: meta-demo | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.DEMO_APP_IMAGE }} | |
tags: | | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') || github.ref == format('refs/heads/{0}', 'master') }} | |
type=ref,event=branch | |
type=sha,format=short | |
- name: Build and push Demo App | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./docker/demo_app.Dockerfile | |
push: true | |
tags: ${{ steps.meta-demo.outputs.tags }} | |
labels: ${{ steps.meta-demo.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |