From 0792255700ab724da272acc24045a1495e28a800 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Tue, 16 Dec 2025 18:54:34 -0300 Subject: [PATCH 1/2] fix: no amd64 binaries on manual installation --- .github/actions/build-docker/action.yml | 20 +++++++++++++++----- .github/actions/setup-node/action.yml | 4 ++-- .yarnrc.yml | 10 ++++++++++ apps/meteor/.docker/Dockerfile.alpine | 9 +-------- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/.github/actions/build-docker/action.yml b/.github/actions/build-docker/action.yml index b00709834c389..b24fffd4c79f0 100644 --- a/.github/actions/build-docker/action.yml +++ b/.github/actions/build-docker/action.yml @@ -75,14 +75,24 @@ runs: set -o xtrace export DENO_VERSION="${{ inputs.deno-version }}" - # Removes unnecessary swc cores to reduce image sized + # Removes unnecessary swc cores and sharp binaries to reduce image size swc_arch='x64' - if [[ "${{ inputs.service }}" == 'rocketchat' ]]; then - if [[ "${{ inputs.arch }}" == 'arm64' ]]; then - swc_arch='arm64' - fi + if [[ "${{ inputs.arch }}" == 'arm64' ]]; then + swc_arch='arm64' + fi + if [[ "${{ inputs.service }}" == 'rocketchat' ]]; then find /tmp/build/bundle/programs/server/npm/node_modules/meteor/babel-compiler/node_modules/@meteorjs/swc-core/.swc/node_modules/@swc -type d -name 'core-*' -not -name "*linux-${swc_arch}-gnu*" -exec rm -rf {} + + + find /tmp/build/bundle/programs/server/npm/node_modules/@img -type d -name 'sharp-*' -not -name "*-linuxmusl-${swc_arch}" -exec rm -rf {} + + + find /tmp/build/bundle/programs/server/npm/node_modules/@napi-rs -type d -name 'pinyin-linux-*' -not -name "*-linux-${swc_arch}-*" -exec rm -rf {} + + + find /tmp/build/bundle/programs/server/npm/node_modules/@rocket.chat/apps-engine/node_modules/@esbuild -type d -name 'linux-*' -not -name "*-${swc_arch}" -exec rm -rf {} + + fi + + if [[ "${{ inputs.service }}" == 'ddp-streamer-service' ]]; then + find /tmp/build/bundle/programs/server/npm/node_modules/@img -type d -name 'sharp-*' -not -name "*-linuxmusl-${swc_arch}" -exec rm -rf {} + fi if [[ "${{ inputs.publish-image }}" == 'true' ]]; then diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml index 2bee636a47835..ac0a52aae2af9 100644 --- a/.github/actions/setup-node/action.yml +++ b/.github/actions/setup-node/action.yml @@ -51,8 +51,8 @@ runs: apps/meteor/ee/server/services/node_modules packages/apps-engine/node_modules packages/apps-engine/.deno-cache - key: node-modules-${{ inputs.type }}-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }}-deno-v${{ inputs.deno-version }}-${{ hashFiles('packages/apps-engine/deno-runtime/deno.lock') }}-v3 - # key: node-modules-${{ inputs.type }}-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }}-deno-v${{ inputs.deno-version }}-${{ hashFiles('packages/apps-engine/deno-runtime/deno.lock') }}-v${{ github.run_id }} + key: node-modules-${{ inputs.type }}-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }}-${{ hashFiles('.yarnrc.yml') }}-deno-v${{ inputs.deno-version }}-${{ hashFiles('packages/apps-engine/deno-runtime/deno.lock') }}-v3 + # key: node-modules-${{ inputs.type }}-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }}-${{ hashFiles('.yarnrc.yml') }}-deno-v${{ inputs.deno-version }}-${{ hashFiles('packages/apps-engine/deno-runtime/deno.lock') }}-v${{ github.run_id }} # # Could use this command to list all paths to save: # find . -name 'node_modules' -prune | grep -v "/\.meteor/" | grep -v "/meteor/packages/" diff --git a/.yarnrc.yml b/.yarnrc.yml index de41a1b237219..197e9e04c1193 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -13,3 +13,13 @@ plugins: spec: "https://raw.githubusercontent.com/devoto13/yarn-plugin-engines/main/bundles/%40yarnpkg/plugin-engines.js" yarnPath: .yarn/releases/yarn-4.11.0.cjs + +supportedArchitectures: + os: + - "current" + cpu: + - "current" + - "x64" + libc: + - "current" + - "musl" diff --git a/apps/meteor/.docker/Dockerfile.alpine b/apps/meteor/.docker/Dockerfile.alpine index dbdeb5abc6391..3761e501dcb00 100644 --- a/apps/meteor/.docker/Dockerfile.alpine +++ b/apps/meteor/.docker/Dockerfile.alpine @@ -9,14 +9,7 @@ COPY . /app ENV NODE_ENV=production RUN cd /app/bundle/programs/server \ - && npm install --omit=dev \ - # Re install sharp dependencies to ensure proper binary for architecture - # We only need the @img folder from sharp dependencies - && cd /app/bundle/programs/server/npm/node_modules/sharp \ - && npm install --omit=dev \ - && rm -rf ../@img \ - && mv node_modules/@img ../@img \ - && rm -rf node_modules + && npm install --omit=dev FROM node:22.16.0-alpine3.20 From 76f1db934d4ee21b33f866c57bef4f7fbcd32dac Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Wed, 17 Dec 2025 11:59:21 -0300 Subject: [PATCH 2/2] Use config as command line parameter --- .github/actions/build-docker/action.yml | 14 ++++++-------- .github/actions/setup-node/action.yml | 8 +++++++- .yarnrc.yml | 10 ---------- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/.github/actions/build-docker/action.yml b/.github/actions/build-docker/action.yml index b24fffd4c79f0..5100528ac7ae0 100644 --- a/.github/actions/build-docker/action.yml +++ b/.github/actions/build-docker/action.yml @@ -77,22 +77,20 @@ runs: # Removes unnecessary swc cores and sharp binaries to reduce image size swc_arch='x64' - if [[ "${{ inputs.arch }}" == 'arm64' ]]; then - swc_arch='arm64' - fi - if [[ "${{ inputs.service }}" == 'rocketchat' ]]; then + if [[ "${{ inputs.arch }}" == 'arm64' ]]; then + swc_arch='arm64' + fi + find /tmp/build/bundle/programs/server/npm/node_modules/meteor/babel-compiler/node_modules/@meteorjs/swc-core/.swc/node_modules/@swc -type d -name 'core-*' -not -name "*linux-${swc_arch}-gnu*" -exec rm -rf {} + find /tmp/build/bundle/programs/server/npm/node_modules/@img -type d -name 'sharp-*' -not -name "*-linuxmusl-${swc_arch}" -exec rm -rf {} + find /tmp/build/bundle/programs/server/npm/node_modules/@napi-rs -type d -name 'pinyin-linux-*' -not -name "*-linux-${swc_arch}-*" -exec rm -rf {} + - find /tmp/build/bundle/programs/server/npm/node_modules/@rocket.chat/apps-engine/node_modules/@esbuild -type d -name 'linux-*' -not -name "*-${swc_arch}" -exec rm -rf {} + - fi + find /tmp/build/bundle/programs/server/npm/node_modules/@esbuild -type d -name 'linux-*' -not -name "*-${swc_arch}" -exec rm -rf {} + - if [[ "${{ inputs.service }}" == 'ddp-streamer-service' ]]; then - find /tmp/build/bundle/programs/server/npm/node_modules/@img -type d -name 'sharp-*' -not -name "*-linuxmusl-${swc_arch}" -exec rm -rf {} + + find /tmp/build/bundle/programs/server/npm/node_modules/@rocket.chat/apps-engine/node_modules/@esbuild -type d -name 'linux-*' -not -name "*-${swc_arch}" -exec rm -rf {} + fi if [[ "${{ inputs.publish-image }}" == 'true' ]]; then diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml index ac0a52aae2af9..faa3f6d7ed17d 100644 --- a/.github/actions/setup-node/action.yml +++ b/.github/actions/setup-node/action.yml @@ -51,7 +51,7 @@ runs: apps/meteor/ee/server/services/node_modules packages/apps-engine/node_modules packages/apps-engine/.deno-cache - key: node-modules-${{ inputs.type }}-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }}-${{ hashFiles('.yarnrc.yml') }}-deno-v${{ inputs.deno-version }}-${{ hashFiles('packages/apps-engine/deno-runtime/deno.lock') }}-v3 + key: node-modules-${{ inputs.type }}-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }}-${{ hashFiles('.yarnrc.yml') }}-deno-v${{ inputs.deno-version }}-${{ hashFiles('packages/apps-engine/deno-runtime/deno.lock') }}-v5 # key: node-modules-${{ inputs.type }}-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }}-${{ hashFiles('.yarnrc.yml') }}-deno-v${{ inputs.deno-version }}-${{ hashFiles('packages/apps-engine/deno-runtime/deno.lock') }}-v${{ github.run_id }} # # Could use this command to list all paths to save: @@ -75,6 +75,12 @@ runs: run: | echo "//registry.npmjs.org/:_authToken=${{ inputs.NPM_TOKEN }}" > ~/.npmrc + - name: yarn config + if: inputs.install + shell: bash + run: | + yarn config set supportedArchitectures --json '{"os": ["linux"], "cpu": ["arm64", "x64"], "libc": ["glibc", "musl"]}' + - name: yarn install if: inputs.install && inputs.type == 'development' shell: bash diff --git a/.yarnrc.yml b/.yarnrc.yml index 197e9e04c1193..de41a1b237219 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -13,13 +13,3 @@ plugins: spec: "https://raw.githubusercontent.com/devoto13/yarn-plugin-engines/main/bundles/%40yarnpkg/plugin-engines.js" yarnPath: .yarn/releases/yarn-4.11.0.cjs - -supportedArchitectures: - os: - - "current" - cpu: - - "current" - - "x64" - libc: - - "current" - - "musl"