Skip to content

Commit

Permalink
Update docker-image-tag-version.yml
Browse files Browse the repository at this point in the history
Fix matrix version
  • Loading branch information
xiaoyao9184 committed Nov 28, 2024
1 parent d646d56 commit 7766a54
Show file tree
Hide file tree
Showing 5 changed files with 266 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
texify/.git/
texify/.github/
texify/benchmark/
texify/data/
texify/docs/
texify/scripts/
texify/signatures/
texify/static/
texify/.gitignore
texify/poetry.lock
# Ignore generated files
**/*.pyc
100 changes: 100 additions & 0 deletions .github/workflows/docker-image-tag-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@

name: Docker Image Build/Publish tag with commit

on:
push:
branches:
- 'master'
paths:
- texify
- docker/build@source/dockerfile
- .github/workflows/docker-image-tag-commit.yml
workflow_dispatch:
inputs:
commit_id:
description: texify commit id(like 'master' '4f2acb61')
required: true
default: master
schedule:
- cron: '0 0 1 */3 *'

jobs:
build-and-push-docker-image:
name: Build Docker image and push to repositories
runs-on: ubuntu-latest
permissions:
packages: write

strategy:
matrix:
BRANCH_CHECKOUT:
- ${{ github.event.inputs.commit_id || 'master' }}
platforms:
- linux/amd64

steps:
# Fix github action 'No space left on device'
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true

- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true

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

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

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout commit
run: |
cd texify
git checkout ${{ matrix.BRANCH_CHECKOUT }}
- name: Set env git short head
working-directory: ./texify
run: echo "COMMIT_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Meta data image
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/texify
ghcr.io/${{ github.repository_owner }}/texify
tags: |
type=raw,value=${{ matrix.BRANCH_CHECKOUT }}
type=raw,value=${{ env.COMMIT_SHORT }}
flavor: |
latest=false
- name: Build push image
id: build
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/build@source/dockerfile
platforms: ${{ matrix.platforms }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Print image digest
run: echo ${{ steps.build.outputs.digest }}
97 changes: 97 additions & 0 deletions .github/workflows/docker-image-tag-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@

name: Docker Image Build/Publish tag with version

on:
push:
branches:
- 'master'
paths:
- docker/build@pypi/dockerfile
- .github/workflows/docker-image-tag-version.yml
workflow_dispatch:
inputs:
texify_version:
description: texify version of pypi
required: true
default: 0.2.1
streamlit_version:
description: streamlit version of pypi
required: true
default: 1.37.1

jobs:
build-and-push-docker-image:
name: Build Docker image and push to repositories
runs-on: ubuntu-latest
permissions:
packages: write

strategy:
matrix:
TEXIFY_VERSION:
- ${{ github.event.inputs.texify_version || '0.2.1' }}
STREAMLIT_VERSION:
- ${{ github.event.inputs.streamlit_version || '1.37.1' }}
platform:
- linux/amd64

steps:
# Fix github action 'No space left on device'
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true

- name: Checkout code
uses: actions/checkout@v4
with:
submodules: false

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

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

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Meta data image
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/texify
ghcr.io/${{ github.repository_owner }}/texify
tags: |
type=raw,value=${{ matrix.TEXIFY_VERSION }}
type=raw,value=lastet
flavor: |
latest=false
- name: Build push image
id: build
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/build@pypi/dockerfile
build-args: |
TEXIFY_VERSION=${{ matrix.TEXIFY_VERSION }}
STREAMLIT_VERSION=${{ matrix.STREAMLIT_VERSION }}
platforms: ${{ matrix.platform }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Print image digest
run: echo ${{ steps.build.outputs.digest }}
29 changes: 29 additions & 0 deletions docker/build@pypi/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ARG TEXIFY_VERSION=0.2.1
ARG STREAMLIT_VERSION=1.37.1


FROM pytorch/pytorch:2.4.1-cuda12.4-cudnn9-runtime

ARG TEXIFY_VERSION
ARG STREAMLIT_VERSION

WORKDIR /app

RUN apt-get update && apt-get install -y \
python3-pip \
libgl1-mesa-glx \
libsm6 \
libxext6 \
libglib2.0-0 \
libxrender-dev \
&& rm -rf /var/lib/apt/lists/*

RUN pip3 install --upgrade pip

RUN pip3 install --no-cache-dir texify==${TEXIFY_VERSION} streamlit==${STREAMLIT_VERSION} streamlit_drawable_canvas

EXPOSE 8501

VOLUME /root/.cache

CMD ["texify_gui"]
28 changes: 28 additions & 0 deletions docker/build@source/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@


FROM pytorch/pytorch:2.4.1-cuda12.4-cudnn9-runtime

WORKDIR /app

RUN apt-get update && apt-get install -y \
python3-pip \
libgl1-mesa-glx \
libsm6 \
libxext6 \
libglib2.0-0 \
libxrender-dev \
&& rm -rf /var/lib/apt/lists/*

RUN pip3 install --upgrade pip

COPY ./texify /app
RUN pip3 install --no-cache-dir -e . "streamlit>=1.37.1" "streamlit_drawable_canvas"
# The image is too large, with layers exceeding 10GB.
# RUN pip3 install poetry
# RUN poetry install --no-root --with dev

EXPOSE 8501

VOLUME /root/.cache

CMD ["texify_gui"]

0 comments on commit 7766a54

Please sign in to comment.