nodejs镜像示例

更新时间:2016/01/28 访问次数:29823
文件名称 说明
dockfile docker镜像构建描述文件
start ews镜像启动脚本

制作nodejs镜像的dockfile如下:

from registry.acs.aliyun.com/open/centos:3.0.0
COPY app.js /acs/user/app.js
COPY package.json /acs/user/package.json
COPY node-v0.12.7.tar.gz /acs/user/node-v0.12.7.tar.gz
RUN cd /acs/user/ && tar -xzf node-v0.12.7.tar.gz && rm -fr node-v0.12.7.tar.gz && \
mv node-v0.12.7 node && \
         cd /acs/user/node && ./configure --prefix=/acs/user/local/node/ && 
         make && make install && \
         ln -s /acs/user/local/node/bin/* /usr/sbin/ && \
         npm install -g grunt-cli && npm config set registry https://registry.npm.taobao.org && \
         ln -s /acs/user/local/node/bin/grunt /usr/sbin/grunt
ENV NODE_HOME /acs/user/local/node
ENV PATH $PATH:/acs/user/local/node/bin:/acs/user/local/node/lib/node_modules/npm/bin/node-gyp-bin
RUN source /etc/profile
COPY start /acs/bin/start

start脚本如下:

ENV_FILE=/acs/conf/env.properties
THIS_PATH="/acs/user/"
WEBROOT="/acs/code/"
APP_START_FILE="app.js"
if [ ! -d "/acs/log" ]; then
    mkdir -p /acs/log
fi
if [ ! -d "/acs/data" ]; then
    mkdir -p /acs/data
fi
if [ ! -d "$WEBROOT" ]; then
    mkdir -p $WEBROOT
fi if [ -f $ENV_FILE ]; then CONF_APP_ROOT_PATH=`cat $ENV_FILE |grep -w APP_ROOT_PATH |awk -F "=" '{print $2}'` if [ ! '$CONF_APP_ROOT_PATH' = "" ]; then WEBROOT=${WEBROOT}${CONF_APP_ROOT_PATH} Fi APP_START_FILE=`cat $ENV_FILE |grep -w APP_START_FILE |awk -F "=" '{print $2}'` if [ "$APP_START_FILE" = "" ]; then APP_START_FILE="app.js" Fi Fi if [ ! -d "$WEBROOT" ]; then mkdir -p $WEBROOT fi content=`ls $WEBROOT` if [ "$content" == "" ]; then #if [ ! -d $WEBROOT ]; then cp $THIS_PATH"app.js" $WEBROOT fi PACKAGE_FILE=${WEBROOT}"package.json" if [ -f $ENV_FILE ]; then APP_NPM_INSTALL=`cat $ENV_FILE |grep -w APP_NPM_INSTALL |awk -F "=" '{print $2}'` if [ "$APP_NPM_INSTALL" = "true" ]; then if [ -f $PACKAGE_FILE ]; then cd $WEBROOT npm install else cp $THIS_PATH"package.json" /acs/package.json cd /ace rm -rf node_modules npm install fi fi fi node ${WEBROOT}${APP_START_FILE}

FAQ

关于此文档暂时还没有FAQ
返回
顶部