From b1f0ced546223e74924fc9984b992e8c206924e0 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 13:43:46 -0800 Subject: [PATCH 01/36] Update build process Bump @lancedb/vectordb to 0.1.19 for AMD compatibilty resolves #539 --- .github/workflows/build-and-push-image.yaml | 17 ++++-- docker/Dockerfile | 4 +- server/package.json | 2 +- server/yarn.lock | 60 +++++++++++++++++++-- 4 files changed, 70 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 943af552668..328f4bff302 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -2,7 +2,7 @@ name: Publish Docker image and Github Registry on: push: - branches: ['master'] + branches: ['master', '539-amd64-support'] paths-ignore: - '*.md' - 'cloud-deployments/*' @@ -11,7 +11,7 @@ on: jobs: push_to_registries: - name: Push Docker image to multiple registries + name: Push multi-platform Docker image to multiple registries runs-on: ubuntu-latest permissions: packages: write @@ -19,7 +19,13 @@ jobs: steps: - name: Check out the repo uses: actions/checkout@v4 - + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Log in to Docker Hub uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a with: @@ -41,11 +47,12 @@ jobs: mintplexlabs/anythingllm ghcr.io/${{ github.repository }} - - name: Build and push Docker images - uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + - name: Build and push multi-platform Docker and GHCR images + uses: docker/build-push-action@v5 with: context: . file: ./docker/Dockerfile push: true + platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/docker/Dockerfile b/docker/Dockerfile index 72fea424a12..ab13c7b7239 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -50,9 +50,7 @@ RUN cd ./frontend/ && yarn install && yarn cache clean # Install server dependencies FROM base as server-deps COPY ./server/package.json ./server/yarn.lock ./server/ -RUN cd ./server/ && yarn install --production && yarn cache clean && \ - rm /app/server/node_modules/vectordb/x86_64-apple-darwin.node && \ - rm /app/server/node_modules/vectordb/aarch64-apple-darwin.node +RUN cd ./server/ && yarn install --production && yarn cache clean # Compile Llama.cpp bindings for node-llama-cpp for this operating system. USER root diff --git a/server/package.json b/server/package.json index 72c57d5a682..2ae549280f6 100644 --- a/server/package.json +++ b/server/package.json @@ -59,7 +59,7 @@ "swagger-ui-express": "^5.0.0", "uuid": "^9.0.0", "uuid-apikey": "^1.5.3", - "vectordb": "0.1.12", + "vectordb": "0.1.19", "weaviate-ts-client": "^1.4.0" }, "devDependencies": { diff --git a/server/yarn.lock b/server/yarn.lock index 642529b87f6..9b5f3d14876 100644 --- a/server/yarn.lock +++ b/server/yarn.lock @@ -201,6 +201,31 @@ resolved "https://registry.yarnpkg.com/@kwsites/promise-deferred/-/promise-deferred-1.1.1.tgz#8ace5259254426ccef57f3175bc64ed7095ed919" integrity sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw== +"@lancedb/vectordb-darwin-arm64@0.1.19": + version "0.1.19" + resolved "https://registry.yarnpkg.com/@lancedb/vectordb-darwin-arm64/-/vectordb-darwin-arm64-0.1.19.tgz#f7e270623008446b2cdcedcc1badfba2d35ab8e8" + integrity sha512-efQhJkBKvMNhjFq3Sw3/qHo9D9gb9UqiIr98n3STsbNxBQjMnWemXn91Ckl40siRG1O8qXcINW7Qs/EGmus+kg== + +"@lancedb/vectordb-darwin-x64@0.1.19": + version "0.1.19" + resolved "https://registry.yarnpkg.com/@lancedb/vectordb-darwin-x64/-/vectordb-darwin-x64-0.1.19.tgz#0d1c271acfb832a5282ad24c2e77cb9a1cc0e9a3" + integrity sha512-r6OZNVyemAssABz2w7CRhe7dyREwBEfTytn+ux1zzTnzsgMgDovCQ0rQ3WZcxWvcy7SFCxiemA9IP1b/lsb4tQ== + +"@lancedb/vectordb-linux-arm64-gnu@0.1.19": + version "0.1.19" + resolved "https://registry.yarnpkg.com/@lancedb/vectordb-linux-arm64-gnu/-/vectordb-linux-arm64-gnu-0.1.19.tgz#47f36e1069182bce9b4143b5fe89963a335babb9" + integrity sha512-mL/hRmZp6Kw7hmGJBdOZfp/tTYiCdlOcs8DA/+nr2eiXERv0gIhyiKvr2P5DwbBmut3qXEkDalMHTo95BSdL2A== + +"@lancedb/vectordb-linux-x64-gnu@0.1.19": + version "0.1.19" + resolved "https://registry.yarnpkg.com/@lancedb/vectordb-linux-x64-gnu/-/vectordb-linux-x64-gnu-0.1.19.tgz#8612ce0969fd98ef2f166837d517bcfc32a45937" + integrity sha512-AG0FHksbbr+cHVKPi4B8cmBtqb6T9E0uaK4kyZkXrX52/xtv9RYVZcykaB/tSSm0XNFPWWRnx9R8UqNZV/hxMA== + +"@lancedb/vectordb-win32-x64-msvc@0.1.19": + version "0.1.19" + resolved "https://registry.yarnpkg.com/@lancedb/vectordb-win32-x64-msvc/-/vectordb-win32-x64-msvc-0.1.19.tgz#6e859949ac2e83546f275b65727eee31451884e9" + integrity sha512-PDWZ2hvLVXH4Z4WIO1rsWY8ev3NpNm7aXlaey32P+l1Iz9Hia9+F2GBpp2UiEQKfvbk82ucAvBLRmpSsHY8Tlw== + "@langchain/core@~0.0.8": version "0.0.9" resolved "https://registry.yarnpkg.com/@langchain/core/-/core-0.0.9.tgz#3b4e74693eddcfa5f6e649857b561d3a9b60d1d4" @@ -231,6 +256,11 @@ semver "^7.3.5" tar "^6.1.11" +"@neon-rs/load@^0.0.74": + version "0.0.74" + resolved "https://registry.yarnpkg.com/@neon-rs/load/-/load-0.0.74.tgz#0f887144b0e3ea79e099b89bd83345004adedeb2" + integrity sha512-/cPZD907UNz55yrc/ud4wDgQKtU1TvkD9jeqZWG6J4IMmZkp6zgjkQcKA8UvpkZlcpPHvc8J17sGzLFbP/LUYg== + "@npmcli/fs@^1.0.0": version "1.1.1" resolved "https://registry.yarnpkg.com/@npmcli/fs/-/fs-1.1.1.tgz#72f719fe935e687c56a4faecf3c03d06ba593257" @@ -912,6 +942,15 @@ axios@^1.3.2: form-data "^4.0.0" proxy-from-env "^1.1.0" +axios@^1.4.0: + version "1.6.5" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.5.tgz#2c090da14aeeab3770ad30c3a1461bc970fb0cd8" + integrity sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg== + dependencies: + follow-redirects "^1.15.4" + form-data "^4.0.0" + proxy-from-env "^1.1.0" + b4a@^1.6.4: version "1.6.4" resolved "https://registry.yarnpkg.com/b4a/-/b4a-1.6.4.tgz#ef1c1422cae5ce6535ec191baeed7567443f36c9" @@ -1761,6 +1800,11 @@ follow-redirects@^1.15.0: resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a" integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q== +follow-redirects@^1.15.4: + version "1.15.4" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.4.tgz#cdc7d308bf6493126b17ea2191ea0ccf3e535adf" + integrity sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw== + form-data-encoder@1.7.2: version "1.7.2" resolved "https://registry.yarnpkg.com/form-data-encoder/-/form-data-encoder-1.7.2.tgz#1f1ae3dccf58ed4690b86d87e4f57c654fbab040" @@ -3944,13 +3988,21 @@ vary@^1, vary@~1.1.2: resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== -vectordb@0.1.12: - version "0.1.12" - resolved "https://registry.yarnpkg.com/vectordb/-/vectordb-0.1.12.tgz#b23b9938467415060e53d614e2a84458244eeb17" - integrity sha512-C7/4/n3kBiR2Z5Cgid08z9hUNfVpQaA5WKVyT4msdwmLoSZOltFeikCdx7OM5a6ekd9BwnPbzP8RhNTW8hBfNA== +vectordb@0.1.19: + version "0.1.19" + resolved "https://registry.yarnpkg.com/vectordb/-/vectordb-0.1.19.tgz#a36ea583cbc269c871edefa6a2abc5467e902d83" + integrity sha512-AS73SjteiLFM5qJQ9YwwYORd2vIVDseEq/vZmwZVbCwJAyD7M52uCiZir0cScRRAisovQZFoyvAKwZs2T4gOmw== dependencies: "@apache-arrow/ts" "^12.0.0" + "@neon-rs/load" "^0.0.74" apache-arrow "^12.0.0" + axios "^1.4.0" + optionalDependencies: + "@lancedb/vectordb-darwin-arm64" "0.1.19" + "@lancedb/vectordb-darwin-x64" "0.1.19" + "@lancedb/vectordb-linux-arm64-gnu" "0.1.19" + "@lancedb/vectordb-linux-x64-gnu" "0.1.19" + "@lancedb/vectordb-win32-x64-msvc" "0.1.19" weaviate-ts-client@^1.4.0: version "1.4.0" From 477c07bf3a5d2dbcf8e8b0873536d216c6a9af41 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 14:12:37 -0800 Subject: [PATCH 02/36] temp only build AMD64 --- .github/workflows/build-and-push-image.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 328f4bff302..df25d480293 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -53,6 +53,7 @@ jobs: context: . file: ./docker/Dockerfile push: true - platforms: linux/amd64,linux/arm64 + # platforms: linux/amd64,linux/arm64 + platforms: linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From bab7fa6c74331f3a3ca40cc2113aac83b3e47c10 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 14:23:04 -0800 Subject: [PATCH 03/36] increase yarn install timeout during ARM build - keeps timing out? --- docker/Dockerfile | 4 ++-- docker/docker-compose.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index ab13c7b7239..d108dc9ef06 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -45,12 +45,12 @@ WORKDIR /app FROM base as frontend-deps COPY ./frontend/package.json ./frontend/yarn.lock ./frontend/ -RUN cd ./frontend/ && yarn install && yarn cache clean +RUN cd ./frontend/ && yarn install --network-timeout 100000 && yarn cache clean # Install server dependencies FROM base as server-deps COPY ./server/package.json ./server/yarn.lock ./server/ -RUN cd ./server/ && yarn install --production && yarn cache clean +RUN cd ./server/ && yarn install --production --network-timeout 100000 && yarn cache clean # Compile Llama.cpp bindings for node-llama-cpp for this operating system. USER root diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 5ec67cab49d..435237b4ab3 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -10,7 +10,7 @@ services: anything-llm: container_name: anything-llm image: anything-llm:latest - platform: linux/amd64 + platform: linux/amd64,linux/arm64 build: context: ../. dockerfile: ./docker/Dockerfile From e5e7fa5edb182704286f3bce49c652e59d3d8180 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 15:24:09 -0800 Subject: [PATCH 04/36] wip monkey patch for ARM chromium --- .github/workflows/build-and-push-image.yaml | 5 ++-- docker/Dockerfile | 27 ++++++++++++++++++--- docker/docker-compose.yml | 1 - 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index df25d480293..1cef13aad44 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -2,7 +2,7 @@ name: Publish Docker image and Github Registry on: push: - branches: ['master', '539-amd64-support'] + branches: ['master'] paths-ignore: - '*.md' - 'cloud-deployments/*' @@ -53,7 +53,6 @@ jobs: context: . file: ./docker/Dockerfile push: true - # platforms: linux/amd64,linux/arm64 - platforms: linux/arm64 + platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/docker/Dockerfile b/docker/Dockerfile index d108dc9ef06..1be5aa62463 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,6 +4,9 @@ FROM ubuntu:jammy-20230522 AS base # Build arguments ARG ARG_UID=1000 ARG ARG_GID=1000 +ARG BUILDARCH + +RUN echo "Building AnythingLLM image for $BUILDARCH" # Install system dependencies RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ @@ -23,6 +26,12 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ && dpkg -i yarn_1.22.19_all.deb \ && rm yarn_1.22.19_all.deb +RUN if [ "$BUILDARCH" = "arm64" ] ; then \ + echo "Need to patch Chromium support for ARM - installing dep!" && \ + DEBIAN_FRONTEND=noninteractive apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium-browser; \ +fi + # Create a group and user with specific UID and GID RUN groupadd -g $ARG_GID anythingllm && \ useradd -u $ARG_UID -m -d /app -s /bin/bash -g anythingllm anythingllm && \ @@ -53,9 +62,9 @@ COPY ./server/package.json ./server/yarn.lock ./server/ RUN cd ./server/ && yarn install --production --network-timeout 100000 && yarn cache clean # Compile Llama.cpp bindings for node-llama-cpp for this operating system. -USER root -RUN cd ./server && npx --no node-llama-cpp download -USER anythingllm +# USER root +# RUN cd ./server && npx --no node-llama-cpp download +# USER anythingllm # Build the frontend FROM frontend-deps as build-stage @@ -73,7 +82,17 @@ COPY --from=build-stage /app/frontend/dist ./server/public COPY --chown=anythingllm:anythingllm ./collector/ ./collector/ # Install collector dependencies -RUN cd /app/collector && yarn install --production && yarn cache clean +RUN if [ "$BUILDARCH" = "amd64" ] ; then \ + export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true && \ + export PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium && \ + cd /app/collector && \ + yarn install --production && \ + yarn cache clean; \ + else \ + cd /app/collector && yarn install --production && yarn cache clean; \ +fi + +# RUN cd /app/collector && yarn install --production && yarn cache clean # Migrate and Run Prisma against known schema RUN cd ./server && npx prisma generate --schema=./prisma/schema.prisma diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 435237b4ab3..65fed24f184 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -10,7 +10,6 @@ services: anything-llm: container_name: anything-llm image: anything-llm:latest - platform: linux/amd64,linux/arm64 build: context: ../. dockerfile: ./docker/Dockerfile From 57c56a8ffeaa4218a0b109beb82e72a0009c046d Mon Sep 17 00:00:00 2001 From: shatfield4 Date: Fri, 5 Jan 2024 17:24:20 -0800 Subject: [PATCH 05/36] WIP arm64 chromedriver dockerfile --- collector/package.json | 2 +- collector/yarn.lock | 50 +++++++++---------- docker/Dockerfile | 31 +++--------- docker/Dockerfile.arm64 | 108 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 140 insertions(+), 51 deletions(-) create mode 100644 docker/Dockerfile.arm64 diff --git a/collector/package.json b/collector/package.json index 0e81b72a533..01cf26b6b0e 100644 --- a/collector/package.json +++ b/collector/package.json @@ -34,7 +34,7 @@ "multer": "^1.4.5-lts.1", "officeparser": "^4.0.5", "pdf-parse": "^1.1.1", - "puppeteer": "^21.6.1", + "puppeteer": "~21.5.2", "slugify": "^1.6.6", "url-pattern": "^1.0.3", "uuid": "^9.0.0", diff --git a/collector/yarn.lock b/collector/yarn.lock index 6501aac9579..e181b245bc5 100644 --- a/collector/yarn.lock +++ b/collector/yarn.lock @@ -134,10 +134,10 @@ resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw== -"@puppeteer/browsers@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@puppeteer/browsers/-/browsers-1.9.0.tgz#dfd0aad0bdc039572f1b57648f189525d627b7ff" - integrity sha512-QwguOLy44YBGC8vuPP2nmpX4MUN2FzWbsnvZJtiCzecU3lHmVZkaC1tq6rToi9a200m8RzlVtDyxCS0UIDrxUg== +"@puppeteer/browsers@1.8.0": + version "1.8.0" + resolved "https://registry.yarnpkg.com/@puppeteer/browsers/-/browsers-1.8.0.tgz#fb6ee61de15e7f0e67737aea9f9bab1512dbd7d8" + integrity sha512-TkRHIV6k2D8OlUe8RtG+5jgOF/H98Myx0M6AOafC8DdNVOFiBSFa5cpRDtpm8LXOa9sVwe0+e6Q3FC56X/DZfg== dependencies: debug "4.3.4" extract-zip "2.0.1" @@ -608,10 +608,10 @@ chownr@^2.0.0: resolved "https://registry.yarnpkg.com/chownr/-/chownr-2.0.0.tgz#15bfbe53d2eab4cf70f18a8cd68ebe5b3cb1dece" integrity sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ== -chromium-bidi@0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/chromium-bidi/-/chromium-bidi-0.5.1.tgz#390c1af350c4887824a33d82190de1cc5c5680fc" - integrity sha512-dcCqOgq9fHKExc2R4JZs/oKbOghWpUNFAJODS8WKRtLhp3avtIH5UDCBrutdqZdh3pARogH8y1ObXm87emwb3g== +chromium-bidi@0.4.33: + version "0.4.33" + resolved "https://registry.yarnpkg.com/chromium-bidi/-/chromium-bidi-0.4.33.tgz#9a9aba5a5b07118c8e7d6405f8ee79f47418dd1d" + integrity sha512-IxoFM5WGQOIAd95qrSXzJUv4eXIrh+RvU3rwwqIiwYuvfE7U/Llj4fejbsJnjJMUYCuGtVQsY2gv7oGl4aTNSQ== dependencies: mitt "3.0.1" urlpattern-polyfill "9.0.0" @@ -2584,26 +2584,26 @@ pump@^3.0.0: end-of-stream "^1.1.0" once "^1.3.1" -puppeteer-core@21.6.1: - version "21.6.1" - resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-21.6.1.tgz#10eccb4dc3167c8c26bc21122fabb45a9fda9ca7" - integrity sha512-0chaaK/RL9S1U3bsyR4fUeUfoj51vNnjWvXgG6DcsyMjwYNpLcAThv187i1rZCo7QhJP0wZN8plQkjNyrq2h+A== +puppeteer-core@21.5.2: + version "21.5.2" + resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-21.5.2.tgz#6d3de4efb2ae65f1ee072043787b75594e88035f" + integrity sha512-v4T0cWnujSKs+iEfmb8ccd7u4/x8oblEyKqplqKnJ582Kw8PewYAWvkH4qUWhitN3O2q9RF7dzkvjyK5HbzjLA== dependencies: - "@puppeteer/browsers" "1.9.0" - chromium-bidi "0.5.1" + "@puppeteer/browsers" "1.8.0" + chromium-bidi "0.4.33" cross-fetch "4.0.0" debug "4.3.4" devtools-protocol "0.0.1203626" - ws "8.15.1" + ws "8.14.2" -puppeteer@^21.6.1: - version "21.6.1" - resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-21.6.1.tgz#2ec0878906ff90b3a424f19e5eb006592abe25b6" - integrity sha512-O+pbc61oj8ln6m8EJKncrsQFmytgRyFYERtk190PeLbJn5JKpmmynn2p1PiFrlhCitAQXLJ0MOy7F0TeyCRqBg== +puppeteer@~21.5.2: + version "21.5.2" + resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-21.5.2.tgz#0a4a72175c0fd0944d6486f4734807e1671d527b" + integrity sha512-BaAGJOq8Fl6/cck6obmwaNLksuY0Bg/lIahCLhJPGXBFUD2mCffypa4A592MaWnDcye7eaHmSK9yot0pxctY8A== dependencies: - "@puppeteer/browsers" "1.9.0" + "@puppeteer/browsers" "1.8.0" cosmiconfig "8.3.6" - puppeteer-core "21.6.1" + puppeteer-core "21.5.2" qs@6.11.0: version "6.11.0" @@ -3259,10 +3259,10 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== -ws@8.15.1: - version "8.15.1" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.15.1.tgz#271ba33a45ca0cc477940f7f200cd7fba7ee1997" - integrity sha512-W5OZiCjXEmk0yZ66ZN82beM5Sz7l7coYxpRkzS+p9PP+ToQry8szKh+61eNktr7EA9DOwvFGhfC605jDHbP6QQ== +ws@8.14.2: + version "8.14.2" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.14.2.tgz#6c249a806eb2db7a20d26d51e7709eab7b2e6c7f" + integrity sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g== xmlbuilder@^10.0.0: version "10.1.1" diff --git a/docker/Dockerfile b/docker/Dockerfile index 1be5aa62463..ab13c7b7239 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,9 +4,6 @@ FROM ubuntu:jammy-20230522 AS base # Build arguments ARG ARG_UID=1000 ARG ARG_GID=1000 -ARG BUILDARCH - -RUN echo "Building AnythingLLM image for $BUILDARCH" # Install system dependencies RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ @@ -26,12 +23,6 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ && dpkg -i yarn_1.22.19_all.deb \ && rm yarn_1.22.19_all.deb -RUN if [ "$BUILDARCH" = "arm64" ] ; then \ - echo "Need to patch Chromium support for ARM - installing dep!" && \ - DEBIAN_FRONTEND=noninteractive apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium-browser; \ -fi - # Create a group and user with specific UID and GID RUN groupadd -g $ARG_GID anythingllm && \ useradd -u $ARG_UID -m -d /app -s /bin/bash -g anythingllm anythingllm && \ @@ -54,17 +45,17 @@ WORKDIR /app FROM base as frontend-deps COPY ./frontend/package.json ./frontend/yarn.lock ./frontend/ -RUN cd ./frontend/ && yarn install --network-timeout 100000 && yarn cache clean +RUN cd ./frontend/ && yarn install && yarn cache clean # Install server dependencies FROM base as server-deps COPY ./server/package.json ./server/yarn.lock ./server/ -RUN cd ./server/ && yarn install --production --network-timeout 100000 && yarn cache clean +RUN cd ./server/ && yarn install --production && yarn cache clean # Compile Llama.cpp bindings for node-llama-cpp for this operating system. -# USER root -# RUN cd ./server && npx --no node-llama-cpp download -# USER anythingllm +USER root +RUN cd ./server && npx --no node-llama-cpp download +USER anythingllm # Build the frontend FROM frontend-deps as build-stage @@ -82,17 +73,7 @@ COPY --from=build-stage /app/frontend/dist ./server/public COPY --chown=anythingllm:anythingllm ./collector/ ./collector/ # Install collector dependencies -RUN if [ "$BUILDARCH" = "amd64" ] ; then \ - export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true && \ - export PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium && \ - cd /app/collector && \ - yarn install --production && \ - yarn cache clean; \ - else \ - cd /app/collector && yarn install --production && yarn cache clean; \ -fi - -# RUN cd /app/collector && yarn install --production && yarn cache clean +RUN cd /app/collector && yarn install --production && yarn cache clean # Migrate and Run Prisma against known schema RUN cd ./server && npx prisma generate --schema=./prisma/schema.prisma diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64 new file mode 100644 index 00000000000..c31bb9988cf --- /dev/null +++ b/docker/Dockerfile.arm64 @@ -0,0 +1,108 @@ +# Setup base image +FROM ubuntu:jammy-20230522 AS base + +# Build arguments +ARG ARG_UID=1000 +ARG ARG_GID=1000 +ARG BUILDARCH + +RUN echo "Building AnythingLLM image for $BUILDARCH" + +# Install system dependencies +RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ + unzip curl gnupg libgfortran5 libgbm1 tzdata netcat \ + libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 \ + libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libx11-6 libx11-xcb1 libxcb1 \ + libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 \ + libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release \ + xdg-utils git build-essential ffmpeg && \ + mkdir -p /etc/apt/keyrings && \ + curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ + echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \ + apt-get update && \ + apt-get install -yq --no-install-recommends nodejs && \ + curl -LO https://github.com/yarnpkg/yarn/releases/download/v1.22.19/yarn_1.22.19_all.deb \ + && dpkg -i yarn_1.22.19_all.deb \ + && rm yarn_1.22.19_all.deb + +# Create a group and user with specific UID and GID +RUN groupadd -g $ARG_GID anythingllm && \ + useradd -u $ARG_UID -m -d /app -s /bin/bash -g anythingllm anythingllm && \ + mkdir -p /app/frontend/ /app/server/ /app/collector/ && chown -R anythingllm:anythingllm /app + +# Copy docker helper scripts +COPY ./docker/docker-entrypoint.sh /usr/local/bin/ +COPY ./docker/docker-healthcheck.sh /usr/local/bin/ +COPY --chown=anythingllm:anythingllm ./docker/.env.example /app/server/.env + +# Ensure the scripts are executable +RUN chmod +x /usr/local/bin/docker-entrypoint.sh && \ + chmod +x /usr/local/bin/docker-healthcheck.sh + +USER anythingllm + +WORKDIR /app + +RUN if [ "$BUILDARCH" = "arm64" ] ; then \ + echo "Need to patch Chromium support for ARM - installing dep!" && \ + curl https://playwright.azureedge.net/builds/chromium/1088/chromium-linux-arm64.zip -o chrome-linux.zip && \ + unzip chrome-linux.zip && \ + rm -rf chrome-linux.zip && \ + chmod -R 777 chrome-linux; \ +fi + +# Install frontend dependencies +FROM base as frontend-deps + +COPY ./frontend/package.json ./frontend/yarn.lock ./frontend/ +RUN cd ./frontend/ && yarn install --network-timeout 100000 && yarn cache clean + +# Install server dependencies +FROM base as server-deps +COPY ./server/package.json ./server/yarn.lock ./server/ +RUN cd ./server/ && yarn install --production --network-timeout 100000 && yarn cache clean + +# Compile Llama.cpp bindings for node-llama-cpp for this operating system. +# USER root +# RUN cd ./server && npx --no node-llama-cpp download +# USER anythingllm + +# Build the frontend +FROM frontend-deps as build-stage +COPY ./frontend/ ./frontend/ +RUN cd ./frontend/ && yarn build && yarn cache clean + +# Setup the server +FROM server-deps as production-stage +COPY --chown=anythingllm:anythingllm ./server/ ./server/ + +# Copy built static frontend files to the server public directory +COPY --from=build-stage /app/frontend/dist ./server/public + +# Copy the collector +COPY --chown=anythingllm:anythingllm ./collector/ ./collector/ + +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true +ENV CHROME_PATH=/app/chrome-linux/chrome +ENV PUPPETEER_EXECUTABLE_PATH=/app/chrome-linux/chrome + +RUN cd /app/collector && yarn install --production && yarn cache clean + +# Migrate and Run Prisma against known schema +RUN cd ./server && npx prisma generate --schema=./prisma/schema.prisma +RUN cd ./server && npx prisma migrate deploy --schema=./prisma/schema.prisma + +# Setup the environment +ENV NODE_ENV=production +ENV ANYTHING_LLM_RUNTIME=docker + +# Expose the server port +EXPOSE 3001 + +# Setup the healthcheck +HEALTHCHECK --interval=1m --timeout=10s --start-period=1m \ + CMD /bin/bash /usr/local/bin/docker-healthcheck.sh || exit 1 + +# Run the server +ENTRYPOINT ["/bin/bash", "/usr/local/bin/docker-entrypoint.sh"] \ No newline at end of file From abec5ab8a9165e0372dd445d635e581c589cdcab Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 17:59:35 -0800 Subject: [PATCH 06/36] update buildfiles per-arch --- .github/workflows/build-and-push-image.yaml | 16 +++++++++++++--- docker/Dockerfile | 2 ++ docker/Dockerfile.arm64 | 17 ++++++++++------- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 1cef13aad44..ae9346a0a7d 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -2,7 +2,7 @@ name: Publish Docker image and Github Registry on: push: - branches: ['master'] + branches: ['master', '539-amd64-support'] paths-ignore: - '*.md' - 'cloud-deployments/*' @@ -47,12 +47,22 @@ jobs: mintplexlabs/anythingllm ghcr.io/${{ github.repository }} - - name: Build and push multi-platform Docker and GHCR images + - name: Build and push x86 Docker and GHCR images uses: docker/build-push-action@v5 with: context: . file: ./docker/Dockerfile push: true - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Build and push arm86 Docker and GHCR images + uses: docker/build-push-action@v5 + with: + context: . + file: ./docker/Dockerfile.arm64 + push: true + platforms: linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/docker/Dockerfile b/docker/Dockerfile index ab13c7b7239..b7c3d09174d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,6 +5,8 @@ FROM ubuntu:jammy-20230522 AS base ARG ARG_UID=1000 ARG ARG_GID=1000 +RUN echo "Building AnythingLLM image for non-ARM architecture" + # Install system dependencies RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64 index c31bb9988cf..0c4e446d281 100644 --- a/docker/Dockerfile.arm64 +++ b/docker/Dockerfile.arm64 @@ -6,7 +6,8 @@ ARG ARG_UID=1000 ARG ARG_GID=1000 ARG BUILDARCH -RUN echo "Building AnythingLLM image for $BUILDARCH" +RUN if [ "$BUILDARCH" != "arm64" ] ; then echo "[ARCH INCOMPATIBLE] You can only run this Dockerfile on arm86 architecture - Aborting."; exit 1; fi +RUN echo "Building AnythingLLM image for $BUILDARCH architecture" # Install system dependencies RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ @@ -44,12 +45,14 @@ USER anythingllm WORKDIR /app +# Puppeteer does not ship with an ARM86 compatible build for Chromium +# so web-scraping would be broken in arm docker containers unless we patch it +# by manually installing a compatible chromedriver. RUN if [ "$BUILDARCH" = "arm64" ] ; then \ - echo "Need to patch Chromium support for ARM - installing dep!" && \ + echo "Need to patch Puppeteer x Chromium support for ARM86 - installing dep!" && \ curl https://playwright.azureedge.net/builds/chromium/1088/chromium-linux-arm64.zip -o chrome-linux.zip && \ unzip chrome-linux.zip && \ - rm -rf chrome-linux.zip && \ - chmod -R 777 chrome-linux; \ + rm -rf chrome-linux.zip; fi # Install frontend dependencies @@ -64,9 +67,9 @@ COPY ./server/package.json ./server/yarn.lock ./server/ RUN cd ./server/ && yarn install --production --network-timeout 100000 && yarn cache clean # Compile Llama.cpp bindings for node-llama-cpp for this operating system. -# USER root -# RUN cd ./server && npx --no node-llama-cpp download -# USER anythingllm +USER root +RUN cd ./server && npx --no node-llama-cpp download +USER anythingllm # Build the frontend FROM frontend-deps as build-stage From 8692cddb95eae3e2679cc12766b40683f2fc063e Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 18:06:01 -0800 Subject: [PATCH 07/36] update build files --- docker/Dockerfile.arm64 | 2 +- docker/docker-compose.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64 index 0c4e446d281..022a05bfad5 100644 --- a/docker/Dockerfile.arm64 +++ b/docker/Dockerfile.arm64 @@ -52,7 +52,7 @@ RUN if [ "$BUILDARCH" = "arm64" ] ; then \ echo "Need to patch Puppeteer x Chromium support for ARM86 - installing dep!" && \ curl https://playwright.azureedge.net/builds/chromium/1088/chromium-linux-arm64.zip -o chrome-linux.zip && \ unzip chrome-linux.zip && \ - rm -rf chrome-linux.zip; + rm -rf chrome-linux.zip; \ fi # Install frontend dependencies diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 65fed24f184..a9909c620c7 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -9,6 +9,7 @@ networks: services: anything-llm: container_name: anything-llm + platform: linux/amd64 # We will assume all docker compose builds are using x86 image: anything-llm:latest build: context: ../. From b9b6ba8404c7281276688b9e657b62c9cca1b040 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 18:12:27 -0800 Subject: [PATCH 08/36] force arg for arm64 --- .github/workflows/build-and-push-image.yaml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index ae9346a0a7d..f59aaf001f4 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -47,15 +47,15 @@ jobs: mintplexlabs/anythingllm ghcr.io/${{ github.repository }} - - name: Build and push x86 Docker and GHCR images - uses: docker/build-push-action@v5 - with: - context: . - file: ./docker/Dockerfile - push: true - platforms: linux/amd64 - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + # - name: Build and push x86 Docker and GHCR images + # uses: docker/build-push-action@v5 + # with: + # context: . + # file: ./docker/Dockerfile + # push: true + # platforms: linux/amd64 + # tags: ${{ steps.meta.outputs.tags }} + # labels: ${{ steps.meta.outputs.labels }} - name: Build and push arm86 Docker and GHCR images uses: docker/build-push-action@v5 @@ -66,3 +66,5 @@ jobs: platforms: linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + env: + BUILDARCH: arm64 From 6d5ffae98582c55ac85caa2764b293aa4b124883 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 18:15:24 -0800 Subject: [PATCH 09/36] wip --- .github/workflows/build-and-push-image.yaml | 4 ++-- docker/Dockerfile.arm64 | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index f59aaf001f4..63815cdc118 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -66,5 +66,5 @@ jobs: platforms: linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - env: - BUILDARCH: arm64 + build-args: | + BUILDARCH=arm64 diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64 index 022a05bfad5..6fd332429c7 100644 --- a/docker/Dockerfile.arm64 +++ b/docker/Dockerfile.arm64 @@ -6,6 +6,7 @@ ARG ARG_UID=1000 ARG ARG_GID=1000 ARG BUILDARCH +RUN echo $BUILDARCH RUN if [ "$BUILDARCH" != "arm64" ] ; then echo "[ARCH INCOMPATIBLE] You can only run this Dockerfile on arm86 architecture - Aborting."; exit 1; fi RUN echo "Building AnythingLLM image for $BUILDARCH architecture" From 28331cb6bb9cec946e55a6f225e695d8588b2234 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 19:14:39 -0800 Subject: [PATCH 10/36] combine jobs into runner --- .github/workflows/build-and-push-image.yaml | 62 +++++++++++++++------ docker/Dockerfile.arm64 | 1 - 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 63815cdc118..fef2895798b 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -1,8 +1,8 @@ -name: Publish Docker image and Github Registry +name: Publish AnythingLLM Docker image on: push: - branches: ['master', '539-amd64-support'] + branches: ['master'] paths-ignore: - '*.md' - 'cloud-deployments/*' @@ -10,8 +10,48 @@ on: - '.vscode/*' jobs: - push_to_registries: - name: Push multi-platform Docker image to multiple registries + push_x86_to_registries: + name: Push Docker x86 image to multiple registries + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: | + mintplexlabs/anythingllm + ghcr.io/${{ github.repository }} + + - name: Build and push x86 Docker image + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: . + file: ./docker/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + push_arm64_to_registries: + name: Push Docker arm64 image to multiple registries runs-on: ubuntu-latest permissions: packages: write @@ -46,18 +86,8 @@ jobs: images: | mintplexlabs/anythingllm ghcr.io/${{ github.repository }} - - # - name: Build and push x86 Docker and GHCR images - # uses: docker/build-push-action@v5 - # with: - # context: . - # file: ./docker/Dockerfile - # push: true - # platforms: linux/amd64 - # tags: ${{ steps.meta.outputs.tags }} - # labels: ${{ steps.meta.outputs.labels }} - - name: Build and push arm86 Docker and GHCR images + - name: Build and push arm64 Docker and GHCR images uses: docker/build-push-action@v5 with: context: . @@ -67,4 +97,4 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: | - BUILDARCH=arm64 + BUILDARCH=arm64 \ No newline at end of file diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64 index 6fd332429c7..022a05bfad5 100644 --- a/docker/Dockerfile.arm64 +++ b/docker/Dockerfile.arm64 @@ -6,7 +6,6 @@ ARG ARG_UID=1000 ARG ARG_GID=1000 ARG BUILDARCH -RUN echo $BUILDARCH RUN if [ "$BUILDARCH" != "arm64" ] ; then echo "[ARCH INCOMPATIBLE] You can only run this Dockerfile on arm86 architecture - Aborting."; exit 1; fi RUN echo "Building AnythingLLM image for $BUILDARCH architecture" From e54af8b5224a53c2f0ad23fc2b2e8b522696056a Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 19:18:04 -0800 Subject: [PATCH 11/36] test build --- .github/workflows/build-and-push-image.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index fef2895798b..59c7d0f94e6 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -2,7 +2,7 @@ name: Publish AnythingLLM Docker image on: push: - branches: ['master'] + branches: ['master', 'arm64'] paths-ignore: - '*.md' - 'cloud-deployments/*' From c7da31920d1836ca0e6ab8ab08a5dcc3f39a311a Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 20:17:46 -0800 Subject: [PATCH 12/36] bump --- .github/workflows/build-and-push-image.yaml | 1 + docker/Dockerfile | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 59c7d0f94e6..1a429100e8b 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -47,6 +47,7 @@ jobs: context: . file: ./docker/Dockerfile push: true + platforms: linux/amd64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/docker/Dockerfile b/docker/Dockerfile index b7c3d09174d..aaecfc495f4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -47,12 +47,12 @@ WORKDIR /app FROM base as frontend-deps COPY ./frontend/package.json ./frontend/yarn.lock ./frontend/ -RUN cd ./frontend/ && yarn install && yarn cache clean +RUN cd ./frontend/ && yarn install --network-timeout 100000 && yarn cache clean # Install server dependencies FROM base as server-deps COPY ./server/package.json ./server/yarn.lock ./server/ -RUN cd ./server/ && yarn install --production && yarn cache clean +RUN cd ./server/ && yarn install --production --network-timeout 100000 && yarn cache clean # Compile Llama.cpp bindings for node-llama-cpp for this operating system. USER root @@ -75,7 +75,7 @@ COPY --from=build-stage /app/frontend/dist ./server/public COPY --chown=anythingllm:anythingllm ./collector/ ./collector/ # Install collector dependencies -RUN cd /app/collector && yarn install --production && yarn cache clean +RUN cd /app/collector && yarn install --production --network-timeout 100000 && yarn cache clean # Migrate and Run Prisma against known schema RUN cd ./server && npx prisma generate --schema=./prisma/schema.prisma From 68d6b7deff8e7f5556da0fe53db68547377034be Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 21:14:53 -0800 Subject: [PATCH 13/36] bump --- .github/workflows/build-and-push-image.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 1a429100e8b..d97b3be76c3 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -61,6 +61,11 @@ jobs: - name: Check out the repo uses: actions/checkout@v4 + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + - name: Set up QEMU uses: docker/setup-qemu-action@v3 From 22a25430d7e7b667fc763e43176e2d965abb0f08 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 21:16:04 -0800 Subject: [PATCH 14/36] bump --- .github/workflows/build-and-push-image.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index d97b3be76c3..51d560e6bb0 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -100,7 +100,7 @@ jobs: file: ./docker/Dockerfile.arm64 push: true platforms: linux/arm64 - tags: ${{ steps.meta.outputs.tags }} + tags: ${{ steps.extract_branch.outputs.branch }}:arm64 labels: ${{ steps.meta.outputs.labels }} build-args: | BUILDARCH=arm64 \ No newline at end of file From c1394eeb50844391dae4da7121338f96a6615206 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 22:22:31 -0800 Subject: [PATCH 15/36] wip --- .github/workflows/build-and-push-image.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 51d560e6bb0..3ede817740f 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -20,6 +20,11 @@ jobs: - name: Check out the repo uses: actions/checkout@v4 + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + - name: Log in to Docker Hub uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a with: @@ -48,7 +53,7 @@ jobs: file: ./docker/Dockerfile push: true platforms: linux/amd64 - tags: ${{ steps.meta.outputs.tags }} + tags: ${{ steps.extract_branch.outputs.branch }}-x86 labels: ${{ steps.meta.outputs.labels }} push_arm64_to_registries: From 168e6b3bc392e78e3bc7f244d7fbcf61f8431d15 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 22:37:31 -0800 Subject: [PATCH 16/36] wip --- .github/workflows/build-and-push-image.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 3ede817740f..1b3a4ec532d 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -53,7 +53,9 @@ jobs: file: ./docker/Dockerfile push: true platforms: linux/amd64 - tags: ${{ steps.extract_branch.outputs.branch }}-x86 + tags: | + mintplexlabs/anythingllm:${{ steps.extract_branch.outputs.branch }}-x86 + ghcr.io/${{ github.repository }}:${{ steps.extract_branch.outputs.branch }}-x86 labels: ${{ steps.meta.outputs.labels }} push_arm64_to_registries: From 2088472428884960aef642b4e9e6f08c8d454bbc Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 22:41:17 -0800 Subject: [PATCH 17/36] wip --- .github/workflows/build-and-push-image.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 1b3a4ec532d..180c5ab189c 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -25,6 +25,11 @@ jobs: run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: extract_branch + - name: downcase repository name + shell: bash + run: echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT + id: lowercase_repo + - name: Log in to Docker Hub uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a with: @@ -55,7 +60,7 @@ jobs: platforms: linux/amd64 tags: | mintplexlabs/anythingllm:${{ steps.extract_branch.outputs.branch }}-x86 - ghcr.io/${{ github.repository }}:${{ steps.extract_branch.outputs.branch }}-x86 + ghcr.io/${{ steps.lowercase_repo.outputs.repo }}:${{ steps.extract_branch.outputs.branch }}-x86 labels: ${{ steps.meta.outputs.labels }} push_arm64_to_registries: From 025cc2682337e84f62b68781793a317364ce0ecc Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 22:48:54 -0800 Subject: [PATCH 18/36] wip --- .github/workflows/build-and-push-image.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 180c5ab189c..cb4cf1439ec 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -58,9 +58,7 @@ jobs: file: ./docker/Dockerfile push: true platforms: linux/amd64 - tags: | - mintplexlabs/anythingllm:${{ steps.extract_branch.outputs.branch }}-x86 - ghcr.io/${{ steps.lowercase_repo.outputs.repo }}:${{ steps.extract_branch.outputs.branch }}-x86 + tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} push_arm64_to_registries: @@ -112,7 +110,9 @@ jobs: file: ./docker/Dockerfile.arm64 push: true platforms: linux/arm64 - tags: ${{ steps.extract_branch.outputs.branch }}:arm64 + tags: | + mintplexlabs/anythingllm:${{ steps.extract_branch.outputs.branch }}-arm64 + ghcr.io/${{ steps.lowercase_repo.outputs.repo }}:${{ steps.extract_branch.outputs.branch }}-arm64 labels: ${{ steps.meta.outputs.labels }} build-args: | BUILDARCH=arm64 \ No newline at end of file From ade0fef66fc6f9c8c31852c189194e16661877f5 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Fri, 5 Jan 2024 23:03:06 -0800 Subject: [PATCH 19/36] add helper method --- .github/workflows/build-and-push-image.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index cb4cf1439ec..08ae9d50a19 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -76,6 +76,11 @@ jobs: run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: extract_branch + - name: downcase repository name + shell: bash + run: echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT + id: lowercase_repo + - name: Set up QEMU uses: docker/setup-qemu-action@v3 From 0d7a759bd3f1e3ceae43818f3bb55c14562ff120 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Sat, 6 Jan 2024 12:22:17 -0800 Subject: [PATCH 20/36] remove testing build branch --- .github/workflows/build-and-push-image.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 08ae9d50a19..2a8352b03da 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -2,7 +2,7 @@ name: Publish AnythingLLM Docker image on: push: - branches: ['master', 'arm64'] + branches: ['master'] paths-ignore: - '*.md' - 'cloud-deployments/*' From b2f9ef3b6943207291048b8fbf0b18ca72dbf91c Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Sat, 6 Jan 2024 12:27:22 -0800 Subject: [PATCH 21/36] docker readme updates --- docker/HOW_TO_USE_DOCKER.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/docker/HOW_TO_USE_DOCKER.md b/docker/HOW_TO_USE_DOCKER.md index 3a2875e949e..10acce8c08f 100644 --- a/docker/HOW_TO_USE_DOCKER.md +++ b/docker/HOW_TO_USE_DOCKER.md @@ -29,7 +29,35 @@ Use the Dockerized version of AnythingLLM for a much faster and complete startup > It is best to mount the containers storage volume to a folder on your host machine > so that you can pull in future updates without deleting your existing data! -`docker pull mintplexlabs/anythingllm:master` + + + + + + + + + + + + +
Pull in the correct image for your system
+ (default) amd64 / x86 + + +```shell +docker pull mintplexlabs/anythingllm:master +``` + +
+ arm64 / Apple Silicon + + +```shell +docker pull mintplexlabs/anythingllm:master-arm64 +``` + +
From 456b225e277116d082e42c7ee3c56fb6bede16b4 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Sat, 6 Jan 2024 12:30:13 -0800 Subject: [PATCH 22/36] correct colspan --- docker/HOW_TO_USE_DOCKER.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/HOW_TO_USE_DOCKER.md b/docker/HOW_TO_USE_DOCKER.md index 10acce8c08f..88abd6ed16e 100644 --- a/docker/HOW_TO_USE_DOCKER.md +++ b/docker/HOW_TO_USE_DOCKER.md @@ -30,8 +30,8 @@ Use the Dockerized version of AnythingLLM for a much faster and complete startup > so that you can pull in future updates without deleting your existing data!
- - + +
Pull in the correct image for your system
Pull in the correct image for your system
From 5d4b52f557b9d561ae13a39c70b061a3dcfcdf8b Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Sat, 6 Jan 2024 12:43:36 -0800 Subject: [PATCH 23/36] update command layout --- docker/HOW_TO_USE_DOCKER.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docker/HOW_TO_USE_DOCKER.md b/docker/HOW_TO_USE_DOCKER.md index 88abd6ed16e..7117b6c0bd5 100644 --- a/docker/HOW_TO_USE_DOCKER.md +++ b/docker/HOW_TO_USE_DOCKER.md @@ -31,7 +31,7 @@ Use the Dockerized version of AnythingLLM for a much faster and complete startup - +
Pull in the correct image for your systemPull in the correct image for your system
@@ -52,6 +52,7 @@ docker pull mintplexlabs/anythingllm:master ```shell +# Keep in mind your tag is `master-arm64`! docker pull mintplexlabs/anythingllm:master-arm64 ``` @@ -61,10 +62,12 @@ docker pull mintplexlabs/anythingllm:master-arm64 - - + + + + +
Linux/MacOsWindows PowershellMount the storage locally and run AnythingLLM in Docker
+ Linux/MacOs + ```shell @@ -79,10 +82,16 @@ docker run -d -p 3001:3001 \ mintplexlabs/anythingllm:master ``` +
+ Windows ```powershell +# Run this in powershell terminal $env:STORAGE_LOCATION="$HOME\Documents\anythingllm"; ` If(!(Test-Path $env:STORAGE_LOCATION)) {New-Item $env:STORAGE_LOCATION -ItemType Directory}; ` If(!(Test-Path "$env:STORAGE_LOCATION\.env")) {New-Item "$env:STORAGE_LOCATION\.env"}; ` From 23335d473d3a762500f61cab38c66a6dff38182a Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Sat, 6 Jan 2024 12:58:21 -0800 Subject: [PATCH 24/36] update build file for latest tag --- .github/workflows/build-and-push-image.yaml | 119 +++++++++++--------- 1 file changed, 64 insertions(+), 55 deletions(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 2a8352b03da..2e4caf1c953 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -1,8 +1,14 @@ -name: Publish AnythingLLM Docker image +# This Github action is for publishing of the primary image for AnythingLLM +# It will publish a linux/amd64 and linux/arm64 image at the same time +# This file should ONLY BY USED FOR `master` BRANCH. +# TODO: Update `runs-on` for arm64 when GitHub finally supports +# native arm environments as QEMU takes around 1 hour to build +# ref: https://github.com/actions/runner-images/issues/5631 :( +name: Publish AnythingLLM Primary Docker image on: push: - branches: ['master'] + branches: ['master', 'arm64'] # master branch only. Do not modify. paths-ignore: - '*.md' - 'cloud-deployments/*' @@ -58,66 +64,69 @@ jobs: file: ./docker/Dockerfile push: true platforms: linux/amd64 - tags: ${{ steps.meta.outputs.tags }} + tags: | + ${{ steps.meta.outputs.tags }} + mintplexlabs/anythingllm:latest-ex + ghcr.io/${{ steps.lowercase_repo.outputs.repo }}:latest-ex labels: ${{ steps.meta.outputs.labels }} - push_arm64_to_registries: - name: Push Docker arm64 image to multiple registries - runs-on: ubuntu-latest - permissions: - packages: write - contents: read - steps: - - name: Check out the repo - uses: actions/checkout@v4 + # push_arm64_to_registries: + # name: Push Docker arm64 image to multiple registries + # runs-on: ubuntu-latest + # permissions: + # packages: write + # contents: read + # steps: + # - name: Check out the repo + # uses: actions/checkout@v4 - - name: Extract branch name - shell: bash - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT - id: extract_branch + # - name: Extract branch name + # shell: bash + # run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + # id: extract_branch - - name: downcase repository name - shell: bash - run: echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT - id: lowercase_repo + # - name: downcase repository name + # shell: bash + # run: echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT + # id: lowercase_repo - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + # - name: Set up QEMU + # uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + # - name: Set up Docker Buildx + # uses: docker/setup-buildx-action@v3 - - name: Log in to Docker Hub - uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + # - name: Log in to Docker Hub + # uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + # with: + # username: ${{ secrets.DOCKER_USERNAME }} + # password: ${{ secrets.DOCKER_PASSWORD }} - - name: Log in to the Container registry - uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + # - name: Log in to the Container registry + # uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + # with: + # registry: ghcr.io + # username: ${{ github.actor }} + # password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 - with: - images: | - mintplexlabs/anythingllm - ghcr.io/${{ github.repository }} + # - name: Extract metadata (tags, labels) for Docker + # id: meta + # uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + # with: + # images: | + # mintplexlabs/anythingllm + # ghcr.io/${{ github.repository }} - - name: Build and push arm64 Docker and GHCR images - uses: docker/build-push-action@v5 - with: - context: . - file: ./docker/Dockerfile.arm64 - push: true - platforms: linux/arm64 - tags: | - mintplexlabs/anythingllm:${{ steps.extract_branch.outputs.branch }}-arm64 - ghcr.io/${{ steps.lowercase_repo.outputs.repo }}:${{ steps.extract_branch.outputs.branch }}-arm64 - labels: ${{ steps.meta.outputs.labels }} - build-args: | - BUILDARCH=arm64 \ No newline at end of file + # - name: Build and push arm64 Docker and GHCR images + # uses: docker/build-push-action@v5 + # with: + # context: . + # file: ./docker/Dockerfile.arm64 + # push: true + # platforms: linux/arm64 + # tags: | + # mintplexlabs/anythingllm:${{ steps.extract_branch.outputs.branch }}-arm64 + # ghcr.io/${{ steps.lowercase_repo.outputs.repo }}:${{ steps.extract_branch.outputs.branch }}-arm64 + # labels: ${{ steps.meta.outputs.labels }} + # build-args: | + # BUILDARCH=arm64 \ No newline at end of file From 24cebd7e6cd5d72f16f7032ed8f9022882105f74 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Sat, 6 Jan 2024 13:56:14 -0800 Subject: [PATCH 25/36] try single build step --- .github/workflows/build-and-push-image.yaml | 81 ++++++++++++++--- docker/Dockerfile | 72 ++++++++++++++-- docker/Dockerfile.old | 96 +++++++++++++++++++++ docker/docker-compose.yml | 3 +- 4 files changed, 233 insertions(+), 19 deletions(-) create mode 100644 docker/Dockerfile.old diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 2e4caf1c953..0489b362571 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -16,8 +16,8 @@ on: - '.vscode/*' jobs: - push_x86_to_registries: - name: Push Docker x86 image to multiple registries + push_amd64_to_registries: + name: Push Docker multi-platform image to multiple registries runs-on: ubuntu-latest permissions: packages: write @@ -35,6 +35,12 @@ jobs: shell: bash run: echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT id: lowercase_repo + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Log in to Docker Hub uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a @@ -57,21 +63,74 @@ jobs: mintplexlabs/anythingllm ghcr.io/${{ github.repository }} - - name: Build and push x86 Docker image - uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + - name: Build and push multi-platform Docker image + uses: docker/build-push-action@v5 with: context: . file: ./docker/Dockerfile push: true - platforms: linux/amd64 - tags: | - ${{ steps.meta.outputs.tags }} - mintplexlabs/anythingllm:latest-ex - ghcr.io/${{ steps.lowercase_repo.outputs.repo }}:latest-ex + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + # push_amd64_to_registries: + # name: Push Docker linux/amd64 image to multiple registries + # runs-on: ubuntu-latest + # permissions: + # packages: write + # contents: read + # steps: + # - name: Check out the repo + # uses: actions/checkout@v4 + + # - name: Extract branch name + # shell: bash + # run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + # id: extract_branch + + # - name: downcase repository name + # shell: bash + # run: echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT + # id: lowercase_repo + + # - name: Log in to Docker Hub + # uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + # with: + # username: ${{ secrets.DOCKER_USERNAME }} + # password: ${{ secrets.DOCKER_PASSWORD }} + + # - name: Log in to the Container registry + # uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + # with: + # registry: ghcr.io + # username: ${{ github.actor }} + # password: ${{ secrets.GITHUB_TOKEN }} + + # - name: Extract metadata (tags, labels) for Docker + # id: meta + # uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + # with: + # images: | + # mintplexlabs/anythingllm + # ghcr.io/${{ github.repository }} + + # - name: Build and push linux/amd64 Docker image + # uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + # with: + # context: . + # file: ./docker/Dockerfile + # push: true + # platforms: linux/amd64 + # tags: | + # ${{ steps.meta.outputs.tags }} + # # tags: | + # # ${{ steps.meta.outputs.tags }} + # # mintplexlabs/anythingllm:latest + # # ghcr.io/${{ steps.lowercase_repo.outputs.repo }}:latest + # labels: ${{ steps.meta.outputs.labels }} + # push_arm64_to_registries: - # name: Push Docker arm64 image to multiple registries + # name: Push Docker linux/arm64 image to multiple registries # runs-on: ubuntu-latest # permissions: # packages: write @@ -117,7 +176,7 @@ jobs: # mintplexlabs/anythingllm # ghcr.io/${{ github.repository }} - # - name: Build and push arm64 Docker and GHCR images + # - name: Build and push linux/arm64 Docker and GHCR images # uses: docker/build-push-action@v5 # with: # context: . diff --git a/docker/Dockerfile b/docker/Dockerfile index aaecfc495f4..595099fb753 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,16 +1,15 @@ # Setup base image FROM ubuntu:jammy-20230522 AS base -# Build arguments ARG ARG_UID=1000 ARG ARG_GID=1000 -RUN echo "Building AnythingLLM image for non-ARM architecture" +FROM base AS build-arm64 +RUN echo "Preparing build of AnythingLLM image for arm64 architecture" -# Install system dependencies RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ - curl gnupg libgfortran5 libgbm1 tzdata netcat \ + unzip curl gnupg libgfortran5 libgbm1 tzdata netcat \ libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 \ libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libx11-6 libx11-xcb1 libxcb1 \ libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 \ @@ -40,17 +39,76 @@ RUN chmod +x /usr/local/bin/docker-entrypoint.sh && \ chmod +x /usr/local/bin/docker-healthcheck.sh USER anythingllm +WORKDIR /app + +# Puppeteer does not ship with an ARM86 compatible build for Chromium +# so web-scraping would be broken in arm docker containers unless we patch it +# by manually installing a compatible chromedriver. +RUN echo "Need to patch Puppeteer x Chromium support for ARM86 - installing dep!" && \ + curl https://playwright.azureedge.net/builds/chromium/1088/chromium-linux-arm64.zip -o chrome-linux.zip && \ + unzip chrome-linux.zip && \ + rm -rf chrome-linux.zip + +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true +ENV CHROME_PATH=/app/chrome-linux/chrome +ENV PUPPETEER_EXECUTABLE_PATH=/app/chrome-linux/chrome + +RUN echo "Done running arm64 specific installtion steps" + +############################################# + +# amd64-specific stage +FROM base AS build-amd64 +RUN echo "Preparing build of AnythingLLM image for non-ARM architecture" + +RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ + curl gnupg libgfortran5 libgbm1 tzdata netcat \ + libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 \ + libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libx11-6 libx11-xcb1 libxcb1 \ + libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 \ + libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release \ + xdg-utils git build-essential ffmpeg && \ + mkdir -p /etc/apt/keyrings && \ + curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ + echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \ + apt-get update && \ + apt-get install -yq --no-install-recommends nodejs && \ + curl -LO https://github.com/yarnpkg/yarn/releases/download/v1.22.19/yarn_1.22.19_all.deb \ + && dpkg -i yarn_1.22.19_all.deb \ + && rm yarn_1.22.19_all.deb + +# Create a group and user with specific UID and GID +RUN groupadd -g $ARG_GID anythingllm && \ + useradd -u $ARG_UID -m -d /app -s /bin/bash -g anythingllm anythingllm && \ + mkdir -p /app/frontend/ /app/server/ /app/collector/ && chown -R anythingllm:anythingllm /app + +# Copy docker helper scripts +COPY ./docker/docker-entrypoint.sh /usr/local/bin/ +COPY ./docker/docker-healthcheck.sh /usr/local/bin/ +COPY --chown=anythingllm:anythingllm ./docker/.env.example /app/server/.env + +# Ensure the scripts are executable +RUN chmod +x /usr/local/bin/docker-entrypoint.sh && \ + chmod +x /usr/local/bin/docker-healthcheck.sh +############################################# +# COMMON BUILD FLOW FOR ALL ARCHS +############################################# +FROM build-${TARGETARCH} AS build +RUN echo "Running common build flow of AnythingLLM image for all architectures" + +USER anythingllm WORKDIR /app # Install frontend dependencies -FROM base as frontend-deps +FROM build as frontend-deps COPY ./frontend/package.json ./frontend/yarn.lock ./frontend/ RUN cd ./frontend/ && yarn install --network-timeout 100000 && yarn cache clean # Install server dependencies -FROM base as server-deps +FROM build as server-deps COPY ./server/package.json ./server/yarn.lock ./server/ RUN cd ./server/ && yarn install --production --network-timeout 100000 && yarn cache clean @@ -93,4 +151,4 @@ HEALTHCHECK --interval=1m --timeout=10s --start-period=1m \ CMD /bin/bash /usr/local/bin/docker-healthcheck.sh || exit 1 # Run the server -ENTRYPOINT ["/bin/bash", "/usr/local/bin/docker-entrypoint.sh"] +ENTRYPOINT ["/bin/bash", "/usr/local/bin/docker-entrypoint.sh"] \ No newline at end of file diff --git a/docker/Dockerfile.old b/docker/Dockerfile.old new file mode 100644 index 00000000000..aaecfc495f4 --- /dev/null +++ b/docker/Dockerfile.old @@ -0,0 +1,96 @@ +# Setup base image +FROM ubuntu:jammy-20230522 AS base + +# Build arguments +ARG ARG_UID=1000 +ARG ARG_GID=1000 + +RUN echo "Building AnythingLLM image for non-ARM architecture" + +# Install system dependencies +RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ + curl gnupg libgfortran5 libgbm1 tzdata netcat \ + libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 \ + libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libx11-6 libx11-xcb1 libxcb1 \ + libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 \ + libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release \ + xdg-utils git build-essential ffmpeg && \ + mkdir -p /etc/apt/keyrings && \ + curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ + echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \ + apt-get update && \ + apt-get install -yq --no-install-recommends nodejs && \ + curl -LO https://github.com/yarnpkg/yarn/releases/download/v1.22.19/yarn_1.22.19_all.deb \ + && dpkg -i yarn_1.22.19_all.deb \ + && rm yarn_1.22.19_all.deb + +# Create a group and user with specific UID and GID +RUN groupadd -g $ARG_GID anythingllm && \ + useradd -u $ARG_UID -m -d /app -s /bin/bash -g anythingllm anythingllm && \ + mkdir -p /app/frontend/ /app/server/ /app/collector/ && chown -R anythingllm:anythingllm /app + +# Copy docker helper scripts +COPY ./docker/docker-entrypoint.sh /usr/local/bin/ +COPY ./docker/docker-healthcheck.sh /usr/local/bin/ +COPY --chown=anythingllm:anythingllm ./docker/.env.example /app/server/.env + +# Ensure the scripts are executable +RUN chmod +x /usr/local/bin/docker-entrypoint.sh && \ + chmod +x /usr/local/bin/docker-healthcheck.sh + +USER anythingllm + +WORKDIR /app + +# Install frontend dependencies +FROM base as frontend-deps + +COPY ./frontend/package.json ./frontend/yarn.lock ./frontend/ +RUN cd ./frontend/ && yarn install --network-timeout 100000 && yarn cache clean + +# Install server dependencies +FROM base as server-deps +COPY ./server/package.json ./server/yarn.lock ./server/ +RUN cd ./server/ && yarn install --production --network-timeout 100000 && yarn cache clean + +# Compile Llama.cpp bindings for node-llama-cpp for this operating system. +USER root +RUN cd ./server && npx --no node-llama-cpp download +USER anythingllm + +# Build the frontend +FROM frontend-deps as build-stage +COPY ./frontend/ ./frontend/ +RUN cd ./frontend/ && yarn build && yarn cache clean + +# Setup the server +FROM server-deps as production-stage +COPY --chown=anythingllm:anythingllm ./server/ ./server/ + +# Copy built static frontend files to the server public directory +COPY --from=build-stage /app/frontend/dist ./server/public + +# Copy the collector +COPY --chown=anythingllm:anythingllm ./collector/ ./collector/ + +# Install collector dependencies +RUN cd /app/collector && yarn install --production --network-timeout 100000 && yarn cache clean + +# Migrate and Run Prisma against known schema +RUN cd ./server && npx prisma generate --schema=./prisma/schema.prisma +RUN cd ./server && npx prisma migrate deploy --schema=./prisma/schema.prisma + +# Setup the environment +ENV NODE_ENV=production +ENV ANYTHING_LLM_RUNTIME=docker + +# Expose the server port +EXPOSE 3001 + +# Setup the healthcheck +HEALTHCHECK --interval=1m --timeout=10s --start-period=1m \ + CMD /bin/bash /usr/local/bin/docker-healthcheck.sh || exit 1 + +# Run the server +ENTRYPOINT ["/bin/bash", "/usr/local/bin/docker-entrypoint.sh"] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index a9909c620c7..d68af252c41 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -9,7 +9,8 @@ networks: services: anything-llm: container_name: anything-llm - platform: linux/amd64 # We will assume all docker compose builds are using x86 + platform: linux/amd64 # default composer builds for amd64 CPUs + # platform: linux/arm64 # to build for ARM-based CPUs image: anything-llm:latest build: context: ../. From 5a34eb5f39aa7a27fd7a162c4734deb82d9e7bca Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Sat, 6 Jan 2024 15:09:24 -0800 Subject: [PATCH 26/36] checkpoint for dual build image --- .github/workflows/build-and-push-image.yaml | 131 +------------------- docker/Dockerfile.arm64 | 111 ----------------- docker/Dockerfile.old | 96 -------------- docker/HOW_TO_USE_DOCKER.md | 34 +---- 4 files changed, 6 insertions(+), 366 deletions(-) delete mode 100644 docker/Dockerfile.arm64 delete mode 100644 docker/Dockerfile.old diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 0489b362571..6a5cbda6c2c 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -8,7 +8,7 @@ name: Publish AnythingLLM Primary Docker image on: push: - branches: ['master', 'arm64'] # master branch only. Do not modify. + branches: ['master'] # master branch only. Do not modify. paths-ignore: - '*.md' - 'cloud-deployments/*' @@ -25,16 +25,6 @@ jobs: steps: - name: Check out the repo uses: actions/checkout@v4 - - - name: Extract branch name - shell: bash - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT - id: extract_branch - - - name: downcase repository name - shell: bash - run: echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT - id: lowercase_repo - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -71,121 +61,4 @@ jobs: push: true platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - # push_amd64_to_registries: - # name: Push Docker linux/amd64 image to multiple registries - # runs-on: ubuntu-latest - # permissions: - # packages: write - # contents: read - # steps: - # - name: Check out the repo - # uses: actions/checkout@v4 - - # - name: Extract branch name - # shell: bash - # run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT - # id: extract_branch - - # - name: downcase repository name - # shell: bash - # run: echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT - # id: lowercase_repo - - # - name: Log in to Docker Hub - # uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a - # with: - # username: ${{ secrets.DOCKER_USERNAME }} - # password: ${{ secrets.DOCKER_PASSWORD }} - - # - name: Log in to the Container registry - # uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 - # with: - # registry: ghcr.io - # username: ${{ github.actor }} - # password: ${{ secrets.GITHUB_TOKEN }} - - # - name: Extract metadata (tags, labels) for Docker - # id: meta - # uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 - # with: - # images: | - # mintplexlabs/anythingllm - # ghcr.io/${{ github.repository }} - - # - name: Build and push linux/amd64 Docker image - # uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 - # with: - # context: . - # file: ./docker/Dockerfile - # push: true - # platforms: linux/amd64 - # tags: | - # ${{ steps.meta.outputs.tags }} - # # tags: | - # # ${{ steps.meta.outputs.tags }} - # # mintplexlabs/anythingllm:latest - # # ghcr.io/${{ steps.lowercase_repo.outputs.repo }}:latest - # labels: ${{ steps.meta.outputs.labels }} - - # push_arm64_to_registries: - # name: Push Docker linux/arm64 image to multiple registries - # runs-on: ubuntu-latest - # permissions: - # packages: write - # contents: read - # steps: - # - name: Check out the repo - # uses: actions/checkout@v4 - - # - name: Extract branch name - # shell: bash - # run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT - # id: extract_branch - - # - name: downcase repository name - # shell: bash - # run: echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT - # id: lowercase_repo - - # - name: Set up QEMU - # uses: docker/setup-qemu-action@v3 - - # - name: Set up Docker Buildx - # uses: docker/setup-buildx-action@v3 - - # - name: Log in to Docker Hub - # uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a - # with: - # username: ${{ secrets.DOCKER_USERNAME }} - # password: ${{ secrets.DOCKER_PASSWORD }} - - # - name: Log in to the Container registry - # uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 - # with: - # registry: ghcr.io - # username: ${{ github.actor }} - # password: ${{ secrets.GITHUB_TOKEN }} - - # - name: Extract metadata (tags, labels) for Docker - # id: meta - # uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 - # with: - # images: | - # mintplexlabs/anythingllm - # ghcr.io/${{ github.repository }} - - # - name: Build and push linux/arm64 Docker and GHCR images - # uses: docker/build-push-action@v5 - # with: - # context: . - # file: ./docker/Dockerfile.arm64 - # push: true - # platforms: linux/arm64 - # tags: | - # mintplexlabs/anythingllm:${{ steps.extract_branch.outputs.branch }}-arm64 - # ghcr.io/${{ steps.lowercase_repo.outputs.repo }}:${{ steps.extract_branch.outputs.branch }}-arm64 - # labels: ${{ steps.meta.outputs.labels }} - # build-args: | - # BUILDARCH=arm64 \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64 deleted file mode 100644 index 022a05bfad5..00000000000 --- a/docker/Dockerfile.arm64 +++ /dev/null @@ -1,111 +0,0 @@ -# Setup base image -FROM ubuntu:jammy-20230522 AS base - -# Build arguments -ARG ARG_UID=1000 -ARG ARG_GID=1000 -ARG BUILDARCH - -RUN if [ "$BUILDARCH" != "arm64" ] ; then echo "[ARCH INCOMPATIBLE] You can only run this Dockerfile on arm86 architecture - Aborting."; exit 1; fi -RUN echo "Building AnythingLLM image for $BUILDARCH architecture" - -# Install system dependencies -RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ - unzip curl gnupg libgfortran5 libgbm1 tzdata netcat \ - libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 \ - libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libx11-6 libx11-xcb1 libxcb1 \ - libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 \ - libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release \ - xdg-utils git build-essential ffmpeg && \ - mkdir -p /etc/apt/keyrings && \ - curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ - echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \ - apt-get update && \ - apt-get install -yq --no-install-recommends nodejs && \ - curl -LO https://github.com/yarnpkg/yarn/releases/download/v1.22.19/yarn_1.22.19_all.deb \ - && dpkg -i yarn_1.22.19_all.deb \ - && rm yarn_1.22.19_all.deb - -# Create a group and user with specific UID and GID -RUN groupadd -g $ARG_GID anythingllm && \ - useradd -u $ARG_UID -m -d /app -s /bin/bash -g anythingllm anythingllm && \ - mkdir -p /app/frontend/ /app/server/ /app/collector/ && chown -R anythingllm:anythingllm /app - -# Copy docker helper scripts -COPY ./docker/docker-entrypoint.sh /usr/local/bin/ -COPY ./docker/docker-healthcheck.sh /usr/local/bin/ -COPY --chown=anythingllm:anythingllm ./docker/.env.example /app/server/.env - -# Ensure the scripts are executable -RUN chmod +x /usr/local/bin/docker-entrypoint.sh && \ - chmod +x /usr/local/bin/docker-healthcheck.sh - -USER anythingllm - -WORKDIR /app - -# Puppeteer does not ship with an ARM86 compatible build for Chromium -# so web-scraping would be broken in arm docker containers unless we patch it -# by manually installing a compatible chromedriver. -RUN if [ "$BUILDARCH" = "arm64" ] ; then \ - echo "Need to patch Puppeteer x Chromium support for ARM86 - installing dep!" && \ - curl https://playwright.azureedge.net/builds/chromium/1088/chromium-linux-arm64.zip -o chrome-linux.zip && \ - unzip chrome-linux.zip && \ - rm -rf chrome-linux.zip; \ -fi - -# Install frontend dependencies -FROM base as frontend-deps - -COPY ./frontend/package.json ./frontend/yarn.lock ./frontend/ -RUN cd ./frontend/ && yarn install --network-timeout 100000 && yarn cache clean - -# Install server dependencies -FROM base as server-deps -COPY ./server/package.json ./server/yarn.lock ./server/ -RUN cd ./server/ && yarn install --production --network-timeout 100000 && yarn cache clean - -# Compile Llama.cpp bindings for node-llama-cpp for this operating system. -USER root -RUN cd ./server && npx --no node-llama-cpp download -USER anythingllm - -# Build the frontend -FROM frontend-deps as build-stage -COPY ./frontend/ ./frontend/ -RUN cd ./frontend/ && yarn build && yarn cache clean - -# Setup the server -FROM server-deps as production-stage -COPY --chown=anythingllm:anythingllm ./server/ ./server/ - -# Copy built static frontend files to the server public directory -COPY --from=build-stage /app/frontend/dist ./server/public - -# Copy the collector -COPY --chown=anythingllm:anythingllm ./collector/ ./collector/ - -ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true -ENV CHROME_PATH=/app/chrome-linux/chrome -ENV PUPPETEER_EXECUTABLE_PATH=/app/chrome-linux/chrome - -RUN cd /app/collector && yarn install --production && yarn cache clean - -# Migrate and Run Prisma against known schema -RUN cd ./server && npx prisma generate --schema=./prisma/schema.prisma -RUN cd ./server && npx prisma migrate deploy --schema=./prisma/schema.prisma - -# Setup the environment -ENV NODE_ENV=production -ENV ANYTHING_LLM_RUNTIME=docker - -# Expose the server port -EXPOSE 3001 - -# Setup the healthcheck -HEALTHCHECK --interval=1m --timeout=10s --start-period=1m \ - CMD /bin/bash /usr/local/bin/docker-healthcheck.sh || exit 1 - -# Run the server -ENTRYPOINT ["/bin/bash", "/usr/local/bin/docker-entrypoint.sh"] \ No newline at end of file diff --git a/docker/Dockerfile.old b/docker/Dockerfile.old deleted file mode 100644 index aaecfc495f4..00000000000 --- a/docker/Dockerfile.old +++ /dev/null @@ -1,96 +0,0 @@ -# Setup base image -FROM ubuntu:jammy-20230522 AS base - -# Build arguments -ARG ARG_UID=1000 -ARG ARG_GID=1000 - -RUN echo "Building AnythingLLM image for non-ARM architecture" - -# Install system dependencies -RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ - curl gnupg libgfortran5 libgbm1 tzdata netcat \ - libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 \ - libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libx11-6 libx11-xcb1 libxcb1 \ - libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 \ - libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release \ - xdg-utils git build-essential ffmpeg && \ - mkdir -p /etc/apt/keyrings && \ - curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ - echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \ - apt-get update && \ - apt-get install -yq --no-install-recommends nodejs && \ - curl -LO https://github.com/yarnpkg/yarn/releases/download/v1.22.19/yarn_1.22.19_all.deb \ - && dpkg -i yarn_1.22.19_all.deb \ - && rm yarn_1.22.19_all.deb - -# Create a group and user with specific UID and GID -RUN groupadd -g $ARG_GID anythingllm && \ - useradd -u $ARG_UID -m -d /app -s /bin/bash -g anythingllm anythingllm && \ - mkdir -p /app/frontend/ /app/server/ /app/collector/ && chown -R anythingllm:anythingllm /app - -# Copy docker helper scripts -COPY ./docker/docker-entrypoint.sh /usr/local/bin/ -COPY ./docker/docker-healthcheck.sh /usr/local/bin/ -COPY --chown=anythingllm:anythingllm ./docker/.env.example /app/server/.env - -# Ensure the scripts are executable -RUN chmod +x /usr/local/bin/docker-entrypoint.sh && \ - chmod +x /usr/local/bin/docker-healthcheck.sh - -USER anythingllm - -WORKDIR /app - -# Install frontend dependencies -FROM base as frontend-deps - -COPY ./frontend/package.json ./frontend/yarn.lock ./frontend/ -RUN cd ./frontend/ && yarn install --network-timeout 100000 && yarn cache clean - -# Install server dependencies -FROM base as server-deps -COPY ./server/package.json ./server/yarn.lock ./server/ -RUN cd ./server/ && yarn install --production --network-timeout 100000 && yarn cache clean - -# Compile Llama.cpp bindings for node-llama-cpp for this operating system. -USER root -RUN cd ./server && npx --no node-llama-cpp download -USER anythingllm - -# Build the frontend -FROM frontend-deps as build-stage -COPY ./frontend/ ./frontend/ -RUN cd ./frontend/ && yarn build && yarn cache clean - -# Setup the server -FROM server-deps as production-stage -COPY --chown=anythingllm:anythingllm ./server/ ./server/ - -# Copy built static frontend files to the server public directory -COPY --from=build-stage /app/frontend/dist ./server/public - -# Copy the collector -COPY --chown=anythingllm:anythingllm ./collector/ ./collector/ - -# Install collector dependencies -RUN cd /app/collector && yarn install --production --network-timeout 100000 && yarn cache clean - -# Migrate and Run Prisma against known schema -RUN cd ./server && npx prisma generate --schema=./prisma/schema.prisma -RUN cd ./server && npx prisma migrate deploy --schema=./prisma/schema.prisma - -# Setup the environment -ENV NODE_ENV=production -ENV ANYTHING_LLM_RUNTIME=docker - -# Expose the server port -EXPOSE 3001 - -# Setup the healthcheck -HEALTHCHECK --interval=1m --timeout=10s --start-period=1m \ - CMD /bin/bash /usr/local/bin/docker-healthcheck.sh || exit 1 - -# Run the server -ENTRYPOINT ["/bin/bash", "/usr/local/bin/docker-entrypoint.sh"] diff --git a/docker/HOW_TO_USE_DOCKER.md b/docker/HOW_TO_USE_DOCKER.md index 7117b6c0bd5..81a3cd83535 100644 --- a/docker/HOW_TO_USE_DOCKER.md +++ b/docker/HOW_TO_USE_DOCKER.md @@ -29,37 +29,11 @@ Use the Dockerized version of AnythingLLM for a much faster and complete startup > It is best to mount the containers storage volume to a folder on your host machine > so that you can pull in future updates without deleting your existing data! - - - - - - - - - - - - -
Pull in the correct image for your system
- (default) amd64 / x86 - - -```shell -docker pull mintplexlabs/anythingllm:master -``` - -
- arm64 / Apple Silicon - - +Pull in the latest image from docker. Supports both `amd64` and `arm64` CPU architectures. ```shell -# Keep in mind your tag is `master-arm64`! -docker pull mintplexlabs/anythingllm:master-arm64 +docker pull mintplexlabs/anythingllm ``` -
- @@ -79,7 +53,7 @@ docker run -d -p 3001:3001 \ -v ${STORAGE_LOCATION}:/app/server/storage \ -v ${STORAGE_LOCATION}/.env:/app/server/.env \ -e STORAGE_DIR="/app/server/storage" \ -mintplexlabs/anythingllm:master +mintplexlabs/anythingllm ``` @@ -100,7 +74,7 @@ docker run -d -p 3001:3001 ` -v "$env:STORAGE_LOCATION`:/app/server/storage" ` -v "$env:STORAGE_LOCATION\.env:/app/server/.env" ` -e STORAGE_DIR="/app/server/storage" ` -mintplexlabs/anythingllm:master; +mintplexlabs/anythingllm; ``` From 7ea464100c80a8d36b2570e120948e4945c3192b Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Sat, 6 Jan 2024 15:10:36 -0800 Subject: [PATCH 27/36] update job runner --- .github/workflows/build-and-push-image.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 6a5cbda6c2c..9a1a9b9aa7d 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -4,7 +4,7 @@ # TODO: Update `runs-on` for arm64 when GitHub finally supports # native arm environments as QEMU takes around 1 hour to build # ref: https://github.com/actions/runner-images/issues/5631 :( -name: Publish AnythingLLM Primary Docker image +name: Publish AnythingLLM Primary Docker image (amd64/arm64) on: push: @@ -16,7 +16,7 @@ on: - '.vscode/*' jobs: - push_amd64_to_registries: + push_multi_platform_to_registries: name: Push Docker multi-platform image to multiple registries runs-on: ubuntu-latest permissions: From df221ab21ca0b271159a2808e05fa235779ce1ed Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Sat, 6 Jan 2024 15:20:13 -0800 Subject: [PATCH 28/36] test concurrency --- .github/workflows/build-and-push-image.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 9a1a9b9aa7d..32a5d7d58e3 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -6,9 +6,13 @@ # ref: https://github.com/actions/runner-images/issues/5631 :( name: Publish AnythingLLM Primary Docker image (amd64/arm64) +concurrency: + group: build-${{ github.ref }} + cancel-in-progress: true + on: push: - branches: ['master'] # master branch only. Do not modify. + branches: ['master', 'arm64'] # master branch only. Do not modify. paths-ignore: - '*.md' - 'cloud-deployments/*' From c86937e0fd6467d07c411cce7daa3dcc477561d4 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Sat, 6 Jan 2024 15:20:57 -0800 Subject: [PATCH 29/36] remove clean.sh script --- clean.sh | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 clean.sh diff --git a/clean.sh b/clean.sh deleted file mode 100644 index 966cc177317..00000000000 --- a/clean.sh +++ /dev/null @@ -1,3 +0,0 @@ -# Easily kill process on port because sometimes nodemon fails to reboot -kill -9 $(lsof -t -i tcp:5000) & -kill -9 $(lsof -t -i tcp:3001) # if running default for MacOS Monterey From 2101801da30b6b6d4817f9ccb2ce86016a7eea92 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Sat, 6 Jan 2024 15:21:54 -0800 Subject: [PATCH 30/36] remove test branch --- .github/workflows/build-and-push-image.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 32a5d7d58e3..9cb65c04051 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -12,7 +12,7 @@ concurrency: on: push: - branches: ['master', 'arm64'] # master branch only. Do not modify. + branches: ['master'] # master branch only. Do not modify. paths-ignore: - '*.md' - 'cloud-deployments/*' From 922f244f506fd23eca8a4843db218b3e1a8809fe Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Mon, 8 Jan 2024 14:01:32 -0800 Subject: [PATCH 31/36] wip: latest tag --- .github/workflows/build-and-push-image.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 9cb65c04051..549e53d5101 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -12,7 +12,7 @@ concurrency: on: push: - branches: ['master'] # master branch only. Do not modify. + branches: ['master', 'arm64'] # master branch only. Do not modify. paths-ignore: - '*.md' - 'cloud-deployments/*' @@ -63,6 +63,10 @@ jobs: context: . file: ./docker/Dockerfile push: true - platforms: linux/amd64,linux/arm64 - tags: ${{ steps.meta.outputs.tags }} + # platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 + tags: | + ${{ steps.meta.outputs.tags }} + mintplexlabs/anythingllm:dev + ghcr.io/${{ github.repository }}:dev labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From 8a172438c0bf82a7fbf62f296b251f29cd9596d7 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Mon, 8 Jan 2024 14:14:52 -0800 Subject: [PATCH 32/36] wip: latest tag --- .github/workflows/build-and-push-image.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 549e53d5101..54757bb4d52 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -30,6 +30,11 @@ jobs: - name: Check out the repo uses: actions/checkout@v4 + - name: downcase repository name + shell: bash + run: echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT + id: lowercase_repo + - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -67,6 +72,6 @@ jobs: platforms: linux/amd64 tags: | ${{ steps.meta.outputs.tags }} - mintplexlabs/anythingllm:dev - ghcr.io/${{ github.repository }}:dev + ${{ github.ref_name == 'master' && 'mintplexlabs/anythingllm:dev' || '' }} + ${{ github.ref_name == 'master' && format('ghcr.io/{0}:{1}', steps.lowercase_repo.outputs.repo, 'dev') || '' }} labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From 00003cee090e2aca8f7b00078354d44309b15beb Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Mon, 8 Jan 2024 14:19:56 -0800 Subject: [PATCH 33/36] add dev branch --- .github/workflows/build-and-push-image.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 54757bb4d52..6fb25575e87 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -72,6 +72,6 @@ jobs: platforms: linux/amd64 tags: | ${{ steps.meta.outputs.tags }} - ${{ github.ref_name == 'master' && 'mintplexlabs/anythingllm:dev' || '' }} - ${{ github.ref_name == 'master' && format('ghcr.io/{0}:{1}', steps.lowercase_repo.outputs.repo, 'dev') || '' }} + ${{ github.ref_name == 'arm64' && 'mintplexlabs/anythingllm:dev' || '' }} + ${{ github.ref_name == 'arm64' && format('ghcr.io/{0}:{1}', steps.lowercase_repo.outputs.repo, 'dev') || '' }} labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From 358d82b7d8b2e6cc97daa854dba3ff683bc0672a Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Mon, 8 Jan 2024 14:26:15 -0800 Subject: [PATCH 34/36] verified conditional latest tagging on master only --- .github/workflows/build-and-push-image.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 6fb25575e87..9f794fc306f 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -68,10 +68,9 @@ jobs: context: . file: ./docker/Dockerfile push: true - # platforms: linux/amd64,linux/arm64 - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64 tags: | ${{ steps.meta.outputs.tags }} - ${{ github.ref_name == 'arm64' && 'mintplexlabs/anythingllm:dev' || '' }} - ${{ github.ref_name == 'arm64' && format('ghcr.io/{0}:{1}', steps.lowercase_repo.outputs.repo, 'dev') || '' }} + ${{ github.ref_name == 'master' && 'mintplexlabs/anythingllm:latest' || '' }} + ${{ github.ref_name == 'master' && format('ghcr.io/{0}:{1}', steps.lowercase_repo.outputs.repo, 'latest') || '' }} labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From ad3da99d7eeeb9b59082aa5ce8ea51fc7e61ebcb Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Mon, 8 Jan 2024 14:36:30 -0800 Subject: [PATCH 35/36] ready for merge --- .github/workflows/build-and-push-image.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-push-image.yaml b/.github/workflows/build-and-push-image.yaml index 9f794fc306f..2ced54c2cfa 100644 --- a/.github/workflows/build-and-push-image.yaml +++ b/.github/workflows/build-and-push-image.yaml @@ -12,7 +12,7 @@ concurrency: on: push: - branches: ['master', 'arm64'] # master branch only. Do not modify. + branches: ['master'] # master branch only. Do not modify. paths-ignore: - '*.md' - 'cloud-deployments/*' @@ -30,7 +30,7 @@ jobs: - name: Check out the repo uses: actions/checkout@v4 - - name: downcase repository name + - name: Parse repository name to lowercase shell: bash run: echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT id: lowercase_repo From 104278af69e0e46295236309eb65b24fe40bdb83 Mon Sep 17 00:00:00 2001 From: shatfield4 Date: Mon, 8 Jan 2024 15:43:04 -0800 Subject: [PATCH 36/36] remove platform option from docker-compose.yml --- docker/docker-compose.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index d68af252c41..313e4175b03 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.9' +version: "3.9" name: anythingllm @@ -9,8 +9,6 @@ networks: services: anything-llm: container_name: anything-llm - platform: linux/amd64 # default composer builds for amd64 CPUs - # platform: linux/arm64 # to build for ARM-based CPUs image: anything-llm:latest build: context: ../.
Mount the storage locally and run AnythingLLM in Docker