chore: update Dockerfile pnpm version

This commit is contained in:
Henry
2024-05-07 14:10:13 +01:00
parent b21c8d6300
commit 6178d92e39
+60 -61
View File
@@ -7,13 +7,13 @@ WORKDIR /app
# place ARG statement before RUN statement which need it to avoid cache miss
ARG USE_CHINA_NPM_REGISTRY=0
RUN \
set -ex && \
if [ "$USE_CHINA_NPM_REGISTRY" = 1 ]; then \
echo 'use npm mirror' && \
npm config set registry https://registry.npmmirror.com && \
yarn config set registry https://registry.npmmirror.com && \
pnpm config set registry https://registry.npmmirror.com ; \
fi;
set -ex &&
if [ "$USE_CHINA_NPM_REGISTRY" = 1 ]; then
echo 'use npm mirror' &&
npm config set registry https://registry.npmmirror.com &&
yarn config set registry https://registry.npmmirror.com &&
pnpm config set registry https://registry.npmmirror.com
fi
COPY ./tsconfig.json /app/
COPY ./pnpm-lock.yaml /app/
@@ -21,10 +21,10 @@ COPY ./package.json /app/
# lazy install Chromium to avoid cache miss, only install production dependencies to minimize the image size
RUN \
set -ex && \
export PUPPETEER_SKIP_DOWNLOAD=true && \
npm install -g pnpm@8.15.7 && \
pnpm install --frozen-lockfile && \
set -ex &&
export PUPPETEER_SKIP_DOWNLOAD=true &&
npm install -g pnpm@9.1.0 &&
pnpm install --frozen-lockfile &&
pnpm rb
# ---------------------------------------------------------------------------------------------------------------------
@@ -38,10 +38,10 @@ FROM debian:bookworm-slim AS dep-version-parser
WORKDIR /ver
COPY ./package.json /app/
RUN \
set -ex && \
set -ex &&
grep -Po '(?<="puppeteer": ")[^\s"]*(?=")' /app/package.json | tee /ver/.puppeteer_version
# grep -Po '(?<="@vercel/nft": ")[^\s"]*(?=")' /app/package.json | tee /ver/.nft_version && \
# grep -Po '(?<="fs-extra": ")[^\s"]*(?=")' /app/package.json | tee /ver/.fs_extra_version
# grep -Po '(?<="@vercel/nft": ")[^\s"]*(?=")' /app/package.json | tee /ver/.nft_version && \
# grep -Po '(?<="fs-extra": ")[^\s"]*(?=")' /app/package.json | tee /ver/.fs_extra_version
# ---------------------------------------------------------------------------------------------------------------------
@@ -66,15 +66,15 @@ COPY . /app
COPY --from=dep-builder /app /app
RUN \
set -ex && \
set -ex &&
# cp /app/scripts/docker/minify-docker.js /minifier/ && \
# export PROJECT_ROOT=/app && \
# node /minifier/minify-docker.js && \
# rm -rf /app/node_modules /app/scripts && \
# mv /app/app-minimal/node_modules /app/ && \
# rm -rf /app/app-minimal && \
npm run build && \
ls -la /app && \
npm run build &&
ls -la /app &&
du -hd1 /app
# ---------------------------------------------------------------------------------------------------------------------
@@ -93,21 +93,21 @@ ARG PUPPETEER_SKIP_DOWNLOAD=1
# The official recommended way to use Puppeteer on x86(_64) is to use the bundled Chromium from Puppeteer:
# https://pptr.dev/faq#q-why-doesnt-puppeteer-vxxx-work-with-chromium-vyyy
RUN \
set -ex ; \
if [ "$PUPPETEER_SKIP_DOWNLOAD" = 0 ] && [ "$TARGETPLATFORM" = 'linux/amd64' ]; then \
if [ "$USE_CHINA_NPM_REGISTRY" = 1 ]; then \
npm config set registry https://registry.npmmirror.com && \
yarn config set registry https://registry.npmmirror.com && \
pnpm config set registry https://registry.npmmirror.com ; \
fi; \
echo 'Downloading Chromium...' && \
unset PUPPETEER_SKIP_DOWNLOAD && \
npm install -g pnpm@8.15.7 && \
pnpm add puppeteer@$(cat /app/.puppeteer_version) --save-prod && \
pnpm rb ; \
else \
mkdir -p /app/node_modules/.cache/puppeteer ; \
fi;
set -ex
if [ "$PUPPETEER_SKIP_DOWNLOAD" = 0 ] && [ "$TARGETPLATFORM" = 'linux/amd64' ]; then
if [ "$USE_CHINA_NPM_REGISTRY" = 1 ]; then
npm config set registry https://registry.npmmirror.com &&
yarn config set registry https://registry.npmmirror.com &&
pnpm config set registry https://registry.npmmirror.com
fi
echo 'Downloading Chromium...' &&
unset PUPPETEER_SKIP_DOWNLOAD &&
npm install -g pnpm@9.1.0 &&
pnpm add puppeteer@$(cat /app/.puppeteer_version) --save-prod &&
pnpm rb
else
mkdir -p /app/node_modules/.cache/puppeteer
fi
# ---------------------------------------------------------------------------------------------------------------------
@@ -129,41 +129,40 @@ ARG PUPPETEER_SKIP_DOWNLOAD=1
# The official recommended way to use Puppeteer on arm/arm64 is to install Chromium from the distribution repositories:
# https://github.com/puppeteer/puppeteer/blob/07391bbf5feaf85c191e1aa8aa78138dce84008d/packages/puppeteer-core/src/node/BrowserFetcher.ts#L128-L131
RUN \
set -ex && \
apt-get update && \
set -ex &&
apt-get update &&
apt-get install -yq --no-install-recommends \
dumb-init git \
; \
if [ "$PUPPETEER_SKIP_DOWNLOAD" = 0 ]; then \
if [ "$TARGETPLATFORM" = 'linux/amd64' ]; then \
apt-get install -yq --no-install-recommends \
ca-certificates fonts-liberation wget xdg-utils \
libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 libcairo2 libcups2 libdbus-1-3 libdrm2 \
libexpat1 libgbm1 libglib2.0-0 libnspr4 libnss3 libpango-1.0-0 libx11-6 libxcb1 libxcomposite1 \
libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2 \
; \
else \
apt-get install -yq --no-install-recommends \
chromium \
&& \
echo "CHROMIUM_EXECUTABLE_PATH=$(which chromium)" | tee /app/.env ; \
fi; \
fi; \
rm -rf /var/lib/apt/lists/*
;
if [ "$PUPPETEER_SKIP_DOWNLOAD" = 0 ]; then
if [ "$TARGETPLATFORM" = 'linux/amd64' ]; then
apt-get install -yq --no-install-recommends \
ca-certificates fonts-liberation wget xdg-utils \
libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 libcairo2 libcups2 libdbus-1-3 libdrm2 \
libexpat1 libgbm1 libglib2.0-0 libnspr4 libnss3 libpango-1.0-0 libx11-6 libxcb1 libxcomposite1 \
libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2 \
;
else
apt-get install -yq --no-install-recommends \
chromium &&
echo "CHROMIUM_EXECUTABLE_PATH=$(which chromium)" | tee /app/.env
fi
fi
rm -rf /var/lib/apt/lists/*
COPY --from=chromium-downloader /app/node_modules/.cache/puppeteer /app/node_modules/.cache/puppeteer
RUN \
set -ex && \
if [ "$PUPPETEER_SKIP_DOWNLOAD" = 0 ] && [ "$TARGETPLATFORM" = 'linux/amd64' ]; then \
echo 'Verifying Chromium installation...' && \
if ldd $(find /app/node_modules/.cache/puppeteer/ -name chrome -type f) | grep "not found"; then \
echo "!!! Chromium has unmet shared libs !!!" && \
exit 1 ; \
else \
echo "Awesome! All shared libs are met!" ; \
fi; \
fi;
set -ex &&
if [ "$PUPPETEER_SKIP_DOWNLOAD" = 0 ] && [ "$TARGETPLATFORM" = 'linux/amd64' ]; then
echo 'Verifying Chromium installation...' &&
if ldd $(find /app/node_modules/.cache/puppeteer/ -name chrome -type f) | grep "not found"; then
echo "!!! Chromium has unmet shared libs !!!" &&
exit 1
else
echo "Awesome! All shared libs are met!"
fi
fi
COPY --from=docker-minifier /app /app