Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIP: Docker node-alpine 安装编译 npm 包: pinyin/nodejieba #57

Open
isayme opened this issue Nov 2, 2020 · 0 comments
Open

TIP: Docker node-alpine 安装编译 npm 包: pinyin/nodejieba #57

isayme opened this issue Nov 2, 2020 · 0 comments

Comments

@isayme
Copy link
Owner

isayme commented Nov 2, 2020

pinyin 依赖 nodejieba, 这里的其实要解决的是安装 nodejieba 的问题.

默认 docker node alpine 因缺失编译工具无法编译 nodejieba, 所以通过 multi stage 在 builder stage 编译后拷贝至最终镜像使用.

FROM node:12.9.0-alpine as builder
WORKDIR /app

# 安装编译工具链
RUN apk add alpine-sdk python
# 如果不是 alpine 而是 debian 需要使用 apt-get 安装
# RUN apt-get update && apt-get install -y build-essential python

# install & build
RUN npm i pinyin

FROM node:12.9.0-alpine

WORKDIR /app

# copy build result so files
COPY --from=builder /app/ /app/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant