用于运行流星应用程序的dockerfile - 使用节点:7.5.0-alpine

时间:2017-02-21 17:07:49

标签: meteor 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:meteor:not found

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

我做错了什么?

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

我的dockerfile应该修复什么?

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

我结束使用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} ..."