build: Improve docker caching (#2140)

* build: Improve docker caching

* more fixes
This commit is contained in:
Mohamed Bassem
2025-11-16 12:09:14 +00:00
committed by GitHub
parent 12d09a7411
commit 6cccb9f197
5 changed files with 100 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
Dockerfile
.dockerignore
node_modules
**/node_modules
npm-debug.log
README.md
**/.next
@@ -17,7 +17,7 @@ charts
apps/mobile
apps/landing
apps/browser-extension
pacakges/e2e_tests
packages/e2e_tests
# Aider
.aider*

View File

@@ -60,8 +60,8 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ matrix.tags_latest }}
cache-from: type=registry,ref=ghcr.io/hoarder-app/hoarder-build-cache:${{ matrix.target }}
cache-to: type=registry,mode=max,ref=ghcr.io/hoarder-app/hoarder-build-cache:${{ matrix.target }}
cache-from: type=registry,ref=ghcr.io/karakeep-app/karakeep-build-cache:${{ matrix.target }}
cache-to: type=registry,mode=max,ref=ghcr.io/karakeep-app/karakeep-build-cache:${{ matrix.target }}
- name: Build ${{ matrix.name }} (release)
uses: docker/build-push-action@v5
@@ -74,5 +74,5 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ matrix.tags_release }}
cache-from: type=registry,ref=ghcr.io/hoarder-app/hoarder-build-cache:${{ matrix.target }}
cache-to: type=registry,mode=max,ref=ghcr.io/hoarder-app/hoarder-build-cache:${{ matrix.target }}
cache-from: type=registry,ref=ghcr.io/karakeep-app/karakeep-build-cache:${{ matrix.target }}
cache-to: type=registry,mode=max,ref=ghcr.io/karakeep-app/karakeep-build-cache:${{ matrix.target }}

View File

@@ -11,14 +11,37 @@ RUN npm install -g corepack@0.31.0 && corepack enable
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat make g++ py3-pip linux-headers
COPY . .
# Copy package files for dependency installation
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
COPY apps/cli/package.json ./apps/cli/
COPY apps/mcp/package.json ./apps/mcp/
COPY apps/web/package.json ./apps/web/
COPY apps/workers/package.json ./apps/workers/
COPY packages/api/package.json ./packages/api/
COPY packages/db/package.json ./packages/db/
COPY packages/open-api/package.json ./packages/open-api/
COPY packages/plugins/package.json ./packages/plugins/
COPY packages/sdk/package.json ./packages/sdk/
COPY packages/shared-react/package.json ./packages/shared-react/
COPY packages/shared-server/package.json ./packages/shared-server/
COPY packages/shared/package.json ./packages/shared/
COPY packages/trpc/package.json ./packages/trpc/
COPY tooling/github/package.json ./tooling/github/
COPY tooling/oxlint/package.json ./tooling/oxlint/
COPY tooling/prettier/package.json ./tooling/prettier/
COPY tooling/tailwind/package.json ./tooling/tailwind/
COPY tooling/typescript/package.json ./tooling/typescript/
COPY ./patches ./patches
ENV NEXT_TELEMETRY_DISABLED 1
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
RUN pnpm install --frozen-lockfile
COPY . .
# Build the db migration script
RUN cd packages/db && \
pnpm dlx @vercel/ncc build migrate.ts -o /db_migrations && \
pnpm exec ncc build migrate.ts -o /db_migrations && \
cp -R drizzle /db_migrations

View File

@@ -29,7 +29,8 @@
"@karakeep/prettier-config": "workspace:^0.1.0",
"@karakeep/tsconfig": "workspace:^0.1.0",
"@tsconfig/node22": "^22.0.0",
"@types/better-sqlite3": "^7.6.11"
"@types/better-sqlite3": "^7.6.11",
"@vercel/ncc": "^0.38.4"
},
"prettier": "@karakeep/prettier-config"
}

68
pnpm-lock.yaml generated
View File

@@ -1088,6 +1088,9 @@ importers:
'@types/better-sqlite3':
specifier: ^7.6.11
version: 7.6.13
'@vercel/ncc':
specifier: ^0.38.4
version: 0.38.4
packages/e2e_tests:
dependencies:
@@ -1281,7 +1284,7 @@ importers:
version: 19.1.0
react-native:
specifier: 0.79.5
version: 0.79.5(@babel/core@7.28.0)(@types/react@19.2.2)(react@19.1.0)
version: 0.79.5(@babel/core@7.26.0)(@types/react@19.2.2)(react@19.1.0)
superjson:
specifier: ^2.2.1
version: 2.2.1
@@ -6025,6 +6028,10 @@ packages:
peerDependencies:
'@urql/core': ^5.0.0
'@vercel/ncc@0.38.4':
resolution: {integrity: sha512-8LwjnlP39s08C08J5NstzriPvW1SP8Zfpp1BvC2sI35kPeZnHfxVkCwu4/+Wodgnd60UtT1n8K8zw+Mp7J9JmQ==}
hasBin: true
'@vitejs/plugin-react-swc@4.0.1':
resolution: {integrity: sha512-NQhPjysi5duItyrMd5JWZFf2vNOuSMyw+EoZyTBDzk+DkfYD8WNrsUs09sELV2cr1P15nufsN25hsUBt4CKF9Q==}
engines: {node: ^20.19.0 || >=22.12.0}
@@ -19847,6 +19854,15 @@ snapshots:
optionalDependencies:
'@types/react': 19.1.8
'@react-native/virtualized-lists@0.79.5(@types/react@19.2.2)(react-native@0.79.5(@babel/core@7.26.0)(@types/react@19.2.2)(react@19.1.0))(react@19.1.0)':
dependencies:
invariant: 2.2.4
nullthrows: 1.1.1
react: 19.1.0
react-native: 0.79.5(@babel/core@7.26.0)(@types/react@19.2.2)(react@19.1.0)
optionalDependencies:
'@types/react': 19.2.2
'@react-native/virtualized-lists@0.79.5(@types/react@19.2.2)(react-native@0.79.5(@babel/core@7.28.0)(@types/react@19.2.2)(react@19.1.0))(react@19.1.0)':
dependencies:
invariant: 2.2.4
@@ -21185,6 +21201,8 @@ snapshots:
'@urql/core': 5.1.1
wonka: 6.3.5
'@vercel/ncc@0.38.4': {}
'@vitejs/plugin-react-swc@4.0.1(vite@7.0.6(@types/node@22.15.30)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.1)(terser@5.41.0)(tsx@4.20.3)(yaml@2.8.0))':
dependencies:
'@rolldown/pluginutils': 1.0.0-beta.32
@@ -29001,6 +29019,54 @@ snapshots:
- supports-color
- utf-8-validate
react-native@0.79.5(@babel/core@7.26.0)(@types/react@19.2.2)(react@19.1.0):
dependencies:
'@jest/create-cache-key-function': 29.7.0
'@react-native/assets-registry': 0.79.5
'@react-native/codegen': 0.79.5(@babel/core@7.26.0)
'@react-native/community-cli-plugin': 0.79.5
'@react-native/gradle-plugin': 0.79.5
'@react-native/js-polyfills': 0.79.5
'@react-native/normalize-colors': 0.79.5
'@react-native/virtualized-lists': 0.79.5(@types/react@19.2.2)(react-native@0.79.5(@babel/core@7.26.0)(@types/react@19.2.2)(react@19.1.0))(react@19.1.0)
abort-controller: 3.0.0
anser: 1.4.10
ansi-regex: 5.0.1
babel-jest: 29.7.0(@babel/core@7.26.0)
babel-plugin-syntax-hermes-parser: 0.25.1
base64-js: 1.5.1
chalk: 4.1.2
commander: 12.1.0
event-target-shim: 5.0.1
flow-enums-runtime: 0.0.6
glob: 7.2.3
invariant: 2.2.4
jest-environment-node: 29.7.0
memoize-one: 5.2.1
metro-runtime: 0.82.5
metro-source-map: 0.82.5
nullthrows: 1.1.1
pretty-format: 29.7.0
promise: 8.3.0
react: 19.1.0
react-devtools-core: 6.1.5
react-refresh: 0.14.2
regenerator-runtime: 0.13.11
scheduler: 0.25.0
semver: 7.7.3
stacktrace-parser: 0.1.11
whatwg-fetch: 3.6.20
ws: 6.2.3
yargs: 17.7.2
optionalDependencies:
'@types/react': 19.2.2
transitivePeerDependencies:
- '@babel/core'
- '@react-native-community/cli'
- bufferutil
- supports-color
- utf-8-validate
react-native@0.79.5(@babel/core@7.28.0)(@types/react@19.2.2)(react@19.1.0):
dependencies:
'@jest/create-cache-key-function': 29.7.0