【问题标题】:Docker: docker-compose for bundling meteor app not working.. (npm errors)Docker:用于捆绑流星应用程序的 docker-compose 不工作..(npm 错误)
【发布时间】:2018-02-08 14:01:19
【问题描述】:

谁能帮我解决这个问题?我目前正在尝试通过 docker-compose 捆绑我的流星应用程序,并且我不断收到 npm 错误。我终于完成了由 docker-compose.yml 文件调用的 Dockerfile 中的最后一个构建步骤,但是我遇到了很多错误。所有文件,包括 package.json,在应用程序目录中都清晰可见,所以在那里没有理由将其隐藏在安装中。

这是我的 dockerfile,以下是错误:


FROM ubuntu:trusty

# Install NodeJS from Node-Source repo (node 0.10.48).
RUN apt-get update && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get install -y nodejs

# Add your app on /Home and install NPM modules. And clean the cache.
RUN mkdir /home/app
COPY app.tar.gz /tmp/app.tar.gz
RUN tar -zxf /tmp/app.tar.gz -C /home/app
RUN apt-get install -y python
RUN cd /home/app/bundle/programs/server

RUN apt-get update
RUN npm install
#RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Expose port 80, but remember to use PORT=80
EXPOSE 80

# Run the app
WORKDIR /home/app
CMD ["node", "main.js"]

npm ERR! install Couldn't read dependencies
npm ERR! Linux 4.10.0-32-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v0.10.48
npm ERR! npm  v2.15.1
npm ERR! path /package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno 34

npm ERR! package.json ENOENT, open '/package.json'
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.

npm ERR! Please include the following file with any support request:
npm ERR!     /npm-debug.log
ERROR: Service 'app' failed to build: The command '/bin/sh -c npm install' returned a non-zero code: 34

【问题讨论】:

    标签: node.js ubuntu meteor npm docker-compose


    【解决方案1】:

    您不需要在 Dockerfile 中安装节点。使用 Node docker 镜像作为基础镜像。 https://hub.docker.com/r/_/node/

    然后安装其他依赖项,例如 python。使用WORKDIR docker 指令,然后将您的文件复制到WORKDIR。

    FROM node:wheezy
    
    RUN mkdir /home/app
    
    WORKDIR /home/app
    
    COPY app.tar.gz .
    RUN tar -zxf app.tar.gz && npm install && apt-get update && apt-get install -y python && cd bundle/programs/server && rm -rf /var/lib/apt/lists/* 
    
    # Expose port 80, but remember to use PORT=80
    EXPOSE 80
    
    # Run the app
    CMD ["node", "main.js"]
    

    【讨论】:

    • 感谢您这么快的回复!!我现在已经克服了第一个错误,但构建到最后一步并返回:错误:对于应用程序无法启动服务应用程序:oci 运行时错误:container_linux.go:262:启动容器进程导致“exec:\”meteor \": $PATH 中找不到可执行文件" 错误: 启动项目时遇到错误。
    • 基于"exec: \"meteor\": executable file not found in $PATH。我的猜测是您没有从正确的位置运行CMD。也许在expose 80 之后添加一行来给自己一些信息。 RUN ls -lha 或 RUN echo $PWD。我认为您的应用需要从/home/app 执行。
    猜你喜欢
    • 1970-01-01
    • 2016-05-14
    • 2017-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多