首页 > 解决方案 > 如何减小包含 python 实用程序的 nodejs 容器的大小

问题描述

我有 javascript 应用程序,我在其中使用 python 实用程序(canconvert of canmatrix 实用程序)。在javascript中我调用canconvert through

    execSync(`canconvert\\
                      --jsonExportAll\\
                      --jsonNativeTypes\\
                      --additionalFrameAttributes\\
                      --additionalSignalAttributes\\
                      ${dbcFileLocation} ${parsedJsonLocation}`);

所以,canconvert 应该在 docker 环境中可用。现在,我只是通过 pip 安装 canmatrix 但容器的大小变得非常大。

FROM node:10.15.3-slim AS dist
...
RUN apt-get update && \
    apt-get install -y python python-pip && \
    pip install canmatrix && \
    chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]

标签: pythonnode.jsdockerdockerfile

解决方案


Python 并不小。包括电池。

我想你可以尝试使用 nuitka 或 cython 构建你的 python 代码,但是你最终可能会放弃自动升级。

磁盘很便宜 - 为什么不像你拥有它那样使用它呢?


推荐阅读