arcade-mcp/.github/workflows/release-containers.yml
Sam Partee 09a0784cd5
Improve Docker Build and Deployment for Arcade Worker (#205)
This PR enhances the Docker build and deployment process for the Arcade
Worker by:

- **Modularizing Docker Builds:**
- Introduces a new `INSTALL_TOOLKITS` build argument in the `Dockerfile`
to conditionally include toolkits. this enables the creation of a
`arcadeai/worker-base` which can be used to build custom containers in a
multi-stage build. an example of this is included in the example dir.
- Adds `docker-base` Makefile target to build a lightweight base image
without toolkits.

- **Publishing to GitHub Container Registry (GHCR):**
- Adds Makefile targets `publish-ghcr` and `gh-login` for pushing images
to GHCR.
  - Supports publishing both base and full images with toolkits to GHCR.

- **Docker Compose:**
  - Add Docker compose file and setup
  - Renames the `actor` service to `worker`
- Adds an `nginx` service in `docker-compose.yml` to proxy requests to
the Arcade Engine.
  - Introduces an `nginx.conf` file for the Nginx service.

- **Streamlining Toolkit Installation:**
- Moves toolkit installation from the `start.sh` script to the Docker
build process.
- Creates a `toolkits.txt` file to manage toolkit dependencies which can
be edited easily when we want to add a new toolkit. Developers can also
use this approach as shown in the example.

- **Improving Configuration Files:**
- Updates `docker.engine.yaml` and `env.example` to align with the new
setup.


TODO:
- CI/CD needs to be adjusted so that images are pushed to ghcr on
release.
- AWS resources need to be renamed actor -> worker @EricGustin 

This can go in after the above two items are resolved.

---------

Co-authored-by: Wils Dawson <wils@arcade-ai.com>
Co-authored-by: Eric Gustin <34000337+EricGustin@users.noreply.github.com>
Co-authored-by: sdreyer <sterling@arcade-ai.com>
Co-authored-by: Sterling Dreyer <sdreyer21@gmail.com>
Co-authored-by: Nate Barbettini <nathanaelb@gmail.com>
2025-01-23 12:57:24 -08:00

274 lines
8.5 KiB
YAML

name: Release and Publish Containers
on:
push:
branches:
- main
tags:
- '*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.1.0)'
required: true
default: '0.0.1'
env:
REGISTRY: ghcr.io
jobs:
set-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set_version.outputs.version }}
steps:
- name: Wait for tests to succeed
uses: lewagon/wait-on-check-action@v1.3.4
with:
ref: ${{ github.ref }}
running-workflow-name: 'Main'
repo-token: ${{ secrets.PAT }}
wait-interval: 10
ignore-checks: "set-version"
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set version
id: set_version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF == refs/tags/* ]]; then
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "version=$(date +'%Y.%-m.%-d').dev0" >> $GITHUB_OUTPUT
fi
build-and-push:
needs: set-version
strategy:
matrix:
include:
- arch: amd64
os: ubuntu-latest
- arch: arm64
os: linux-arm64
runs-on: ${{ matrix.os }}
permissions:
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to ECR
uses: docker/login-action@v3
with:
registry: 471112909428.dkr.ecr.us-east-1.amazonaws.com
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Worker image
id: build
run: |
make docker VERSION=${{ needs.set-version.outputs.version }} ARCH=${{ matrix.arch }}
make docker-base VERSION=${{ needs.set-version.outputs.version }} ARCH=${{ matrix.arch }}
make publish-ecr VERSION=${{ needs.set-version.outputs.version }} ARCH=${{ matrix.arch }}
- name: Push GHCR
if: github.event_name != 'push' || startsWith(github.ref, 'refs/tags/')
run: |
make publish-ghcr VERSION=${{ needs.set-version.outputs.version }} ARCH=${{ matrix.arch }}
push-manifest:
runs-on: ubuntu-latest
needs: [set-version, build-and-push]
permissions:
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to ECR
uses: docker/login-action@v3
with:
registry: 471112909428.dkr.ecr.us-east-1.amazonaws.com
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Push manifest to ECR
working-directory: ./docker
run: |
make ecr-manifest VERSION=${{ needs.set-version.outputs.version }}
make ecr-manifest INSTALL_TOOLKITS=false VERSION=${{ needs.set-version.outputs.version }}
- name: Push manifest to GHCR
if: github.event_name != 'push' || startsWith(github.ref, 'refs/tags/')
working-directory: ./docker
run: |
make ghcr-manifest VERSION=${{ needs.set-version.outputs.version }}
make ghcr-manifest INSTALL_TOOLKITS=false VERSION=${{ needs.set-version.outputs.version }}
# Currently broken: workflow deploy requires all versions
# deploy:
# if: github.event_name == 'push'
# runs-on: ubuntu-latest
# needs: [set-version, push-manifest]
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - name: Set image
# run: |
# echo "image=471112909428.dkr.ecr.us-east-1.amazonaws.com/arcadeai/arcade-ai:${{ needs.set-version.outputs.version }}" >> $GITHUB_OUTPUT
# - name: Deploy to Amazon ECS
# env:
# GITHUB_TOKEN: ${{ secrets.PAT }}
# run: gh workflow -R ArcadeAI/Team run Deploy -f actor-version=${{ needs.set-version.outputs.version }}
release:
needs: [set-version, build-and-push]
runs-on: ubuntu-latest
if: github.event_name != 'push' || startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.5
- name: Make dist
run: make full-dist VERSION=${{ needs.set-version.outputs.version }}
- name: Set TAR and WHL names
run: |
export PKG=$(ls arcade/dist/ | grep tar)
set -- $PKG
echo "TAR_NAME=$1" >> $GITHUB_ENV
export PKG=$(ls arcade/dist/ | grep whl)
set -- $PKG
echo "WHL_NAME=$1" >> $GITHUB_ENV
- name: Generate release notes
id: generate_release_notes
run: |
echo "Release notes for version ${{ needs.set-version.outputs.version }}" > release_notes.md
echo "" >> release_notes.md
echo "Changes in this release:" >> release_notes.md
git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"- %s" >> release_notes.md
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.set-version.outputs.version }}
release_name: Release ${{ needs.set-version.outputs.version }}
body_path: release_notes.md
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./release_notes.md
asset_name: release_notes.md
asset_content_type: text/markdown
- name: Upload Python Tar Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./arcade/dist/${{ env.TAR_NAME }}
asset_name: ${{ env.TAR_NAME }}
asset_content_type: application/zip
- name: Upload Python Whl Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./arcade/dist/${{ env.WHL_NAME }}
asset_name: ${{ env.WHL_NAME }}
asset_content_type: application/zip
- name: Zip Full Dist
run: tar -cvf python-package-distributions.tar.gz ./dist
- name: Upload Full Dist
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: python-package-distributions.tar.gz
asset_name: python-package-distributions.tar.gz
asset_content_type: application/zip
- name: Upload the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/