resolve conflicts #101
This file contains 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: CI | |
on: | |
push: | |
branches: | |
- "*" | |
paths-ignore: | |
- 'frontend/**' | |
- '.github/workflows/ci.yml' | |
- 'Changelog.md' | |
- 'docker/**' | |
- 'docker-compose.yml' | |
- docs/** | |
- '.dockerignore' | |
- 'README.md' | |
pull_request: | |
types: [opened, synchronize, reopened] | |
paths-ignore: | |
- 'frontend/**' | |
- '.github/workflows/ci.yml' | |
- 'Changelog.md' | |
- 'docker/**' | |
- 'docker-compose.yml' | |
- docs/** | |
- '.dockerignore' | |
- 'README.md' | |
jobs: | |
############################################################### | |
## Test Backend use Cache | |
############################################################### | |
test: | |
runs-on: ubuntu-latest | |
env: | |
APP_ENV: development | |
APP_SECRET: this-is-a-test-secret | |
AZURE_OPENAI_KEY: ${{ secrets.AZURE_OPENAI_KEY }} | |
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }} | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
BUCKET: pe-oss-bucket | |
S3_REGION: us-east-1 | |
ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }} | |
ACCESS_SECRET_KEY: ${{ secrets.ACCESS_SECRET_KEY }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Cache Python dependencies | |
id: cache-python | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/backend/requirements.txt', '**/backend/requirements-dev.txt', '**/backend/constraints.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
working-directory: ./backend | |
run: | | |
pip install --upgrade pip | |
pip install uv | |
uv pip install -v --system --no-cache-dir \ | |
-c constraints.txt \ | |
-r requirements.txt \ | |
-r requirements-dev.txt | |
- name: Save Python dependencies cache | |
if: steps.cache-python.outputs.cache-hit != 'true' | |
id: save-cache-python | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/backend/requirements.txt', '**/backend/requirements-dev.txt', '**/backend/constraints.txt') }} | |
- name: Run tests | |
working-directory: ./backend | |
env: | |
PYTHONPATH: ./src:. | |
run: | | |
# Create the database directory | |
mkdir -p data | |
# Run your tests | |
pytest -rs | |
############################################################### | |
## Build Docker Image | |
############################################################### | |
build: | |
runs-on: ubuntu-latest | |
needs: test | |
if: github.ref == 'refs/heads/development' | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ env.DOCKER_USERNAME }} | |
password: ${{ env.DOCKER_PASSWORD }} | |
- name: Build and push Docker image | |
working-directory: ./backend | |
run: | | |
COMMIT_SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) | |
DOCKER_IMAGE=docker.io/promptengineers/llm-server:${COMMIT_SHORT_SHA} | |
echo "Building image: $DOCKER_IMAGE" | |
# docker buildx build --platform linux/amd64,linux/arm64 --push -t $DOCKER_IMAGE . | |
docker build --squash --push -t $DOCKER_IMAGE . | |
############################################################### | |
## Deploy to Cloud Run | |
############################################################### | |
deploy: | |
runs-on: ubuntu-latest | |
needs: [test, build] | |
if: github.ref == 'refs/heads/development' | |
env: | |
APP_ENV: development | |
APP_SECRET: ${{ secrets.APP_SECRET }} | |
APP_ADMIN_EMAIL: admin@example.com | |
APP_ADMIN_PASS: test1234 | |
APP_WORKERS: 1 | |
DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} | |
PINECONE_ENV: ${{ secrets.PINECONE_ENV }} | |
PINECONE_INDEX: ${{ secrets.PINECONE_INDEX }} | |
REDIS_URL: ${{ secrets.REDIS_URL }} | |
POSTGRES_URL: ${{ secrets.POSTGRES_URL }} | |
DOCKER_USERNAME: promptengineers | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
GCP_PROJECT: ${{ secrets.GCP_PROJECT }} | |
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} | |
AZURE_OPENAI_KEY: ${{ secrets.AZURE_OPENAI_KEY }} | |
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }} | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }} | |
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
# OLLAMA_BASE_URL: ${{ secrets.OLLAMA_BASE_URL }} | |
# MINIO_HOST: ${{ secrets.MINIO_HOST }} | |
BUCKET: ${{ secrets.BUCKET }} | |
S3_REGION: ${{ secrets.S3_REGION }} | |
ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }} | |
ACCESS_SECRET_KEY: ${{ secrets.ACCESS_SECRET_KEY }} | |
SEARX_SEARCH_HOST_URL: ${{ secrets.SEARX_SEARCH_HOST_URL }} | |
steps: | |
- name: Authenticate to Google Cloud | |
id: 'auth' | |
uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ env.GCP_SA_KEY }} | |
- name: Setup Google Cloud SDK | |
uses: google-github-actions/setup-gcloud@v2 | |
with: | |
version: 'latest' | |
- name: Deploy to Cloud Run | |
run: | | |
COMMIT_SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) | |
DOCKER_IMAGE=docker.io/promptengineers/llm-server:${COMMIT_SHORT_SHA} | |
gcloud config set project ${{ env.GCP_PROJECT }} | |
echo "Deploying $DOCKER_IMAGE to Cloud Run Server" | |
declare -a ENV_VARS=( | |
## App | |
"APP_ENV=$APP_ENV" | |
"APP_VERSION=$COMMIT_SHORT_SHA" | |
"APP_SECRET=$APP_SECRET" | |
"APP_ADMIN_EMAIL=$APP_ADMIN_EMAIL" | |
"APP_ADMIN_PASS=$APP_ADMIN_PASS" | |
"APP_WORKERS=$APP_WORKERS" | |
## Database | |
"DATABASE_URL=$DATABASE_URL" | |
"PINECONE_API_KEY=$PINECONE_API_KEY" | |
"PINECONE_ENV=$PINECONE_ENV" | |
"PINECONE_INDEX=$PINECONE_INDEX" | |
"REDIS_URL=$REDIS_URL" | |
"POSTGRES_URL=$POSTGRES_URL" | |
## LLM | |
"OPENAI_API_KEY=$OPENAI_API_KEY" | |
"GROQ_API_KEY=$GROQ_API_KEY" | |
"ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY" | |
# "OLLAMA_BASE_URL=$OLLAMA_BASE_URL" # Commented out if not using Ollama (Requires GPU server) | |
## Tools | |
"SEARX_SEARCH_HOST_URL=$SEARX_SEARCH_HOST_URL" | |
## Storage | |
# "MINIO_HOST=$MINIO_HOST" # Commented out if not using Minio (Requires Minio server) | |
"BUCKET=$BUCKET" | |
"S3_REGION=$S3_REGION" | |
"ACCESS_KEY_ID=$ACCESS_KEY_ID" | |
"ACCESS_SECRET_KEY=$ACCESS_SECRET_KEY" | |
) | |
# Join array elements into a comma-separated string | |
VARS=$(IFS=,; echo "${ENV_VARS[*]}") | |
# Deploy | |
gcloud run deploy llm-server \ | |
--image docker.io/promptengineers/llm-server:${COMMIT_SHORT_SHA} \ | |
--platform managed \ | |
--region us-central1 \ | |
--allow-unauthenticated \ | |
--set-env-vars $VARS |