Simplify dependencies & split CPU/GPU backend Dockerfiles #37
Workflow file for this run
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
on: | |
push: | |
branches: | |
- main | |
- staging | |
- expt | |
pull_request: | |
branches: | |
- main | |
- staging | |
# Trigger the workflow on release activity | |
release: | |
# Only use the types keyword to narrow down the activity types that will trigger your workflow. | |
types: | |
- published | |
- edited | |
- created | |
# Certain actions will only run when this is the main repo. | |
env: | |
MAIN_REPO: classtranscribe/latextranscribe | |
DOCKERHUB_ORG: classtranscribe | |
jobs: | |
build-server: | |
name: Build server Docker image | |
runs-on: ubuntu-latest | |
env: | |
FOLDER: ./server | |
IMAGE: latextranscribe-server | |
DOCKERFILE: Dockerfile.cpu | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install the latest version of uv | |
uses: astral-sh/setup-uv@v5 | |
- name: Download model weights using huggingface_hub | |
run: | | |
cd server | |
HF_HUB_ENABLE_HF_TRANSFER=1 uv run download_models.py | |
du -hs models/ | |
# calculate some variables that are used later | |
- name: github branch | |
run: | | |
if [ "${{ github.event.release.target_commitish }}" != "" ]; then | |
BRANCH="${{ github.event.release.target_commitish }}" | |
else | |
BRANCH=${GITHUB_REF##*/} | |
fi | |
echo "GITHUB_BRANCH=${BRANCH}" >> $GITHUB_ENV | |
# Commit was for main/release branch, build a new version | |
if [ "$BRANCH" == "master" -o "$BRANCH" == "main" ]; then | |
version="$(cat gui/package.json | jq -r .version)" | |
echo "VERSION=$(version)" >> $GITHUB_ENV | |
tags="latest" | |
oldversion="" | |
while [ "${oldversion}" != "${version}" ]; do | |
oldversion="${version}" | |
tags="${tags},${version}" | |
version=${version%.*} | |
done | |
echo "TAGS=${tags}" >> $GITHUB_ENV | |
else | |
echo "VERSION=$BRANCH" >> $GITHUB_ENV | |
echo "TAGS=$BRANCH" >> $GITHUB_ENV | |
fi | |
# build the docker image, this will always run to make sure | |
# the Dockerfile still works. | |
- name: Build Docker image | |
uses: elgohr/Publish-Docker-Github-Action@2.22 | |
env: | |
BRANCH: ${{ env.GITHUB_BRANCH }} | |
VERSION: ${{ env.VERSION }} | |
BUILDNUMBER: ${{ github.run_number }} | |
GITSHA1: ${{ github.sha }} | |
with: | |
registry: docker.pkg.github.com | |
name: ${{ github.repository_owner }}/${{ github.event.repository.name }}/${{ env.IMAGE }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
workdir: ${{ env.FOLDER }} | |
tags: "${{ env.TAGS }}" | |
dockerfile: ${{ env.DOCKERFILE }} | |
buildargs: BRANCH,VERSION,BUILDNUMBER,GITSHA1 | |
no_push: true | |
# TODO: need publish permissions for ghcr.io | |
# this will publish to github container registry | |
#- name: Publish to GitHub | |
# if: github.event_name != 'pull_request' && github.repository == env.MAIN_REPO | |
# uses: elgohr/Publish-Docker-Github-Action@2.22 | |
# env: | |
# BRANCH: ${{ env.GITHUB_BRANCH }} | |
# VERSION: ${{ env.VERSION }} | |
# BUILDNUMBER: ${{ github.run_number }} | |
# GITSHA1: ${{ github.sha }} | |
# with: | |
# registry: ghcr.io | |
# name: ${{ github.repository_owner }}/${{ matrix.IMAGE }} | |
# username: ${{ secrets.GHCR_USERNAME }} | |
# password: ${{ secrets.GHCR_PASSWORD }} | |
# context: ${{ matrix.FOLDER }} | |
# tags: "${{ env.TAGS }}" | |
# buildargs: BRANCH,VERSION,BUILDNUMBER,GITSHA1 | |
# this will publish to dockerhub | |
- name: Publish to Docker Hub | |
if: github.event_name != 'pull_request' && github.repository == env.MAIN_REPO | |
uses: elgohr/Publish-Docker-Github-Action@2.22 | |
env: | |
BRANCH: ${{ env.GITHUB_BRANCH }} | |
VERSION: ${{ env.VERSION }} | |
BUILDNUMBER: ${{ github.run_number }} | |
GITSHA1: ${{ github.sha }} | |
with: | |
name: ${{ env.DOCKERHUB_ORG }}/${{ env.IMAGE }} | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
workdir: ${{ env.FOLDER }} | |
tags: "${{ env.TAGS }}" | |
dockerfile: ${{ env.DOCKERFILE }} | |
buildargs: BRANCH,VERSION,BUILDNUMBER,GITSHA1 | |
build-frontend: | |
name: Build frontend Docker image | |
runs-on: ubuntu-latest | |
env: | |
FOLDER: ./frontend | |
IMAGE: latextranscribe-frontend | |
DOCKERFILE: Dockerfile | |
steps: | |
- uses: actions/checkout@v4 | |
# calculate some variables that are used later | |
- name: github branch | |
run: | | |
if [ "${{ github.event.release.target_commitish }}" != "" ]; then | |
BRANCH="${{ github.event.release.target_commitish }}" | |
else | |
BRANCH=${GITHUB_REF##*/} | |
fi | |
echo "GITHUB_BRANCH=${BRANCH}" >> $GITHUB_ENV | |
# Commit was for main/release branch, build a new version | |
if [ "$BRANCH" == "master" -o "$BRANCH" == "main" ]; then | |
version="$(cat gui/package.json | jq -r .version)" | |
echo "VERSION=$(version)" >> $GITHUB_ENV | |
tags="latest" | |
oldversion="" | |
while [ "${oldversion}" != "${version}" ]; do | |
oldversion="${version}" | |
tags="${tags},${version}" | |
version=${version%.*} | |
done | |
echo "TAGS=${tags}" >> $GITHUB_ENV | |
else | |
echo "VERSION=$BRANCH" >> $GITHUB_ENV | |
echo "TAGS=$BRANCH" >> $GITHUB_ENV | |
fi | |
# build the docker image, this will always run to make sure | |
# the Dockerfile still works. | |
- name: Build Docker image | |
uses: elgohr/Publish-Docker-Github-Action@2.22 | |
env: | |
BRANCH: ${{ env.GITHUB_BRANCH }} | |
VERSION: ${{ env.VERSION }} | |
BUILDNUMBER: ${{ github.run_number }} | |
GITSHA1: ${{ github.sha }} | |
with: | |
registry: docker.pkg.github.com | |
name: ${{ github.repository_owner }}/${{ github.event.repository.name }}/${{ env.IMAGE }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
workdir: ${{ env.FOLDER }} | |
tags: "${{ env.TAGS }}" | |
dockerfile: ${{ env.DOCKERFILE }} | |
buildargs: BRANCH,VERSION,BUILDNUMBER,GITSHA1 | |
no_push: true | |
# TODO: need publish permissions for ghcr.io | |
# this will publish to github container registry | |
#- name: Publish to GitHub | |
# if: github.event_name != 'pull_request' && github.repository == env.MAIN_REPO | |
# uses: elgohr/Publish-Docker-Github-Action@2.22 | |
# env: | |
# BRANCH: ${{ env.GITHUB_BRANCH }} | |
# VERSION: ${{ env.VERSION }} | |
# BUILDNUMBER: ${{ github.run_number }} | |
# GITSHA1: ${{ github.sha }} | |
# with: | |
# registry: ghcr.io | |
# name: ${{ github.repository_owner }}/${{ matrix.IMAGE }} | |
# username: ${{ secrets.GHCR_USERNAME }} | |
# password: ${{ secrets.GHCR_PASSWORD }} | |
# context: ${{ matrix.FOLDER }} | |
# tags: "${{ env.TAGS }}" | |
# buildargs: BRANCH,VERSION,BUILDNUMBER,GITSHA1 | |
# this will publish to dockerhub | |
- name: Publish to Docker Hub | |
if: github.event_name != 'pull_request' && github.repository == env.MAIN_REPO | |
uses: elgohr/Publish-Docker-Github-Action@2.22 | |
env: | |
BRANCH: ${{ env.GITHUB_BRANCH }} | |
VERSION: ${{ env.VERSION }} | |
BUILDNUMBER: ${{ github.run_number }} | |
GITSHA1: ${{ github.sha }} | |
with: | |
name: ${{ env.DOCKERHUB_ORG }}/${{ env.IMAGE }} | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
workdir: ${{ env.FOLDER }} | |
tags: "${{ env.TAGS }}" | |
dockerfile: ${{ env.DOCKERFILE }} | |
buildargs: BRANCH,VERSION,BUILDNUMBER,GITSHA1 |