refactor(DockerFile):

1. Replace npm with yarn for package management;
2. Add NODE_ENV ARG;
3. Rmove Taobao npm registry;
4. Remove package-lock.json;
mack-mac
mackt 8 months ago
parent 47a2d84b86
commit 2ed57b5f9f

@ -1,24 +1,26 @@
ARG NODE_ENV
FROM node:alpine
ENV NODE_ENV $NODE_ENV
# Install dependencies only when needed
FROM node:alpine AS deps
# 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
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install --frozen-lockfile --registry=https://registry.npm.taobao.org
COPY package.json yarn.lock ./
RUN yarn --frozen-lockfile
# Rebuild the source code only when needed
FROM node:alpine AS builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
RUN npm run build && npm install --production --ignore-scripts --prefer-offline --registry=https://registry.npm.taobao.org
RUN yarn build && yarn add --$NODE_ENV --ignore-scripts --prefer-offline
# Production image, copy all the files and run next
FROM node:alpine AS runner
WORKDIR /app
ENV NODE_ENV production
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001

8951
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -17,7 +17,6 @@
"qs": "^6.12.0",
"react": "^18",
"react-dom": "^18",
"swr": "^2.2.5",
"zustand": "^4.5.2"
},
"devDependencies": {

@ -1746,7 +1746,7 @@ cli-truncate@^4.0.0:
slice-ansi "^5.0.0"
string-width "^7.0.0"
client-only@0.0.1, client-only@^0.0.1:
client-only@0.0.1:
version "0.0.1"
resolved "https://registry.npmmirror.com/client-only/-/client-only-0.0.1.tgz"
integrity sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==
@ -4493,14 +4493,6 @@ supports-preserve-symlinks-flag@^1.0.0:
resolved "https://registry.npmmirror.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz"
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==
swr@^2.2.5:
version "2.2.5"
resolved "https://registry.npmmirror.com/swr/-/swr-2.2.5.tgz"
integrity sha512-QtxqyclFeAsxEUeZIYmsaQ0UjimSq1RZ9Un7I68/0ClKK/U3LoyQunwkQfJZr2fc22DfIXLNDc2wFyTEikCUpg==
dependencies:
client-only "^0.0.1"
use-sync-external-store "^1.2.0"
synckit@^0.8.6:
version "0.8.8"
resolved "https://registry.npmmirror.com/synckit/-/synckit-0.8.8.tgz"
@ -4708,7 +4700,7 @@ uri-js@^4.2.2:
dependencies:
punycode "^2.1.0"
use-sync-external-store@1.2.0, use-sync-external-store@^1.2.0:
use-sync-external-store@1.2.0:
version "1.2.0"
resolved "https://registry.npmmirror.com/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz"
integrity sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==

Loading…
Cancel
Save