Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Adds workflow to publish docker builds #377

Merged
merged 10 commits into from
Mar 19, 2023
46 changes: 46 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build And Push Docker Image

on:
push:
branches:
- main

env:
DOCKER_REGISTRY: "quay.io"
DOCKER_NAMESPACE: "unstructured-io"
IMAGE_PLATFORMS: linux/amd64
PACKAGE: "unstructured"
PIP_VERSION: "22.2.1"
BUILD_TYPE_TAG_SUFFIX: ""

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Quay.io
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_IO_ROBOT_USERNAME }}
password: ${{ secrets.QUAY_IO_ROBOT_TOKEN }}

# TODO(rniko): add a step to test the built image before pushing. Will add after https://unstructured-ai.atlassian.net/browse/CORE-745 is done
- name: Build and push Docker image
run: |
VERSION=$(grep -Po '(?<=__version__ = ")[^"]*' unstructured/__version__.py)
GIT_SHA=$(git rev-parse --short HEAD)
IMAGE_NAME=${{ env.PACKAGE }}
docker buildx build --platform=${{ env.IMAGE_PLATFORMS }} --provenance=false --push \
--build-arg PIP_VERSION=${{ env.PIP_VERSION }} \
-t ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_NAMESPACE }}/${IMAGE_NAME}:${GIT_SHA} \
-t ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_NAMESPACE }}/${IMAGE_NAME}:${VERSION} \
-t ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_NAMESPACE }}/${IMAGE_NAME}:latest .
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ ARG UNSTRUCTURED
RUN yum -y update && \
yum -y install poppler-utils xz-devel which

# Enable the EPEL repository
RUN yum install -y epel-release && yum clean all

# Install pandoc
RUN yum install -y pandoc && yum clean all

# Note(austin) Get a recent tesseract from this repo
# See https://tesseract-ocr.github.io/tessdoc/Installation.html
# PDF and images:
Expand Down Expand Up @@ -44,6 +50,7 @@ ENV PATH="/home/usr/.local/bin:${PATH}"
COPY example-docs example-docs

COPY requirements/base.txt requirements-base.txt
COPY requirements/test.txt requirements-test.txt
COPY requirements/huggingface.txt requirements-huggingface.txt
COPY requirements/dev.txt requirements-dev.txt
# PDFs and images
Expand All @@ -52,6 +59,7 @@ COPY requirements/local-inference.txt requirements-local-inference.txt

RUN python3.8 -m pip install pip==${PIP_VERSION} \
&& pip install --no-cache -r requirements-base.txt \
&& pip install --no-cache -r requirements-test.txt \
&& pip install --no-cache -r requirements-huggingface.txt \
&& pip install --no-cache -r requirements-dev.txt \
# PDFs and images
Expand Down