UI fixes (#4709) #1026
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 and Push Backend Image on Tag | |
on: | |
push: | |
tags: | |
- "*" | |
env: | |
REGISTRY_IMAGE: ${{ contains(github.ref_name, 'cloud') && 'onyxdotapp/onyx-backend-cloud' || 'onyxdotapp/onyx-backend' }} | |
DEPLOYMENT: ${{ contains(github.ref_name, 'cloud') && 'cloud' || 'standalone' }} | |
# don't tag cloud images with "latest" | |
LATEST_TAG: ${{ contains(github.ref_name, 'latest') && !contains(github.ref_name, 'cloud') }} | |
jobs: | |
build-and-push: | |
# TODO: investigate a matrix build like the web container | |
# See https://runs-on.com/runners/linux/ | |
runs-on: | |
- runs-on | |
- runner=${{ matrix.platform == 'linux/amd64' && '8cpu-linux-x64' || '8cpu-linux-arm64' }} | |
- run-id=${{ github.run_id }} | |
- tag=platform-${{ matrix.platform }} | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- linux/amd64 | |
- linux/arm64 | |
steps: | |
- name: Prepare | |
run: | | |
platform=${{ matrix.platform }} | |
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY_IMAGE }} | |
flavor: | | |
latest=false | |
tags: | | |
type=raw,value=${{ github.ref_name }} | |
type=raw,value=${{ env.LATEST_TAG == 'true' && 'latest' || '' }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Install build-essential | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y build-essential | |
- name: Backend Image Docker Build and Push | |
id: build | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./backend | |
file: ./backend/Dockerfile | |
platforms: ${{ matrix.platform }} | |
push: true | |
build-args: | | |
ONYX_VERSION=${{ github.ref_name }} | |
labels: ${{ steps.meta.outputs.labels }} | |
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true | |
cache-from: type=s3,prefix=cache/${{ github.repository }}/${{ env.DEPLOYMENT }}/backend-${{ env.PLATFORM_PAIR }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }} | |
cache-to: type=s3,prefix=cache/${{ github.repository }}/${{ env.DEPLOYMENT }}/backend-${{ env.PLATFORM_PAIR }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }},mode=max | |
- name: Export digest | |
run: | | |
mkdir -p /tmp/digests | |
digest="${{ steps.build.outputs.digest }}" | |
touch "/tmp/digests/${digest#sha256:}" | |
- name: Upload digest | |
uses: actions/upload-artifact@v4 | |
with: | |
name: backend-digests-${{ env.PLATFORM_PAIR }}-${{ github.run_id }} | |
path: /tmp/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
merge: | |
runs-on: ubuntu-latest | |
needs: | |
- build-and-push | |
steps: | |
# Needed for trivyignore | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download digests | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp/digests | |
pattern: backend-digests-*-${{ github.run_id }} | |
merge-multiple: true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY_IMAGE }} | |
flavor: | | |
latest=false | |
tags: | | |
type=raw,value=${{ github.ref_name }} | |
type=raw,value=${{ env.LATEST_TAG == 'true' && 'latest' || '' }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Create manifest list and push | |
working-directory: /tmp/digests | |
run: | | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} | |
# trivy has their own rate limiting issues causing this action to flake | |
# we worked around it by hardcoding to different db repos in env | |
# can re-enable when they figure it out | |
# https://github.com/aquasecurity/trivy/discussions/7538 | |
# https://github.com/aquasecurity/trivy-action/issues/389 | |
- name: Run Trivy vulnerability scanner | |
uses: aquasecurity/trivy-action@master | |
env: | |
TRIVY_DB_REPOSITORY: "public.ecr.aws/aquasecurity/trivy-db:2" | |
TRIVY_JAVA_DB_REPOSITORY: "public.ecr.aws/aquasecurity/trivy-java-db:1" | |
TRIVY_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
TRIVY_PASSWORD: ${{ secrets.DOCKER_TOKEN }} | |
with: | |
# To run locally: trivy image --severity HIGH,CRITICAL onyxdotapp/onyx-backend | |
image-ref: docker.io/${{ env.REGISTRY_IMAGE }}:${{ github.ref_name }} | |
severity: "CRITICAL,HIGH" | |
trivyignores: ./backend/.trivyignore |