【问题标题】:dockerfile for running meteor app - using node:7.5.0-alpine用于运行流星应用程序的 dockerfile - 使用节点:7.5.0-alpine
【发布时间】:2018-10-28 00:37:43
【问题描述】:

我正在尝试在 docker 上运行一个流星应用程序。

这是我的 Dockerfile:

From node:7.5.0-alpine
RUN meteor npm install --a
CMD ["meteor"]

运行:

➜ docker build . -t myapp
Sending build context to Docker daemon 21.91 MB
Step 1 : FROM node:7.5.0-alpine
 ---> 0895ecd79009
Step 2 : RUN meteor npm install --a
 ---> Running in 1de3ba593bb1
/bin/sh: meteor: not found
The command '/bin/sh -c meteor npm install --a' returned a non-zero code: 127

这是收到的错误:

/bin/sh: 流星:未找到

命令 '/bin/sh -c meteor npm install --a' 返回一个非零值

我做错了什么?

基本上我正在尝试使用轻量级流星基础图像 (node:7.5.0-alpine) 来创建我的图像

应该在我的 dockerfile 中修复什么?

【问题讨论】:

  • node:7.5.0-alpine 不是 Meteor 基础镜像 - 你必须先安装 Meteor
  • @chazsolo 你推荐什么 Meteor 图像?我宁愿使用轻量级图像
  • 你可以试试ulexus/meteor

标签: meteor docker


【解决方案1】:

必须先安装meteor,node不够用。
尝试添加类似:
RUN curl "https://install.meteor.com/" | /bin/sh
在第二行。
This is an example for a dockerfile for mongo based on a node image.

【讨论】:

  • 为什么不在 dockerfile 中使用:FROM ulexus/meteor?这不是更好吗?
  • 如果该图像对您有好处,那么为什么不使用它...无论如何,您的图像上必须有流星才能在其上运行流星 :)
【解决方案2】:

我结束了使用martinezko/alpine-meteor 图像

Dockerfile

FROM martinezko/alpine-meteor
ENV NODE_ENV=production

运行 docker-build.sh 来构建它:

#!/bin/sh

set -e

# get the image tag
echo -n "Enter release tag [e.g. 1.0.7] "
read TAG
echo "You release has an amazing tag: $TAG"

REGISTRY=us.gcr.io
CONTAINER=my-com/my-app
BUILD_DIR=`pwd`/.build                      # <-- This is where meteor build your files.
                                            #     Folder will be created and after build will be deleted


echo "Start building container ${CONTAINER} ..."

# clean old build if exist
rm   -rf $BUILD_DIR
mkdir -p $BUILD_DIR

# install node packages
meteor npm install --a &&

# build meteor app
meteor build --directory $BUILD_DIR --architecture=os.linux.x86_64 --server-only &&

# pull fresh base image:
docker pull martinezko/alpine-meteor:latest &&

# build container
docker build --rm -t ${REGISTRY}/${CONTAINER}:${TAG} . &&


echo "${REGISTRY}/${CONTAINER}:${TAG}"
# push to our registry
echo "we are now pushing your amazing relese to google container engine registry $REGISTRY/$CONTAINER:$TAG"
docker push ${REGISTRY}/${CONTAINER}:${TAG}


# clean images if needed
# docker rmi -f ${CONTAINER}:${TAG} ${REGISTRY}/${CONTAINER}:${TAG} martinezko/alpine-meteor:latest

# to run your container
# docker run -d ${REGISTRY}/${CONTAINER}:${TAG}
# OR use docker-compose.yaml file
# docker-compose up -d

# clean build folder
rm -rf .build

echo "End build of container ${CONTAINER} ..."

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-18
    • 1970-01-01
    • 2016-01-14
    • 1970-01-01
    • 2012-11-27
    • 2014-11-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多