Created
November 29, 2021 06:52
-
-
Save xmsz/87bd049d34ac839300fbeb8cddc9eb68 to your computer and use it in GitHub Desktop.
Dockerfile + midway + pnpm + build + tzdata + apkMirror
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:12 AS build | |
WORKDIR /app | |
COPY . . | |
RUN npm i pnpm -g --registry=https://registry.npmmirror.com | |
RUN pnpm i --prefer-offline -frozen-lockfile --shamefully-hoist --registry=https://registry.npmmirror.com | |
RUN npm run build | |
RUN pnpm prune --production | |
RUN pnpm i --prefer-offline -frozen-lockfile --shamefully-hoist --registry=https://registry.npmmirror.com -P | |
# 生成生产镜像 | |
FROM node:12-alpine | |
WORKDIR /app | |
COPY --from=build /app/dist ./dist | |
COPY --from=build /app/bootstrap.js ./ | |
COPY --from=build /app/package.json ./ | |
COPY --from=build /app/node_modules ./node_modules | |
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories | |
RUN apk add --no-cache tzdata | |
ENV TZ="Asia/Shanghai" | |
# 如果端口更换,这边可以更新一下 | |
EXPOSE 7001 | |
CMD ["npm", "run", "start"] |
注意的是 现在pnpm prune有bug 如果不在运行一次pnpm i -P,就会出现依赖映射不对的情况
导致运行时会报错说找不到依赖,实际上是有只是映射不对了
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
优点