From 72b9af23bbff41321f880bb48812a0f84c7277c7 Mon Sep 17 00:00:00 2001 From: Itaykal <82172131+Itaykal@users.noreply.github.com> Date: Fri, 31 Mar 2023 13:21:13 +0000 Subject: [PATCH 01/16] added updated dockerfile --- Dockerfile | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index de7ead5..c62509e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,36 @@ -FROM python:3.9 +# Build Stage 1 +# Build the UI +FROM node:12 AS node-builder -ENV DOCKER_DEPLOYMENT=1 +WORKDIR /app/ui -RUN pip install torch +COPY ./ui/package.json . +RUN npm install --silent --production -COPY ./app/requirements.txt /tmp/requirements.txt +COPY ./ui . +RUN npm run build -RUN pip install -r /tmp/requirements.txt +# Build Stage 2 +# Builds the backend as well as gets the built UI from Stage 1 +FROM python:3.9 ENV CAPTURE_TELEMETRY=1 -COPY ./app/models.py /tmp/models.py +WORKDIR /app -# cache the models -RUN python3 /tmp/models.py +COPY ./app/requirements.txt . +RUN pip install -r /app/requirements.txt COPY ./app /app -COPY ./ui/build /ui +# Cache the models +COPY ./app/models.py /tmp/models.py +RUN python3 /tmp/models.py -COPY ./run.sh /app/run.sh - -WORKDIR /app +COPY --from=node-builder /app/ui/build /ui +COPY ./run.sh . VOLUME [ "/opt/storage" ] EXPOSE 80 - CMD ./run.sh From 52c9280942b9eb7bd9b14adf6de813c044898a91 Mon Sep 17 00:00:00 2001 From: Itaykal <82172131+Itaykal@users.noreply.github.com> Date: Fri, 31 Mar 2023 13:22:42 +0000 Subject: [PATCH 02/16] removed npm build from actions --- .github/workflows/deploy.yaml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index e7e0d8b..5799754 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -31,24 +31,6 @@ jobs: base: ${{ github.event.repository.default_branch }} head: HEAD extra_args: --debug --only-verified - - - # Use Caching for npm - - name: Cache node modules - uses: actions/cache@v2 - with: - working-directory: ./ui - path: | - node_modules - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-npm- - - - name: Install npm dependencies and build UI - run: | - cd ui - npm install - npm run build - name: Login to Docker Hub uses: docker/login-action@v1 From bbd2c311ea6b4dc8778dcd7c50cbfbb47a961ec3 Mon Sep 17 00:00:00 2001 From: Roey Lalazar <127092381+Roey7@users.noreply.github.com> Date: Fri, 31 Mar 2023 16:26:51 +0300 Subject: [PATCH 03/16] Update README.md --- README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 86aeaad..2c22c26 100644 --- a/README.md +++ b/README.md @@ -84,10 +84,18 @@ docker run -p 80:80 -v ~/.gerev/storage:/opt/storage gerev/gerev ## Run from source See CONTRIBUTING.md - - + + - **gerev is also popular with some big names. 😉** --- ![first image](./images/bill.png) + +Built by the community 💜 + + + + + +Made with [contributors-img](https://contrib.rocks). From f17fa0cd642dc1b47f593ae86663de356a32f845 Mon Sep 17 00:00:00 2001 From: Itaykal <82172131+Itaykal@users.noreply.github.com> Date: Fri, 31 Mar 2023 15:08:20 +0000 Subject: [PATCH 04/16] added docker layer cache --- .github/workflows/deploy.yaml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 5799754..2c143ad 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -44,7 +44,15 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Build and push + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Build and Push uses: docker/build-push-action@v4 env: VERSION: ${{ env.VERSION }} @@ -57,4 +65,9 @@ jobs: gerev/gerev:${{ env.VERSION }} gerev/gerev:latest cache-from: type=gha - cache-to: type=gha,mode=max \ No newline at end of file + cache-to: type=gha,mode=max + + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache \ No newline at end of file From 97c4cde1f8ffad777feb77a3d669b19102961989 Mon Sep 17 00:00:00 2001 From: Itaykal <82172131+Itaykal@users.noreply.github.com> Date: Fri, 31 Mar 2023 15:21:47 +0000 Subject: [PATCH 05/16] changed cache name --- .github/workflows/deploy.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 2c143ad..bf7b3e1 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -64,8 +64,8 @@ jobs: tags: | gerev/gerev:${{ env.VERSION }} gerev/gerev:latest - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new - name: Move cache run: | From 446a2f73230f8360d89939bb82b95ba13c8ce450 Mon Sep 17 00:00:00 2001 From: Itaykal <82172131+Itaykal@users.noreply.github.com> Date: Fri, 31 Mar 2023 15:26:30 +0000 Subject: [PATCH 06/16] added comment about fix --- .github/workflows/deploy.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index bf7b3e1..f39b901 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -67,6 +67,9 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new + + # Temp fix for cache growth + # https://github.com/docker/build-push-action/issues/252 - name: Move cache run: | rm -rf /tmp/.buildx-cache From f7ca1df1c5fed2e4df0a5e042dd9ad4ebbe8a0ba Mon Sep 17 00:00:00 2001 From: Itaykal <82172131+Itaykal@users.noreply.github.com> Date: Fri, 31 Mar 2023 15:28:48 +0000 Subject: [PATCH 07/16] added comment about fix --- .github/workflows/deploy.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index f39b901..fc8cc60 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -69,7 +69,9 @@ jobs: # Temp fix for cache growth + # https://docs.docker.com/build/ci/github-actions/cache/#local-cache # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 - name: Move cache run: | rm -rf /tmp/.buildx-cache From 9590f5725eba07e3156d7b12b4c1e2a4a376988b Mon Sep 17 00:00:00 2001 From: Itaykal <82172131+Itaykal@users.noreply.github.com> Date: Fri, 31 Mar 2023 15:37:58 +0000 Subject: [PATCH 08/16] removed whitespace --- .github/workflows/deploy.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index fc8cc60..023edb3 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -67,7 +67,6 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new - # Temp fix for cache growth # https://docs.docker.com/build/ci/github-actions/cache/#local-cache # https://github.com/docker/build-push-action/issues/252 From 70952ac06dbdd549d11c9eef297eee5d8ebb06d6 Mon Sep 17 00:00:00 2001 From: Itaykal <82172131+Itaykal@users.noreply.github.com> Date: Fri, 31 Mar 2023 17:24:10 +0000 Subject: [PATCH 09/16] Fixed whitespaces --- .github/workflows/deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 023edb3..a81ed93 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -43,7 +43,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - + - name: Cache Docker layers uses: actions/cache@v2 with: From fe1038c47786e88c7cf99aee9398d45420e20bad Mon Sep 17 00:00:00 2001 From: Itaykal <82172131+Itaykal@users.noreply.github.com> Date: Fri, 31 Mar 2023 17:24:35 +0000 Subject: [PATCH 10/16] added whitespace to file to test build cache --- app/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/__init__.py b/app/__init__.py index e69de29..8b13789 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -0,0 +1 @@ + From 4394e37cb5bd23e8e6b06d0ce5c150c2aee36a00 Mon Sep 17 00:00:00 2001 From: Itaykal <82172131+Itaykal@users.noreply.github.com> Date: Fri, 31 Mar 2023 17:34:53 +0000 Subject: [PATCH 11/16] reverted back to gha, doesnt seem that it makes a diffenerce --- .github/workflows/deploy.yaml | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index a81ed93..119b293 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -43,14 +43,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - - name: Cache Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - name: Build and Push uses: docker/build-push-action@v4 @@ -64,14 +56,5 @@ jobs: tags: | gerev/gerev:${{ env.VERSION }} gerev/gerev:latest - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new - - # Temp fix for cache growth - # https://docs.docker.com/build/ci/github-actions/cache/#local-cache - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - - name: Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache \ No newline at end of file + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file From fefb9d1c654b6899a49399f7a956b9becc4eefd2 Mon Sep 17 00:00:00 2001 From: Yuval Steuer <105603555+yuvalsteuer@users.noreply.github.com> Date: Sun, 9 Apr 2023 20:18:56 +0300 Subject: [PATCH 12/16] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c62509e..eb10a94 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,7 +30,7 @@ RUN python3 /tmp/models.py COPY --from=node-builder /app/ui/build /ui COPY ./run.sh . -VOLUME [ "/opt/storage" ] +RUN mkdir /opt/storage EXPOSE 80 CMD ./run.sh From cfc9b201df5565d64b13b5728ec62c7a8510c8d1 Mon Sep 17 00:00:00 2001 From: Yuval Steuer <105603555+yuvalsteuer@users.noreply.github.com> Date: Sun, 9 Apr 2023 21:18:00 +0300 Subject: [PATCH 13/16] Update paths.py --- app/paths.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/paths.py b/app/paths.py index f8085b7..ad65a4b 100644 --- a/app/paths.py +++ b/app/paths.py @@ -6,7 +6,7 @@ if os.name == 'nt': STORAGE_PATH = Path(".gerev\\storage") else: - STORAGE_PATH = Path('/opt/storage/') if IS_IN_DOCKER else Path(f'/home/{os.getlogin()}/.gerev/storage/') + STORAGE_PATH = Path('/tmp/storage/') if IS_IN_DOCKER else Path(f'/home/{os.getlogin()}/.gerev/storage/') if not STORAGE_PATH.exists(): STORAGE_PATH.mkdir(parents=True) From 16143622e527a7f17cc49fb800b523163d7e256f Mon Sep 17 00:00:00 2001 From: Yuval Steuer <105603555+yuvalsteuer@users.noreply.github.com> Date: Sun, 9 Apr 2023 21:18:25 +0300 Subject: [PATCH 14/16] Update paths.py --- app/paths.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/paths.py b/app/paths.py index ad65a4b..1712e8d 100644 --- a/app/paths.py +++ b/app/paths.py @@ -6,7 +6,7 @@ if os.name == 'nt': STORAGE_PATH = Path(".gerev\\storage") else: - STORAGE_PATH = Path('/tmp/storage/') if IS_IN_DOCKER else Path(f'/home/{os.getlogin()}/.gerev/storage/') + STORAGE_PATH = Path('/tmp/storage/') if not STORAGE_PATH.exists(): STORAGE_PATH.mkdir(parents=True) From c62acf8738fcac7a6746657bff5c631ba69d63b9 Mon Sep 17 00:00:00 2001 From: Yuval Steuer <105603555+yuvalsteuer@users.noreply.github.com> Date: Sun, 9 Apr 2023 21:21:01 +0300 Subject: [PATCH 15/16] Update paths.py --- app/paths.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/paths.py b/app/paths.py index 1712e8d..ad65a4b 100644 --- a/app/paths.py +++ b/app/paths.py @@ -6,7 +6,7 @@ if os.name == 'nt': STORAGE_PATH = Path(".gerev\\storage") else: - STORAGE_PATH = Path('/tmp/storage/') + STORAGE_PATH = Path('/tmp/storage/') if IS_IN_DOCKER else Path(f'/home/{os.getlogin()}/.gerev/storage/') if not STORAGE_PATH.exists(): STORAGE_PATH.mkdir(parents=True) From 5ed0f77132ad7d92c8991dc7d93771bf6eef6373 Mon Sep 17 00:00:00 2001 From: Yuval Steuer <105603555+yuvalsteuer@users.noreply.github.com> Date: Sun, 9 Apr 2023 21:21:26 +0300 Subject: [PATCH 16/16] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index eb10a94..681641e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,7 +30,7 @@ RUN python3 /tmp/models.py COPY --from=node-builder /app/ui/build /ui COPY ./run.sh . -RUN mkdir /opt/storage +ENV DOCKER_DEPLOYMENT=1 EXPOSE 80 CMD ./run.sh