Bladeren bron

Merge branch 'split_image' into test

scossu 1 jaar geleden
bovenliggende
commit
15e32bd20f

+ 39 - 0
.github/workflows/push-app-image.yml

@@ -0,0 +1,39 @@
+name: Push app image
+on:
+  # This runs on v *.*.0 after the base image has been
+  # built and pushed, or on v
+  push:
+    tags:
+      - "v*.*.[1-9]*"
+  workflow_run:
+    workflows: ["Push base image"]
+    types: ["completed"]
+
+env:
+  DOCKER_USER: lcnetdev
+  DOCKER_PASSWORD: ${{secrets.DOCKER_HUB}}
+  REPO_NAME: scriptshifter
+
+jobs:
+  push-image-to-docker-hub:
+    runs-on: ubuntu-latest
+    steps:
+      - name: checkout repo
+        uses: actions/checkout@v4
+        with:
+          submodules: recursive
+
+      - name: Build the Docker image
+        run: >
+          docker build -f Dockerfile .
+          --tag $DOCKER_USER/$REPO_NAME:${{ github.ref_name }}
+          --tag $DOCKER_USER/$REPO_NAME:latest
+
+      - name: Login to Docker Hub
+        uses: docker/login-action@v3
+        with:
+          username: lcnetdev
+          password: ${{ secrets.DOCKER_HUB }}
+
+      - name: Push to Docker Hub
+        run: docker push $DOCKER_USER/$REPO_NAME --all-tags

+ 5 - 4
.github/workflows/push-docker-image.yml → .github/workflows/push-base-image.yml

@@ -1,13 +1,13 @@
-name: Push image to Docker Hub.
+name: Push base image
 on:
   push:
     tags:
-      - "v*.*.*"
+      - "v*.*.0"
 
 env:
   DOCKER_USER: lcnetdev
   DOCKER_PASSWORD: ${{secrets.DOCKER_HUB}}
-  REPO_NAME: scriptshifter
+  REPO_NAME: scriptshifter-base
 
 jobs:
   push-image-to-docker-hub:
@@ -32,7 +32,8 @@ jobs:
 
       - name: Build the Docker image
         run: >
-          docker build . --tag $DOCKER_USER/$REPO_NAME:${{ github.ref_name }}
+          docker build -f scriptshifter_base.Dockerfile .
+          --tag $DOCKER_USER/$REPO_NAME:${{ github.ref_name }}
           --tag $DOCKER_USER/$REPO_NAME:latest
 
       - name: Login to Docker Hub

+ 5 - 14
.github/workflows/push-test-image.yml

@@ -1,4 +1,4 @@
-name: Push test image to Docker Hub.
+name: Push test image
 on:
   push:
     branch:
@@ -18,20 +18,11 @@ jobs:
         with:
           submodules: recursive
 
-      - name: checkout yiddish submodules (1/2)
-        uses: actions/checkout@v4
-        with:
-          repository: ibleaman/loshn-koydesh-pronunciation
-          path: ext/yiddish/yiddish/submodules/loshn-koydesh-pronunciation
-
-      - name: checkout yiddish submodules (2/2)
-        uses: actions/checkout@v4
-        with:
-          repository: ibleaman/hasidify_lexicon
-          path: ext/yiddish/yiddish/submodules/hasidify_lexicon
-
       - name: Build the Docker image
-        run: docker build . --tag $DOCKER_USER/$REPO_NAME:test
+        run: >
+          docker build -f Dockerfile .
+          --tag $DOCKER_USER/$REPO_NAME:${{ github.ref_name }}
+          --tag $DOCKER_USER/$REPO_NAME:test
 
       - name: Login to Docker Hub
         uses: docker/login-action@v3

+ 5 - 19
Dockerfile

@@ -1,29 +1,15 @@
-FROM python:3.10-slim-bookworm
+FROM lcnetdev/scriptshifter-base:latest
+ARG WORKROOT "/usr/local/scriptshifter/src"
 
-RUN apt update
-RUN apt install -y build-essential tzdata gfortran libopenblas-dev libboost-all-dev libpcre2-dev
-
-ENV TZ=America/New_York
-ENV _workroot "/usr/local/scriptshifter/src"
-
-RUN addgroup --system www
-RUN adduser --system www
-RUN gpasswd -a www www
-
-WORKDIR ${_workroot}
+# Copy core application files.
+WORKDIR ${WORKROOT}
 COPY entrypoint.sh uwsgi.ini wsgi.py ./
-COPY ext ./ext/
 COPY scriptshifter ./scriptshifter/
-
 COPY requirements.txt ./
 RUN pip install --no-cache-dir -r requirements.txt
 
-# Remove development packages.
-RUN apt remove -y build-essential git
-RUN apt autoremove -y
-
 RUN chmod +x ./entrypoint.sh
-RUN chown -R www:www ${_workroot} .
+#RUN chown -R www:www ${WORKROOT} .
 
 EXPOSE 8000
 

+ 7 - 0
deps.txt

@@ -0,0 +1,7 @@
+# External dependencies.
+aksharamukha>=2.1,<3
+camel-tools>=1.5
+funcy>=1.15,<2
+pymarc>=4.0,<5
+repackage>=0.7.3
+./ext/yiddish

+ 1 - 6
requirements.txt

@@ -1,10 +1,5 @@
-aksharamukha>=2.1,<3
-camel-tools>=1.5
+# Core application dependencies.
 flask>=2.3,<3
-funcy>=1.15,<2
-pymarc>=4.0,<5
 python-dotenv>=1.0,<2
 pyyaml>=6.0,<7
-repackage>=0.7.3
 uwsgi>=2.0,<2.1
-./ext/yiddish

+ 1 - 3
scriptshifter/rest_api.py

@@ -123,9 +123,7 @@ def transliterate_req():
     except (NotImplementedError, ValueError) as e:
         return (str(e), 400)
 
-    return {
-            "output": out, "warnings": warnings,
-            "debug": {"form_data": request.form}}
+    return {"output": out, "warnings": warnings}
 
 
 @app.route("/feedback", methods=["POST"])

+ 21 - 0
scriptshifter_base.Dockerfile

@@ -0,0 +1,21 @@
+FROM python:3.10-slim-bookworm
+
+RUN apt update
+RUN apt install -y build-essential tzdata gfortran libopenblas-dev libboost-all-dev libpcre2-dev
+
+ENV TZ=America/New_York
+ARG WORKROOT "/usr/local/scriptshifter/src"
+
+RUN addgroup --system www
+RUN adduser --system www
+RUN gpasswd -a www www
+
+# Copy external dependencies.
+WORKDIR ${WORKROOT}
+COPY ext ./ext/
+COPY deps.txt ./
+RUN pip install --no-cache-dir -r deps.txt
+
+# Remove development packages.
+RUN apt remove -y build-essential git
+RUN apt autoremove -y

+ 7 - 0
test.Dockerfile

@@ -0,0 +1,7 @@
+FROM python:3.10-slim-bookworm
+
+RUN apt update
+RUN apt install -y build-essential libpcre2-dev
+
+RUN pip install uwsgi
+