Skip to content

Commit

Permalink
ci: Adds workflow to publish docker builds (Unstructured-IO#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryannikolaidis authored Mar 19, 2023
1 parent c9c1b84 commit 1e39e1a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
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

0 comments on commit 1e39e1a

Please sign in to comment.