From 18239aa0ae7b6a1584b19cec46da5c8eb882bacb Mon Sep 17 00:00:00 2001 From: Karl Date: Fri, 9 May 2025 16:40:43 +0100 Subject: [PATCH] build the docker image and push a new one to kithub --- .gitea/workflows/demo.yml | 19 ------------ .gitea/workflows/docker-publish.sh | 47 ++++++++++++++++++++++++++++++ dockerfile | 22 ++++++++++++++ 3 files changed, 69 insertions(+), 19 deletions(-) delete mode 100644 .gitea/workflows/demo.yml create mode 100644 .gitea/workflows/docker-publish.sh create mode 100644 dockerfile diff --git a/.gitea/workflows/demo.yml b/.gitea/workflows/demo.yml deleted file mode 100644 index 394c807..0000000 --- a/.gitea/workflows/demo.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Gitea Actions Demo -run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 -on: [push] - -jobs: - Explore-Gitea-Actions: - runs-on: ubuntu-latest - steps: - - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" - - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - - name: Check out repository code - uses: actions/checkout@v4 - - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - name: List files in the repository - run: | - ls ${{ gitea.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." \ No newline at end of file diff --git a/.gitea/workflows/docker-publish.sh b/.gitea/workflows/docker-publish.sh new file mode 100644 index 0000000..b3bd1f3 --- /dev/null +++ b/.gitea/workflows/docker-publish.sh @@ -0,0 +1,47 @@ +name: Build and Publish Docker Image + +on: + push: + branches: [main] + tags: ['*'] # triggers on any tag push + workflow_dispatch: + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Registry + run: echo "${{ secrets.PASSWORD }}" | docker login ${{ secrets.REGISTRY }} -u "${{ secrets.USERNAME }}" --password-stdin + + - name: Build and Push Docker Images + run: | + IMAGE_NAME="ktv-ui" + REGISTRY="${{ secrets.REGISTRY }}" + USERNAME="${{ secrets.USERNAME }}" + IMAGE_LATEST="$REGISTRY/$USERNAME/$IMAGE_NAME:latest" + + # Always build and tag as latest + echo "🔧 Building $IMAGE_LATEST" + docker build -t $IMAGE_LATEST . + + echo "📤 Pushing $IMAGE_LATEST" + docker push $IMAGE_LATEST + + # If this is a tag push, tag the image accordingly + if [[ "${GITHUB_REF}" == refs/tags/* ]]; then + GIT_TAG="${GITHUB_REF#refs/tags/}" + IMAGE_TAGGED="$REGISTRY/$USERNAME/$IMAGE_NAME:$GIT_TAG" + + echo "🏷️ Also tagging as $IMAGE_TAGGED" + docker tag $IMAGE_LATEST $IMAGE_TAGGED + + echo "📤 Pushing $IMAGE_TAGGED" + docker push $IMAGE_TAGGED + fi diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..2daab93 --- /dev/null +++ b/dockerfile @@ -0,0 +1,22 @@ +FROM python:3.11-slim + +# Install system dependencies required by PaddleOCR and OpenCV +RUN apt-get update && apt-get install -y \ + libglib2.0-0 \ + libsm6 \ + libxrender1 \ + libxext6 \ + libgomp1 \ + libgl1 \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +EXPOSE 8089 + +CMD ["python", "app.py"]