mirror of
https://github.com/onyx-dot-app/onyx.git
synced 2026-10-23 11:53:08 -05:00
1069 lines
46 KiB
YAML
1069 lines
46 KiB
YAML
name: Build and Push Docker Images on Tag
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "*"
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
env:
|
|
IS_DRY_RUN: ${{ github.event_name == 'workflow_dispatch' }}
|
|
EDGE_TAG: ${{ startsWith(github.ref_name, 'nightly-latest') }}
|
|
|
|
jobs:
|
|
# Determine which components to build based on the tag
|
|
determine-builds:
|
|
# NOTE: Github-hosted runners have about 20s faster queue times and are preferred here.
|
|
runs-on: ubuntu-slim
|
|
timeout-minutes: 90
|
|
outputs:
|
|
build-web: ${{ steps.check.outputs.build-web }}
|
|
build-web-cloud: ${{ steps.check.outputs.build-web-cloud }}
|
|
build-backend: ${{ steps.check.outputs.build-backend }}
|
|
build-model-server: ${{ steps.check.outputs.build-model-server }}
|
|
is-cloud-tag: ${{ steps.check.outputs.is-cloud-tag }}
|
|
is-stable: ${{ steps.check.outputs.is-stable }}
|
|
is-beta: ${{ steps.check.outputs.is-beta }}
|
|
is-stable-standalone: ${{ steps.check.outputs.is-stable-standalone }}
|
|
is-beta-standalone: ${{ steps.check.outputs.is-beta-standalone }}
|
|
sanitized-tag: ${{ steps.check.outputs.sanitized-tag }}
|
|
steps:
|
|
- name: Check which components to build and version info
|
|
id: check
|
|
run: |
|
|
TAG="${GITHUB_REF_NAME}"
|
|
# Sanitize tag name by replacing slashes with hyphens (for Docker tag compatibility)
|
|
SANITIZED_TAG=$(echo "$TAG" | tr '/' '-')
|
|
IS_CLOUD=false
|
|
BUILD_WEB=false
|
|
BUILD_WEB_CLOUD=false
|
|
BUILD_BACKEND=true
|
|
BUILD_MODEL_SERVER=true
|
|
IS_STABLE=false
|
|
IS_BETA=false
|
|
IS_STABLE_STANDALONE=false
|
|
IS_BETA_STANDALONE=false
|
|
|
|
if [[ "$TAG" == *cloud* ]]; then
|
|
IS_CLOUD=true
|
|
BUILD_WEB_CLOUD=true
|
|
else
|
|
BUILD_WEB=true
|
|
fi
|
|
|
|
# Version checks (for web - any stable version)
|
|
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
IS_STABLE=true
|
|
fi
|
|
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+$ ]]; then
|
|
IS_BETA=true
|
|
fi
|
|
|
|
# Version checks (for backend/model-server - stable version excluding cloud tags)
|
|
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] && [[ "$TAG" != *cloud* ]]; then
|
|
IS_STABLE_STANDALONE=true
|
|
fi
|
|
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+$ ]] && [[ "$TAG" != *cloud* ]]; then
|
|
IS_BETA_STANDALONE=true
|
|
fi
|
|
|
|
{
|
|
echo "build-web=$BUILD_WEB"
|
|
echo "build-web-cloud=$BUILD_WEB_CLOUD"
|
|
echo "build-backend=$BUILD_BACKEND"
|
|
echo "build-model-server=$BUILD_MODEL_SERVER"
|
|
echo "is-cloud-tag=$IS_CLOUD"
|
|
echo "is-stable=$IS_STABLE"
|
|
echo "is-beta=$IS_BETA"
|
|
echo "is-stable-standalone=$IS_STABLE_STANDALONE"
|
|
echo "is-beta-standalone=$IS_BETA_STANDALONE"
|
|
echo "sanitized-tag=$SANITIZED_TAG"
|
|
} >> "$GITHUB_OUTPUT"
|
|
|
|
check-version-tag:
|
|
runs-on: ubuntu-slim
|
|
timeout-minutes: 10
|
|
if: ${{ !startsWith(github.ref_name, 'nightly-latest') && github.event_name != 'workflow_dispatch' }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # ratchet:actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Setup uv
|
|
uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # ratchet:astral-sh/setup-uv@v7.1.4
|
|
with:
|
|
# NOTE: This isn't caching much and zizmor suggests this could be poisoned, so disable.
|
|
enable-cache: false
|
|
|
|
- name: Validate tag is versioned correctly
|
|
run: |
|
|
uv run --no-sync --with release-tag tag --check
|
|
|
|
notify-slack-on-tag-check-failure:
|
|
needs:
|
|
- check-version-tag
|
|
if: always() && needs.check-version-tag.result == 'failure' && github.event_name != 'workflow_dispatch'
|
|
runs-on: ubuntu-slim
|
|
timeout-minutes: 10
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # ratchet:actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Send Slack notification
|
|
uses: ./.github/actions/slack-notify
|
|
with:
|
|
webhook-url: ${{ secrets.MONITOR_DEPLOYMENTS_WEBHOOK }}
|
|
failed-jobs: "• check-version-tag"
|
|
title: "🚨 Version Tag Check Failed"
|
|
ref-name: ${{ github.ref_name }}
|
|
|
|
build-web-amd64:
|
|
needs: determine-builds
|
|
if: needs.determine-builds.outputs.build-web == 'true'
|
|
runs-on:
|
|
- runs-on
|
|
- runner=4cpu-linux-x64
|
|
- run-id=${{ github.run_id }}-web-amd64
|
|
- extras=ecr-cache
|
|
timeout-minutes: 90
|
|
outputs:
|
|
digest: ${{ steps.build.outputs.digest }}
|
|
env:
|
|
REGISTRY_IMAGE: onyxdotapp/onyx-web-server
|
|
steps:
|
|
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # ratchet:runs-on/action@v2
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # ratchet:actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # ratchet:docker/metadata-action@v5
|
|
with:
|
|
images: ${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }}
|
|
flavor: |
|
|
latest=false
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # ratchet:docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # ratchet:docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Build and push AMD64
|
|
id: build
|
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # ratchet:docker/build-push-action@v6
|
|
with:
|
|
context: ./web
|
|
file: ./web/Dockerfile
|
|
platforms: linux/amd64
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
build-args: |
|
|
ONYX_VERSION=${{ github.ref_name }}
|
|
NODE_OPTIONS=--max-old-space-size=8192
|
|
cache-from: |
|
|
type=registry,ref=${{ env.REGISTRY_IMAGE }}:latest
|
|
type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:web-cache-amd64
|
|
cache-to: |
|
|
type=inline
|
|
type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:web-cache-amd64,mode=max
|
|
outputs: type=image,name=${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
|
no-cache: ${{ vars.DOCKER_NO_CACHE == 'true' }}
|
|
|
|
build-web-arm64:
|
|
needs: determine-builds
|
|
if: needs.determine-builds.outputs.build-web == 'true'
|
|
runs-on:
|
|
- runs-on
|
|
- runner=4cpu-linux-arm64
|
|
- run-id=${{ github.run_id }}-web-arm64
|
|
- extras=ecr-cache
|
|
timeout-minutes: 90
|
|
outputs:
|
|
digest: ${{ steps.build.outputs.digest }}
|
|
env:
|
|
REGISTRY_IMAGE: onyxdotapp/onyx-web-server
|
|
steps:
|
|
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # ratchet:runs-on/action@v2
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # ratchet:actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # ratchet:docker/metadata-action@v5
|
|
with:
|
|
images: ${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }}
|
|
flavor: |
|
|
latest=false
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # ratchet:docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # ratchet:docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Build and push ARM64
|
|
id: build
|
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # ratchet:docker/build-push-action@v6
|
|
with:
|
|
context: ./web
|
|
file: ./web/Dockerfile
|
|
platforms: linux/arm64
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
build-args: |
|
|
ONYX_VERSION=${{ github.ref_name }}
|
|
NODE_OPTIONS=--max-old-space-size=8192
|
|
cache-from: |
|
|
type=registry,ref=${{ env.REGISTRY_IMAGE }}:latest
|
|
type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:web-cache-arm64
|
|
cache-to: |
|
|
type=inline
|
|
type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:web-cache-arm64,mode=max
|
|
outputs: type=image,name=${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
|
no-cache: ${{ vars.DOCKER_NO_CACHE == 'true' }}
|
|
|
|
merge-web:
|
|
needs:
|
|
- determine-builds
|
|
- build-web-amd64
|
|
- build-web-arm64
|
|
runs-on:
|
|
- runs-on
|
|
- runner=2cpu-linux-x64
|
|
- run-id=${{ github.run_id }}-merge-web
|
|
- extras=ecr-cache
|
|
timeout-minutes: 90
|
|
env:
|
|
REGISTRY_IMAGE: onyxdotapp/onyx-web-server
|
|
steps:
|
|
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # ratchet:runs-on/action@v2
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # ratchet:docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # ratchet:docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # ratchet:docker/metadata-action@v5
|
|
with:
|
|
images: ${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }}
|
|
flavor: |
|
|
latest=false
|
|
tags: |
|
|
type=raw,value=${{ github.event_name == 'workflow_dispatch' && format('web-{0}', needs.determine-builds.outputs.sanitized-tag) || github.ref_name }}
|
|
type=raw,value=${{ github.event_name != 'workflow_dispatch' && needs.determine-builds.outputs.is-stable == 'true' && 'latest' || '' }}
|
|
type=raw,value=${{ github.event_name != 'workflow_dispatch' && env.EDGE_TAG == 'true' && 'edge' || '' }}
|
|
type=raw,value=${{ github.event_name != 'workflow_dispatch' && needs.determine-builds.outputs.is-beta == 'true' && 'beta' || '' }}
|
|
|
|
- name: Create and push manifest
|
|
env:
|
|
IMAGE_REPO: ${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }}
|
|
AMD64_DIGEST: ${{ needs.build-web-amd64.outputs.digest }}
|
|
ARM64_DIGEST: ${{ needs.build-web-arm64.outputs.digest }}
|
|
META_TAGS: ${{ steps.meta.outputs.tags }}
|
|
run: |
|
|
IMAGES="${IMAGE_REPO}@${AMD64_DIGEST} ${IMAGE_REPO}@${ARM64_DIGEST}"
|
|
docker buildx imagetools create \
|
|
$(printf '%s\n' "${META_TAGS}" | xargs -I {} echo -t {}) \
|
|
$IMAGES
|
|
|
|
build-web-cloud-amd64:
|
|
needs: determine-builds
|
|
if: needs.determine-builds.outputs.build-web-cloud == 'true'
|
|
runs-on:
|
|
- runs-on
|
|
- runner=4cpu-linux-x64
|
|
- run-id=${{ github.run_id }}-web-cloud-amd64
|
|
- extras=ecr-cache
|
|
timeout-minutes: 90
|
|
outputs:
|
|
digest: ${{ steps.build.outputs.digest }}
|
|
env:
|
|
REGISTRY_IMAGE: onyxdotapp/onyx-web-server-cloud
|
|
steps:
|
|
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # ratchet:runs-on/action@v2
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # ratchet:actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # ratchet:docker/metadata-action@v5
|
|
with:
|
|
images: ${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }}
|
|
flavor: |
|
|
latest=false
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # ratchet:docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # ratchet:docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Build and push AMD64
|
|
id: build
|
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # ratchet:docker/build-push-action@v6
|
|
with:
|
|
context: ./web
|
|
file: ./web/Dockerfile
|
|
platforms: linux/amd64
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
build-args: |
|
|
ONYX_VERSION=${{ github.ref_name }}
|
|
NEXT_PUBLIC_CLOUD_ENABLED=true
|
|
NEXT_PUBLIC_POSTHOG_KEY=${{ secrets.POSTHOG_KEY }}
|
|
NEXT_PUBLIC_POSTHOG_HOST=${{ secrets.POSTHOG_HOST }}
|
|
NEXT_PUBLIC_SENTRY_DSN=${{ secrets.SENTRY_DSN }}
|
|
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=${{ secrets.STRIPE_PUBLISHABLE_KEY }}
|
|
NEXT_PUBLIC_GTM_ENABLED=true
|
|
NEXT_PUBLIC_FORGOT_PASSWORD_ENABLED=true
|
|
NEXT_PUBLIC_INCLUDE_ERROR_POPUP_SUPPORT_LINK=true
|
|
NODE_OPTIONS=--max-old-space-size=8192
|
|
cache-from: |
|
|
type=registry,ref=${{ env.REGISTRY_IMAGE }}:latest
|
|
type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:cloudweb-cache-amd64
|
|
cache-to: |
|
|
type=inline
|
|
type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:cloudweb-cache-amd64,mode=max
|
|
outputs: type=image,name=${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
|
no-cache: ${{ vars.DOCKER_NO_CACHE == 'true' }}
|
|
|
|
build-web-cloud-arm64:
|
|
needs: determine-builds
|
|
if: needs.determine-builds.outputs.build-web-cloud == 'true'
|
|
runs-on:
|
|
- runs-on
|
|
- runner=4cpu-linux-arm64
|
|
- run-id=${{ github.run_id }}-web-cloud-arm64
|
|
- extras=ecr-cache
|
|
timeout-minutes: 90
|
|
outputs:
|
|
digest: ${{ steps.build.outputs.digest }}
|
|
env:
|
|
REGISTRY_IMAGE: onyxdotapp/onyx-web-server-cloud
|
|
steps:
|
|
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # ratchet:runs-on/action@v2
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # ratchet:actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # ratchet:docker/metadata-action@v5
|
|
with:
|
|
images: ${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }}
|
|
flavor: |
|
|
latest=false
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # ratchet:docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # ratchet:docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Build and push ARM64
|
|
id: build
|
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # ratchet:docker/build-push-action@v6
|
|
with:
|
|
context: ./web
|
|
file: ./web/Dockerfile
|
|
platforms: linux/arm64
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
build-args: |
|
|
ONYX_VERSION=${{ github.ref_name }}
|
|
NEXT_PUBLIC_CLOUD_ENABLED=true
|
|
NEXT_PUBLIC_POSTHOG_KEY=${{ secrets.POSTHOG_KEY }}
|
|
NEXT_PUBLIC_POSTHOG_HOST=${{ secrets.POSTHOG_HOST }}
|
|
NEXT_PUBLIC_SENTRY_DSN=${{ secrets.SENTRY_DSN }}
|
|
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=${{ secrets.STRIPE_PUBLISHABLE_KEY }}
|
|
NEXT_PUBLIC_GTM_ENABLED=true
|
|
NEXT_PUBLIC_FORGOT_PASSWORD_ENABLED=true
|
|
NEXT_PUBLIC_INCLUDE_ERROR_POPUP_SUPPORT_LINK=true
|
|
NODE_OPTIONS=--max-old-space-size=8192
|
|
cache-from: |
|
|
type=registry,ref=${{ env.REGISTRY_IMAGE }}:latest
|
|
type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:cloudweb-cache-arm64
|
|
cache-to: |
|
|
type=inline
|
|
type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:cloudweb-cache-arm64,mode=max
|
|
outputs: type=image,name=${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
|
no-cache: ${{ vars.DOCKER_NO_CACHE == 'true' }}
|
|
|
|
merge-web-cloud:
|
|
needs:
|
|
- determine-builds
|
|
- build-web-cloud-amd64
|
|
- build-web-cloud-arm64
|
|
runs-on:
|
|
- runs-on
|
|
- runner=2cpu-linux-x64
|
|
- run-id=${{ github.run_id }}-merge-web-cloud
|
|
- extras=ecr-cache
|
|
timeout-minutes: 90
|
|
env:
|
|
REGISTRY_IMAGE: onyxdotapp/onyx-web-server-cloud
|
|
steps:
|
|
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # ratchet:runs-on/action@v2
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # ratchet:docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # ratchet:docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # ratchet:docker/metadata-action@v5
|
|
with:
|
|
images: ${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }}
|
|
flavor: |
|
|
latest=false
|
|
tags: |
|
|
type=raw,value=${{ github.event_name == 'workflow_dispatch' && format('web-cloud-{0}', needs.determine-builds.outputs.sanitized-tag) || github.ref_name }}
|
|
|
|
- name: Create and push manifest
|
|
env:
|
|
IMAGE_REPO: ${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }}
|
|
AMD64_DIGEST: ${{ needs.build-web-cloud-amd64.outputs.digest }}
|
|
ARM64_DIGEST: ${{ needs.build-web-cloud-arm64.outputs.digest }}
|
|
META_TAGS: ${{ steps.meta.outputs.tags }}
|
|
run: |
|
|
IMAGES="${IMAGE_REPO}@${AMD64_DIGEST} ${IMAGE_REPO}@${ARM64_DIGEST}"
|
|
docker buildx imagetools create \
|
|
$(printf '%s\n' "${META_TAGS}" | xargs -I {} echo -t {}) \
|
|
$IMAGES
|
|
|
|
build-backend-amd64:
|
|
needs: determine-builds
|
|
if: needs.determine-builds.outputs.build-backend == 'true'
|
|
runs-on:
|
|
- runs-on
|
|
- runner=2cpu-linux-x64
|
|
- run-id=${{ github.run_id }}-backend-amd64
|
|
- extras=ecr-cache
|
|
timeout-minutes: 90
|
|
outputs:
|
|
digest: ${{ steps.build.outputs.digest }}
|
|
env:
|
|
REGISTRY_IMAGE: ${{ contains(github.ref_name, 'cloud') && 'onyxdotapp/onyx-backend-cloud' || 'onyxdotapp/onyx-backend' }}
|
|
steps:
|
|
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # ratchet:runs-on/action@v2
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # ratchet:actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # ratchet:docker/metadata-action@v5
|
|
with:
|
|
images: ${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }}
|
|
flavor: |
|
|
latest=false
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # ratchet:docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # ratchet:docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Build and push AMD64
|
|
id: build
|
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # ratchet:docker/build-push-action@v6
|
|
with:
|
|
context: ./backend
|
|
file: ./backend/Dockerfile
|
|
platforms: linux/amd64
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
build-args: |
|
|
ONYX_VERSION=${{ github.ref_name }}
|
|
cache-from: |
|
|
type=registry,ref=${{ env.REGISTRY_IMAGE }}:latest
|
|
type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:backend-cache-amd64
|
|
cache-to: |
|
|
type=inline
|
|
type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:backend-cache-amd64,mode=max
|
|
outputs: type=image,name=${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
|
no-cache: ${{ vars.DOCKER_NO_CACHE == 'true' }}
|
|
|
|
build-backend-arm64:
|
|
needs: determine-builds
|
|
if: needs.determine-builds.outputs.build-backend == 'true'
|
|
runs-on:
|
|
- runs-on
|
|
- runner=2cpu-linux-arm64
|
|
- run-id=${{ github.run_id }}-backend-arm64
|
|
- extras=ecr-cache
|
|
timeout-minutes: 90
|
|
outputs:
|
|
digest: ${{ steps.build.outputs.digest }}
|
|
env:
|
|
REGISTRY_IMAGE: ${{ contains(github.ref_name, 'cloud') && 'onyxdotapp/onyx-backend-cloud' || 'onyxdotapp/onyx-backend' }}
|
|
steps:
|
|
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # ratchet:runs-on/action@v2
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # ratchet:actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # ratchet:docker/metadata-action@v5
|
|
with:
|
|
images: ${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }}
|
|
flavor: |
|
|
latest=false
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # ratchet:docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # ratchet:docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Build and push ARM64
|
|
id: build
|
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # ratchet:docker/build-push-action@v6
|
|
with:
|
|
context: ./backend
|
|
file: ./backend/Dockerfile
|
|
platforms: linux/arm64
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
build-args: |
|
|
ONYX_VERSION=${{ github.ref_name }}
|
|
cache-from: |
|
|
type=registry,ref=${{ env.REGISTRY_IMAGE }}:latest
|
|
type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:backend-cache-arm64
|
|
cache-to: |
|
|
type=inline
|
|
type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:backend-cache-arm64,mode=max
|
|
outputs: type=image,name=${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
|
no-cache: ${{ vars.DOCKER_NO_CACHE == 'true' }}
|
|
|
|
merge-backend:
|
|
needs:
|
|
- determine-builds
|
|
- build-backend-amd64
|
|
- build-backend-arm64
|
|
runs-on:
|
|
- runs-on
|
|
- runner=2cpu-linux-x64
|
|
- run-id=${{ github.run_id }}-merge-backend
|
|
- extras=ecr-cache
|
|
timeout-minutes: 90
|
|
env:
|
|
REGISTRY_IMAGE: ${{ contains(github.ref_name, 'cloud') && 'onyxdotapp/onyx-backend-cloud' || 'onyxdotapp/onyx-backend' }}
|
|
steps:
|
|
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # ratchet:runs-on/action@v2
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # ratchet:docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # ratchet:docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # ratchet:docker/metadata-action@v5
|
|
with:
|
|
images: ${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }}
|
|
flavor: |
|
|
latest=false
|
|
tags: |
|
|
type=raw,value=${{ github.event_name == 'workflow_dispatch' && format('backend-{0}', needs.determine-builds.outputs.sanitized-tag) || github.ref_name }}
|
|
type=raw,value=${{ github.event_name != 'workflow_dispatch' && needs.determine-builds.outputs.is-stable-standalone == 'true' && 'latest' || '' }}
|
|
type=raw,value=${{ github.event_name != 'workflow_dispatch' && env.EDGE_TAG == 'true' && 'edge' || '' }}
|
|
type=raw,value=${{ github.event_name != 'workflow_dispatch' && needs.determine-builds.outputs.is-beta-standalone == 'true' && 'beta' || '' }}
|
|
|
|
- name: Create and push manifest
|
|
env:
|
|
IMAGE_REPO: ${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }}
|
|
AMD64_DIGEST: ${{ needs.build-backend-amd64.outputs.digest }}
|
|
ARM64_DIGEST: ${{ needs.build-backend-arm64.outputs.digest }}
|
|
META_TAGS: ${{ steps.meta.outputs.tags }}
|
|
run: |
|
|
IMAGES="${IMAGE_REPO}@${AMD64_DIGEST} ${IMAGE_REPO}@${ARM64_DIGEST}"
|
|
docker buildx imagetools create \
|
|
$(printf '%s\n' "${META_TAGS}" | xargs -I {} echo -t {}) \
|
|
$IMAGES
|
|
|
|
build-model-server-amd64:
|
|
needs: determine-builds
|
|
if: needs.determine-builds.outputs.build-model-server == 'true'
|
|
runs-on:
|
|
- runs-on
|
|
- runner=2cpu-linux-x64
|
|
- run-id=${{ github.run_id }}-model-server-amd64
|
|
- volume=40gb
|
|
- extras=ecr-cache
|
|
timeout-minutes: 90
|
|
outputs:
|
|
digest: ${{ steps.build.outputs.digest }}
|
|
env:
|
|
REGISTRY_IMAGE: ${{ contains(github.ref_name, 'cloud') && 'onyxdotapp/onyx-model-server-cloud' || 'onyxdotapp/onyx-model-server' }}
|
|
steps:
|
|
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # ratchet:runs-on/action@v2
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # ratchet:actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # ratchet:docker/metadata-action@v5
|
|
with:
|
|
images: ${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }}
|
|
flavor: |
|
|
latest=false
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # ratchet:docker/setup-buildx-action@v3
|
|
with:
|
|
buildkitd-flags: ${{ vars.DOCKER_DEBUG == 'true' && '--debug' || '' }}
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # ratchet:docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Build and push AMD64
|
|
id: build
|
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # ratchet:docker/build-push-action@v6
|
|
env:
|
|
DEBUG: ${{ vars.DOCKER_DEBUG == 'true' && 1 || 0 }}
|
|
with:
|
|
context: ./backend
|
|
file: ./backend/Dockerfile.model_server
|
|
platforms: linux/amd64
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
build-args: |
|
|
ONYX_VERSION=${{ github.ref_name }}
|
|
cache-from: |
|
|
type=registry,ref=${{ env.REGISTRY_IMAGE }}:latest
|
|
type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:model-server-cache-amd64
|
|
cache-to: |
|
|
type=inline
|
|
type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:model-server-cache-amd64,mode=max
|
|
outputs: type=image,name=${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
|
no-cache: ${{ env.EDGE_TAG != 'true' && vars.MODEL_SERVER_NO_CACHE == 'true' }}
|
|
provenance: false
|
|
sbom: false
|
|
|
|
build-model-server-arm64:
|
|
needs: determine-builds
|
|
if: needs.determine-builds.outputs.build-model-server == 'true'
|
|
runs-on:
|
|
- runs-on
|
|
- runner=2cpu-linux-arm64
|
|
- run-id=${{ github.run_id }}-model-server-arm64
|
|
- volume=40gb
|
|
- extras=ecr-cache
|
|
timeout-minutes: 90
|
|
outputs:
|
|
digest: ${{ steps.build.outputs.digest }}
|
|
env:
|
|
REGISTRY_IMAGE: ${{ contains(github.ref_name, 'cloud') && 'onyxdotapp/onyx-model-server-cloud' || 'onyxdotapp/onyx-model-server' }}
|
|
steps:
|
|
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # ratchet:runs-on/action@v2
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # ratchet:actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # ratchet:docker/metadata-action@v5
|
|
with:
|
|
images: ${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }}
|
|
flavor: |
|
|
latest=false
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # ratchet:docker/setup-buildx-action@v3
|
|
with:
|
|
buildkitd-flags: ${{ vars.DOCKER_DEBUG == 'true' && '--debug' || '' }}
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # ratchet:docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Build and push ARM64
|
|
id: build
|
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # ratchet:docker/build-push-action@v6
|
|
env:
|
|
DEBUG: ${{ vars.DOCKER_DEBUG == 'true' && 1 || 0 }}
|
|
with:
|
|
context: ./backend
|
|
file: ./backend/Dockerfile.model_server
|
|
platforms: linux/arm64
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
build-args: |
|
|
ONYX_VERSION=${{ github.ref_name }}
|
|
cache-from: |
|
|
type=registry,ref=${{ env.REGISTRY_IMAGE }}:latest
|
|
type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:model-server-cache-arm64
|
|
cache-to: |
|
|
type=inline
|
|
type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:model-server-cache-arm64,mode=max
|
|
outputs: type=image,name=${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
|
no-cache: ${{ env.EDGE_TAG != 'true' && vars.MODEL_SERVER_NO_CACHE == 'true' }}
|
|
provenance: false
|
|
sbom: false
|
|
|
|
merge-model-server:
|
|
needs:
|
|
- determine-builds
|
|
- build-model-server-amd64
|
|
- build-model-server-arm64
|
|
runs-on:
|
|
- runs-on
|
|
- runner=2cpu-linux-x64
|
|
- run-id=${{ github.run_id }}-merge-model-server
|
|
- extras=ecr-cache
|
|
timeout-minutes: 90
|
|
env:
|
|
REGISTRY_IMAGE: ${{ contains(github.ref_name, 'cloud') && 'onyxdotapp/onyx-model-server-cloud' || 'onyxdotapp/onyx-model-server' }}
|
|
steps:
|
|
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # ratchet:runs-on/action@v2
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # ratchet:docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # ratchet:docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # ratchet:docker/metadata-action@v5
|
|
with:
|
|
images: ${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }}
|
|
flavor: |
|
|
latest=false
|
|
tags: |
|
|
type=raw,value=${{ github.event_name == 'workflow_dispatch' && format('model-server-{0}', needs.determine-builds.outputs.sanitized-tag) || github.ref_name }}
|
|
type=raw,value=${{ github.event_name != 'workflow_dispatch' && needs.determine-builds.outputs.is-stable-standalone == 'true' && 'latest' || '' }}
|
|
type=raw,value=${{ github.event_name != 'workflow_dispatch' && env.EDGE_TAG == 'true' && 'edge' || '' }}
|
|
type=raw,value=${{ github.event_name != 'workflow_dispatch' && needs.determine-builds.outputs.is-beta-standalone == 'true' && 'beta' || '' }}
|
|
|
|
- name: Create and push manifest
|
|
env:
|
|
IMAGE_REPO: ${{ github.event_name == 'workflow_dispatch' && env.RUNS_ON_ECR_CACHE || env.REGISTRY_IMAGE }}
|
|
AMD64_DIGEST: ${{ needs.build-model-server-amd64.outputs.digest }}
|
|
ARM64_DIGEST: ${{ needs.build-model-server-arm64.outputs.digest }}
|
|
META_TAGS: ${{ steps.meta.outputs.tags }}
|
|
run: |
|
|
IMAGES="${IMAGE_REPO}@${AMD64_DIGEST} ${IMAGE_REPO}@${ARM64_DIGEST}"
|
|
docker buildx imagetools create \
|
|
$(printf '%s\n' "${META_TAGS}" | xargs -I {} echo -t {}) \
|
|
$IMAGES
|
|
|
|
trivy-scan-web:
|
|
needs:
|
|
- determine-builds
|
|
- merge-web
|
|
if: needs.merge-web.result == 'success'
|
|
runs-on:
|
|
- runs-on
|
|
- runner=2cpu-linux-arm64
|
|
- run-id=${{ github.run_id }}-trivy-scan-web
|
|
- extras=ecr-cache
|
|
timeout-minutes: 90
|
|
env:
|
|
REGISTRY_IMAGE: onyxdotapp/onyx-web-server
|
|
steps:
|
|
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # ratchet:runs-on/action@v2
|
|
|
|
- name: Run Trivy vulnerability scanner
|
|
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # ratchet:nick-fields/retry@v3
|
|
with:
|
|
timeout_minutes: 30
|
|
max_attempts: 3
|
|
retry_wait_seconds: 10
|
|
command: |
|
|
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
|
|
SCAN_IMAGE="${{ env.RUNS_ON_ECR_CACHE }}:web-${{ needs.determine-builds.outputs.sanitized-tag }}"
|
|
else
|
|
SCAN_IMAGE="docker.io/${{ env.REGISTRY_IMAGE }}:${{ github.ref_name }}"
|
|
fi
|
|
docker run --rm -v $HOME/.cache/trivy:/root/.cache/trivy \
|
|
-e TRIVY_DB_REPOSITORY="public.ecr.aws/aquasecurity/trivy-db:2" \
|
|
-e TRIVY_JAVA_DB_REPOSITORY="public.ecr.aws/aquasecurity/trivy-java-db:1" \
|
|
-e TRIVY_USERNAME="${{ secrets.DOCKER_USERNAME }}" \
|
|
-e TRIVY_PASSWORD="${{ secrets.DOCKER_TOKEN }}" \
|
|
aquasec/trivy@sha256:a22415a38938a56c379387a8163fcb0ce38b10ace73e593475d3658d578b2436 \
|
|
image \
|
|
--skip-version-check \
|
|
--timeout 20m \
|
|
--severity CRITICAL,HIGH \
|
|
${SCAN_IMAGE}
|
|
|
|
trivy-scan-web-cloud:
|
|
needs:
|
|
- determine-builds
|
|
- merge-web-cloud
|
|
if: needs.merge-web-cloud.result == 'success'
|
|
runs-on:
|
|
- runs-on
|
|
- runner=2cpu-linux-arm64
|
|
- run-id=${{ github.run_id }}-trivy-scan-web-cloud
|
|
- extras=ecr-cache
|
|
timeout-minutes: 90
|
|
env:
|
|
REGISTRY_IMAGE: onyxdotapp/onyx-web-server-cloud
|
|
steps:
|
|
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # ratchet:runs-on/action@v2
|
|
|
|
- name: Run Trivy vulnerability scanner
|
|
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # ratchet:nick-fields/retry@v3
|
|
with:
|
|
timeout_minutes: 30
|
|
max_attempts: 3
|
|
retry_wait_seconds: 10
|
|
command: |
|
|
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
|
|
SCAN_IMAGE="${{ env.RUNS_ON_ECR_CACHE }}:web-cloud-${{ needs.determine-builds.outputs.sanitized-tag }}"
|
|
else
|
|
SCAN_IMAGE="docker.io/${{ env.REGISTRY_IMAGE }}:${{ github.ref_name }}"
|
|
fi
|
|
docker run --rm -v $HOME/.cache/trivy:/root/.cache/trivy \
|
|
-e TRIVY_DB_REPOSITORY="public.ecr.aws/aquasecurity/trivy-db:2" \
|
|
-e TRIVY_JAVA_DB_REPOSITORY="public.ecr.aws/aquasecurity/trivy-java-db:1" \
|
|
-e TRIVY_USERNAME="${{ secrets.DOCKER_USERNAME }}" \
|
|
-e TRIVY_PASSWORD="${{ secrets.DOCKER_TOKEN }}" \
|
|
aquasec/trivy@sha256:a22415a38938a56c379387a8163fcb0ce38b10ace73e593475d3658d578b2436 \
|
|
image \
|
|
--skip-version-check \
|
|
--timeout 20m \
|
|
--severity CRITICAL,HIGH \
|
|
${SCAN_IMAGE}
|
|
|
|
trivy-scan-backend:
|
|
needs:
|
|
- determine-builds
|
|
- merge-backend
|
|
if: needs.merge-backend.result == 'success'
|
|
runs-on:
|
|
- runs-on
|
|
- runner=2cpu-linux-arm64
|
|
- run-id=${{ github.run_id }}-trivy-scan-backend
|
|
- extras=ecr-cache
|
|
timeout-minutes: 90
|
|
env:
|
|
REGISTRY_IMAGE: ${{ contains(github.ref_name, 'cloud') && 'onyxdotapp/onyx-backend-cloud' || 'onyxdotapp/onyx-backend' }}
|
|
steps:
|
|
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # ratchet:runs-on/action@v2
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # ratchet:actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Run Trivy vulnerability scanner
|
|
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # ratchet:nick-fields/retry@v3
|
|
with:
|
|
timeout_minutes: 30
|
|
max_attempts: 3
|
|
retry_wait_seconds: 10
|
|
command: |
|
|
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
|
|
SCAN_IMAGE="${{ env.RUNS_ON_ECR_CACHE }}:backend-${{ needs.determine-builds.outputs.sanitized-tag }}"
|
|
else
|
|
SCAN_IMAGE="docker.io/${{ env.REGISTRY_IMAGE }}:${{ github.ref_name }}"
|
|
fi
|
|
docker run --rm -v $HOME/.cache/trivy:/root/.cache/trivy \
|
|
-v ${{ github.workspace }}/backend/.trivyignore:/tmp/.trivyignore:ro \
|
|
-e TRIVY_DB_REPOSITORY="public.ecr.aws/aquasecurity/trivy-db:2" \
|
|
-e TRIVY_JAVA_DB_REPOSITORY="public.ecr.aws/aquasecurity/trivy-java-db:1" \
|
|
-e TRIVY_USERNAME="${{ secrets.DOCKER_USERNAME }}" \
|
|
-e TRIVY_PASSWORD="${{ secrets.DOCKER_TOKEN }}" \
|
|
aquasec/trivy@sha256:a22415a38938a56c379387a8163fcb0ce38b10ace73e593475d3658d578b2436 \
|
|
image \
|
|
--skip-version-check \
|
|
--timeout 20m \
|
|
--severity CRITICAL,HIGH \
|
|
--ignorefile /tmp/.trivyignore \
|
|
${SCAN_IMAGE}
|
|
|
|
trivy-scan-model-server:
|
|
needs:
|
|
- determine-builds
|
|
- merge-model-server
|
|
if: needs.merge-model-server.result == 'success'
|
|
runs-on:
|
|
- runs-on
|
|
- runner=2cpu-linux-arm64
|
|
- run-id=${{ github.run_id }}-trivy-scan-model-server
|
|
- extras=ecr-cache
|
|
timeout-minutes: 90
|
|
env:
|
|
REGISTRY_IMAGE: ${{ contains(github.ref_name, 'cloud') && 'onyxdotapp/onyx-model-server-cloud' || 'onyxdotapp/onyx-model-server' }}
|
|
steps:
|
|
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # ratchet:runs-on/action@v2
|
|
|
|
- name: Run Trivy vulnerability scanner
|
|
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # ratchet:nick-fields/retry@v3
|
|
with:
|
|
timeout_minutes: 30
|
|
max_attempts: 3
|
|
retry_wait_seconds: 10
|
|
command: |
|
|
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
|
|
SCAN_IMAGE="${{ env.RUNS_ON_ECR_CACHE }}:model-server-${{ needs.determine-builds.outputs.sanitized-tag }}"
|
|
else
|
|
SCAN_IMAGE="docker.io/${{ env.REGISTRY_IMAGE }}:${{ github.ref_name }}"
|
|
fi
|
|
docker run --rm -v $HOME/.cache/trivy:/root/.cache/trivy \
|
|
-e TRIVY_DB_REPOSITORY="public.ecr.aws/aquasecurity/trivy-db:2" \
|
|
-e TRIVY_JAVA_DB_REPOSITORY="public.ecr.aws/aquasecurity/trivy-java-db:1" \
|
|
-e TRIVY_USERNAME="${{ secrets.DOCKER_USERNAME }}" \
|
|
-e TRIVY_PASSWORD="${{ secrets.DOCKER_TOKEN }}" \
|
|
aquasec/trivy@sha256:a22415a38938a56c379387a8163fcb0ce38b10ace73e593475d3658d578b2436 \
|
|
image \
|
|
--skip-version-check \
|
|
--timeout 20m \
|
|
--severity CRITICAL,HIGH \
|
|
${SCAN_IMAGE}
|
|
|
|
notify-slack-on-failure:
|
|
needs:
|
|
- build-web-amd64
|
|
- build-web-arm64
|
|
- merge-web
|
|
- build-web-cloud-amd64
|
|
- build-web-cloud-arm64
|
|
- merge-web-cloud
|
|
- build-backend-amd64
|
|
- build-backend-arm64
|
|
- merge-backend
|
|
- build-model-server-amd64
|
|
- build-model-server-arm64
|
|
- merge-model-server
|
|
if: always() && (needs.build-web-amd64.result == 'failure' || needs.build-web-arm64.result == 'failure' || needs.merge-web.result == 'failure' || needs.build-web-cloud-amd64.result == 'failure' || needs.build-web-cloud-arm64.result == 'failure' || needs.merge-web-cloud.result == 'failure' || needs.build-backend-amd64.result == 'failure' || needs.build-backend-arm64.result == 'failure' || needs.merge-backend.result == 'failure' || needs.build-model-server-amd64.result == 'failure' || needs.build-model-server-arm64.result == 'failure' || needs.merge-model-server.result == 'failure') && github.event_name != 'workflow_dispatch'
|
|
# NOTE: Github-hosted runners have about 20s faster queue times and are preferred here.
|
|
runs-on: ubuntu-slim
|
|
timeout-minutes: 90
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # ratchet:actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Determine failed jobs
|
|
id: failed-jobs
|
|
shell: bash
|
|
run: |
|
|
FAILED_JOBS=""
|
|
if [ "${NEEDS_BUILD_WEB_AMD64_RESULT}" == "failure" ]; then
|
|
FAILED_JOBS="${FAILED_JOBS}• build-web-amd64\\n"
|
|
fi
|
|
if [ "${NEEDS_BUILD_WEB_ARM64_RESULT}" == "failure" ]; then
|
|
FAILED_JOBS="${FAILED_JOBS}• build-web-arm64\\n"
|
|
fi
|
|
if [ "${NEEDS_MERGE_WEB_RESULT}" == "failure" ]; then
|
|
FAILED_JOBS="${FAILED_JOBS}• merge-web\\n"
|
|
fi
|
|
if [ "${NEEDS_BUILD_WEB_CLOUD_AMD64_RESULT}" == "failure" ]; then
|
|
FAILED_JOBS="${FAILED_JOBS}• build-web-cloud-amd64\\n"
|
|
fi
|
|
if [ "${NEEDS_BUILD_WEB_CLOUD_ARM64_RESULT}" == "failure" ]; then
|
|
FAILED_JOBS="${FAILED_JOBS}• build-web-cloud-arm64\\n"
|
|
fi
|
|
if [ "${NEEDS_MERGE_WEB_CLOUD_RESULT}" == "failure" ]; then
|
|
FAILED_JOBS="${FAILED_JOBS}• merge-web-cloud\\n"
|
|
fi
|
|
if [ "${NEEDS_BUILD_BACKEND_AMD64_RESULT}" == "failure" ]; then
|
|
FAILED_JOBS="${FAILED_JOBS}• build-backend-amd64\\n"
|
|
fi
|
|
if [ "${NEEDS_BUILD_BACKEND_ARM64_RESULT}" == "failure" ]; then
|
|
FAILED_JOBS="${FAILED_JOBS}• build-backend-arm64\\n"
|
|
fi
|
|
if [ "${NEEDS_MERGE_BACKEND_RESULT}" == "failure" ]; then
|
|
FAILED_JOBS="${FAILED_JOBS}• merge-backend\\n"
|
|
fi
|
|
if [ "${NEEDS_BUILD_MODEL_SERVER_AMD64_RESULT}" == "failure" ]; then
|
|
FAILED_JOBS="${FAILED_JOBS}• build-model-server-amd64\\n"
|
|
fi
|
|
if [ "${NEEDS_BUILD_MODEL_SERVER_ARM64_RESULT}" == "failure" ]; then
|
|
FAILED_JOBS="${FAILED_JOBS}• build-model-server-arm64\\n"
|
|
fi
|
|
if [ "${NEEDS_MERGE_MODEL_SERVER_RESULT}" == "failure" ]; then
|
|
FAILED_JOBS="${FAILED_JOBS}• merge-model-server\\n"
|
|
fi
|
|
# Remove trailing \n and set output
|
|
FAILED_JOBS=$(printf '%s' "$FAILED_JOBS" | sed 's/\\n$//')
|
|
echo "jobs=$FAILED_JOBS" >> "$GITHUB_OUTPUT"
|
|
env:
|
|
NEEDS_BUILD_WEB_AMD64_RESULT: ${{ needs.build-web-amd64.result }}
|
|
NEEDS_BUILD_WEB_ARM64_RESULT: ${{ needs.build-web-arm64.result }}
|
|
NEEDS_MERGE_WEB_RESULT: ${{ needs.merge-web.result }}
|
|
NEEDS_BUILD_WEB_CLOUD_AMD64_RESULT: ${{ needs.build-web-cloud-amd64.result }}
|
|
NEEDS_BUILD_WEB_CLOUD_ARM64_RESULT: ${{ needs.build-web-cloud-arm64.result }}
|
|
NEEDS_MERGE_WEB_CLOUD_RESULT: ${{ needs.merge-web-cloud.result }}
|
|
NEEDS_BUILD_BACKEND_AMD64_RESULT: ${{ needs.build-backend-amd64.result }}
|
|
NEEDS_BUILD_BACKEND_ARM64_RESULT: ${{ needs.build-backend-arm64.result }}
|
|
NEEDS_MERGE_BACKEND_RESULT: ${{ needs.merge-backend.result }}
|
|
NEEDS_BUILD_MODEL_SERVER_AMD64_RESULT: ${{ needs.build-model-server-amd64.result }}
|
|
NEEDS_BUILD_MODEL_SERVER_ARM64_RESULT: ${{ needs.build-model-server-arm64.result }}
|
|
NEEDS_MERGE_MODEL_SERVER_RESULT: ${{ needs.merge-model-server.result }}
|
|
|
|
- name: Send Slack notification
|
|
uses: ./.github/actions/slack-notify
|
|
with:
|
|
webhook-url: ${{ secrets.MONITOR_DEPLOYMENTS_WEBHOOK }}
|
|
failed-jobs: ${{ steps.failed-jobs.outputs.jobs }}
|
|
title: "🚨 Deployment Workflow Failed"
|
|
ref-name: ${{ github.ref_name }}
|