2015-12-14 51 views
-1
FROM ubuntu:14.04 

RUN apt-get update 
RUN apt-get install -y build-essential git 
RUN apt-get install -y python python-dev python3 python3-dev python3-pip 
RUN apt-get install -y nginx uwsgi uwsgi-plugin-python3 supervisor 

RUN pip3 install uwsgi 

#RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf 
RUN chown -R www-data:www-data /var/lib/nginx 

# UWSGI 
ENV UWSGIVERSION 2.0.11.2 

RUN apt-get update && apt-get install -y --no-install-recommends \ 
      build-essential \ 
      libjansson-dev \ 
      libpcre3-dev \ 
      libssl-dev \ 
      libxml2-dev \ 
      wget \ 
      zlib1g-dev 

RUN cd /usr/src && \ 
    wget --quiet -O - http://projects.unbit.it/downloads/uwsgi-${UWSGIVERSION}.tar.gz | \ 
    tar zxvf - 

RUN cd /usr/src/uwsgi-${UWSGIVERSION} && make 
RUN cp /usr/src/uwsgi-${UWSGIVERSION}/uwsgi /usr/local/bin/uwsgi 
RUN PYTHON=/usr/local/python3.4/bin/python3.4 
RUN cd /usr/src/uwsgi-${UWSGIVERSION} && ./uwsgi --build-plugin "plugins/python python34" 
RUN mkdir -p /usr/local/lib/uwsgi/plugins 
RUN cp /usr/src/uwsgi-${UWSGIVERSION}/*.so /usr/local/lib/uwsgi/plugins 

# Java 
ENV VERSION 7 
ENV UPDATE 80 
ENV BUILD 15 

ENV JAVA_HOME /usr/lib/jvm/java-${VERSION}-oracle 
ENV JRE_HOME ${JAVA_HOME}/jre 

RUN apt-get update && apt-get install ca-certificates curl -y && \ 
    curl --silent --location --retry 3 --cacert /etc/ssl/certs/GeoTrust_Global_CA.pem \ 
    --header "Cookie: oraclelicense=accept-securebackup-cookie;" \ 
    http://download.oracle.com/otn-pub/java/jdk/"${VERSION}"u"${UPDATE}"-b"${BUILD}"/server-jre-"${VERSION}"u"${UPDATE}"-linux-x64.tar.gz \ 
    | tar xz -C /tmp && \ 
    mkdir -p /usr/lib/jvm && mv /tmp/jdk1.${VERSION}.0_${UPDATE} "${JAVA_HOME}" && \ 
    apt-get autoclean && apt-get --purge -y autoremove && \ 
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 

RUN update-alternatives --install "/usr/bin/java" "java" "${JRE_HOME}/bin/java" 1 && \ 
    update-alternatives --install "/usr/bin/javac" "javac" "${JAVA_HOME}/bin/javac" 1 && \ 
    update-alternatives --set java "${JRE_HOME}/bin/java" && \ 
    update-alternatives --set javac "${JAVA_HOME}/bin/javac" 

# Node 
RUN \ 
    apt-get update && \ 
    apt-get install -yqq curl \ 
    wget git python build-essential g++ libkrb5-dev libfreetype6 libfontconfig \ 
    libjpeg8 libpng12-0 libicu-dev libcurl3 libcurl3-gnutls libcurl4-openssl-dev \ 
    libcurl3 libcurl3-gnutls libcurl4-openssl-dev && \ 
    curl --silent --location https://deb.nodesource.com/setup_0.10 | bash - && \ 
    apt-get install -yqq nodejs && \ 
    wget -O - 'https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-14.04.tar.bz2' | tar xjf - -C ~/ && \ 
    mv ~/phantomjs /usr/local/bin/ && \ 
    npm install -g [email protected] && \ 
    apt-get autoremove -yqq && \ 
    apt-get clean 
RUN npm install -g bower 

# Redis 
RUN apt-get update -qq && apt-get install -y python-software-properties sudo 
RUN apt-get install -y redis-server 
RUN chown -R redis:redis /var/lib/redis 

# psycopg2 
RUN apt-get install -y python-psycopg2 
RUN apt-get install -y libpq-dev 

# lxml 
RUN apt-get install -y python3-lxml 
RUN apt-get install -y libxml2-dev libxslt-dev 

# Pillow 
RUN apt-get install -y libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev 

# Project 
ENV PROJECT_DIR /home/ubuntu/workspace/ward 
ADD . ${PROJECT_DIR} 
RUN cd ${PROJECT_DIR} && bower --allow-root install 
RUN cd ${PROJECT_DIR} && pip3 install -r requirements.txt 
RUN mkdir ${PROJECT_DIR}/www/logs 
RUN cd ${PROJECT_DIR}/www && python3 manage.py migrate --noinput 
RUN cd ${PROJECT_DIR}/www && python3 manage.py collectstatic --noinput 

RUN ln -s ${PROJECT_DIR}/conf/nginx-app.conf /etc/nginx/sites-enabled/ 
RUN ln -s ${PROJECT_DIR}/conf/uwsgi.ini /etc/uwsgi/apps-enabled/ 
RUN ln -s ${PROJECT_DIR}/conf/celeryd.conf /etc/default/celeryd 
RUN ln -s ${PROJECT_DIR}/conf/celerybeat.conf /etc/default/celerybeat 
RUN ln -s ${PROJECT_DIR}/code/supervisor-app.conf /etc/supervisor/conf.d/ 

RUN cp ${PROJECT_DIR}/conf/celeryd /etc/init.d/ 
RUN chmod +x /etc/init.d/celeryd 
RUN update-rc.d celeryd defaults 
RUN update-rc.d celeryd enable 
RUN chown root:root /etc/init.d/celeryd 
RUN chmod 755 /etc/init.d/celeryd 

RUN cp ${PROJECT_DIR}/conf/celerybeat /etc/init.d/ 
RUN chmod +x /etc/init.d/celerybeat 
RUN update-rc.d celeryd defaults 
RUN update-rc.d celeryd enable 
RUN chown root:root /etc/init.d/celerybeat 
RUN chmod 755 /etc/init.d/celerybeat 

service nginx start 
service uwsgi start 
service celeryd start 
service celerybeat start 

VOLUME ["/data", \ 
     "/etc/nginx/site-enabled", "/var/log/nginx", \ 
     "/etc/uwsgi/apps-enabled", "/var/log/uwsgi", \ 
     "/var/log/celery", \ 
     "/var/lib/redis", "/etc/redis"] 

EXPOSE 80 
EXPOSE 443 
# EXPOSE 6379 

#CMD ["supervisord", "-n"] 

我使這個碼頭文件。它可以建立在昨天,但它今天不起作用。apt-get更新失敗,在碼頭中的哈希總和不匹配

這是一條錯誤消息。 得到:20 http://archive.ubuntu.com信賴/宇宙AMD64封裝[7589 KB] 擷取的21.4 MB的1分鐘3秒(336千字節/秒) 寬:無法抓取http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/binary-amd64/Packages哈希和錯配

E: Some index files failed to download. They have been ignored, or old ones used instead. 

我不知道爲什麼它不起作用。

回答

1

你搬運工文件不能被我們用來重現的問題,因爲你有地方

一些嚴重的項目和項目依賴的分辨率看你的錯誤讓我們假設它發生在

FROM ubuntu:14.04 
RUN apt-get update 

待辦事項你多次看到你嘗試構建。如果簽名的包散列不匹配獲得

  • 你打的瞬間所在的包是在回購更新,但簽署的散列仍在更新
  • 包的哈希值

    1. 哈希不匹配,可能會發生

    最有可能的是2.因爲我現在跑14.04,沒有看到這個。

    Get:19 http://archive.ubuntu.com/ubuntu/ trusty/main librtmp0 amd64 2.4+20121230.gitdf6c518-1 [57.5 kB] 
    Get:20 http://archive.ubuntu.com/ubuntu/ trusty-updates/main libcurl3-gnutls amd64 7.35.0-1ubuntu2.6 [165 kB] 
    Get:21 http://archive.ubuntu.com/ubuntu/ trusty/main libedit2 amd64 3.1-20130712-2 [86.7 kB] 
    

    如果每次構建時都能重現錯誤。

    • 請不要發佈整個碼頭文件(就像我說的,它不會幫助我或任何其他人)。
    • 做一些工作評論整個事情,並取消一次一條指令。
    • 當你點擊錯誤信息編輯你的文章與未評論的塊。