Image node-python có python3 nhưng thiếu make/g++, nên module Node có phần native (vd better-sqlite3) không biên dịch được khi không tải được prebuilt. Đã thử: docker build OK; trong image, npm ci của tl-noti build better-sqlite3 từ nguồn thành công, 55/55 test pass.
24 lines
766 B
Docker
24 lines
766 B
Docker
FROM node:lts-slim
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
# Cài git + Python 3 (Debian stable) + build-essential (make, g++):
|
|
# node-gyp (module Node có phần native, vd better-sqlite3) và pip build wheel C
|
|
# cần trình biên dịch khi không tải được bản build sẵn.
|
|
RUN set -eux; \
|
|
apt-get update; \
|
|
apt-get install -y --no-install-recommends \
|
|
git \
|
|
build-essential \
|
|
python3 python3-pip python3-venv; \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Tạo virtualenv mặc định cho mọi thứ Python trong container
|
|
# => bạn dùng `python`/`pip` là vào venv này luôn
|
|
RUN python3 -m venv /opt/venv \
|
|
&& /opt/venv/bin/python -m pip install --upgrade pip setuptools wheel
|
|
|
|
ENV PATH="/opt/venv/bin:${PATH}"
|
|
|
|
WORKDIR /app
|