2015-11-03 26 views
1

我試圖運行使用開始燼-CLI應用與碼頭工人,組成了

「泊塢窗,撰寫了」命令我燼-CLI應用程序,但得到以下錯誤..

front-end_1 | Future versions of Ember CLI will not support v0.10.25. 
Please update to Node 0.12 or io.js. 
front-end_1 | version: 1.13.8 
front-end_1 | You have to be inside an ember-cli project in order to 
use the serve command. 

這裏是我的Dockerfile

#https://hub.docker.com/_/ubuntu/ 
FROM ubuntu:latest 

RUN rm /bin/sh && ln -s /bin/bash /bin/sh 

ENV DEBIAN_FRONTEND noninteractive 

# Create user docker so we don't have to run everything as root. 
RUN useradd -d /home/docker -m -s /bin/bash docker 

# Install dependencies. 
RUN sudo apt-get update -q && apt-get install -qy\ 
    autoconf \ 
    autotools-dev \ 
    build-essential\ 
    chrpath \ 
    curl \ 
    git\ 
    libbz2-dev \ 
    libcurl4-openssl-dev \ 
    libexpat-dev \ 
    libfontconfig1-dev \ 
    libncurses-dev \ 
    libssl-dev \ 
    m4\ 
    nodejs-legacy \ 
    npm \ 
    python-dev \ 
    ruby-compass \ 
    texinfo \ 
    zlib1g-dev 

#install homebrew 
USER docker 
RUN ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)" 

ENV PATH=$HOME/.linuxbrew/bin:$HOME/local/m4/bin:$PATH 
ENV MANPATH=$HOME/.linuxbrew/share/man:$MANPATH 
ENV INFOPATH=$HOME/.linuxbrew/share/info:$INFOPATH 

RUN $HOME/.linuxbrew/bin/brew install watchman 

USER root 

#install npm packages 

RUN npm install -g --save bower \ 
    ember-cli 

# Clean up after apt 
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 

# Code volume should be mounted here. 
VOLUME /code 
#ADD ./code /code 

EXPOSE 4200 

# Use baseimage-docker's init system so CMD doesn't have PID 1. 
# https://github.com/phusion/baseimage-docker#running-a-one-shot-command-in-the-container 
# ENTRYPOINT ["/sbin/my_init", "--quiet", "--skip-startup-files", "--skip-runit", "--"] 

# Open shell as user docker by default. 
CMD ["su", "docker"] 

WORKDIR /code 

# run ember server on container start 

ENTRYPOINT ["/usr/local/bin/ember"] 

CMD ["server"] 

這裏是我的搬運工,compose.yml

front-end: 
    build: . 
    ports: 
     - "4200:4200" 
    volumes: 
     - .:/code 

請問我可以告訴我如何解決這個問題?另外,我確信我可以改進/優化我的Dockerfle ..我的Dockerfile上的任何反饋也會很棒。

+0

有關Dockerfile的一些注意事項:1)在單獨的運行命令中進行apt-get安裝後清理並不會縮小映像,它需要在與apt-get安裝相同的RUN步驟中進行2)您可能不需要'VOLUME/code',你可以在運行時創建一個主機卷。 3)你有兩個'CMD'條目,但你只能有一個。第一個沒有做任何事情。 – dnephin

+0

thx !!清理完所有東西,並保存了大約40MB ..我的圖像大約550MB雖然.. – genwip

+0

雅,清理並沒有做太多(我很少這樣做)。你可以做的其他事情來減少圖像方面:1)使用不同的基本圖像,debian基本圖像往往比ubuntu小很多2)你可以嘗試避免安裝程序自制軟件,並找到一種方法來建立一個二進制'看門人'在一個容器裏。然後只需curl來安裝二進制文件。 – dnephin

回答

0

我認爲發生的事情是docker-compose保留了您創建的音量,而不是使用VOLUMES /code而不是使用主機卷。嘗試運行docker-compose rm -f以刪除舊容器,從Dockerfile中刪除VOLUMES /code,並嘗試再次運行up

0

最後我得到這個工作..

這裏是我的Dockerfile

FROM debian:wheezy 

ENV DEBIAN_FRONTEND noninteractive 

# Install dependencies. 
RUN apt-get update -q && apt-get install -qy\ 
    autoconf \ 
    autotools-dev \ 
    build-essential\ 
    chrpath \ 
    curl \ 
    git\ 
    libbz2-dev \ 
    libcurl4-openssl-dev \ 
    libexpat-dev \ 
    libfontconfig1-dev \ 
    libncurses-dev \ 
    libssl-dev \ 
    m4\ 
    python-dev \ 
    ruby-compass \ 
    texinfo \ 
    zlib1g-dev 

RUN curl -sL https://deb.nodesource.com/setup_0.12 | bash - 

RUN apt-get install -qy nodejs \ 
    npm 

RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 

RUN git clone https://github.com/facebook/watchman.git \ 
    && cd watchman \ 
    && git checkout v3.1 \ 
    && ./autogen.sh \ 
    && ./configure \ 
    && make \ 
    && make install 

#install npm packages 
RUN npm install -g bower \ 
    ember-cli 

EXPOSE 4200 

VOLUME /code 
WORKDIR /code 

CMD ["ember", "server"] 

和我docker-compose.ml

front-end: 
    build: . 
    ports: 
     - "4200:4200" 
    volumes: 
     - ./code:/code 

現在,我可以開始我的餘燼,CLI應用使用'docker-compose up'命令。

但是這個碼頭圖像大約是600MB ..是否有任何方法可以縮小圖像的大小?

+0

你安裝了兩次節點嗎?看起來像你apt-get安裝它,但你也下載源代碼? – dnephin

+0

如果您只需要構建監視員的所有'autoconf'和'-dev'包,則可以將它們安裝在同一個RUN行中,同時將它們安裝到'apt-get remove --purge'中。 – dnephin