【云计算】Dockerfile示例模板
发布日期:2022-04-03 16:31:51 浏览次数:29 分类:博客文章

本文共 3278 字,大约阅读时间需要 10 分钟。

DockerfileFROM debian:jessieMAINTAINER "Konrad Kleine"USER root############################################################# Setup environment variables############################################################ENV WWW_DIR /var/www/htmlENV SOURCE_DIR /tmp/sourceENV START_SCRIPT /root/start-apache.shRUN mkdir -pv $WWW_DIR############################################################# Speedup DPKG and don't use cache for packages############################################################# Taken from here: https://gist.github.com/kwk/55bb5b6a4b7457bef38d## this forces dpkg not to call sync() after package extraction and speeds up# installRUN echo "force-unsafe-io" > /etc/dpkg/dpkg.cfg.d/02apt-speedup# # we don't need and apt cache in a containerRUN echo "Acquire::http {No-Cache=True;};" > /etc/apt/apt.conf.d/no-cache############################################################# Create dirsRUN mkdir -p  $SOURCE_DIR/dist \              $SOURCE_DIR/app \              $SOURCE_DIR/test \              $SOURCE_DIR/.git # Add dirsADD app $SOURCE_DIR/appADD test $SOURCE_DIR/test# Dot filesADD .jshintrc $SOURCE_DIR/ADD .bowerrc $SOURCE_DIR/ADD .editorconfig $SOURCE_DIR/ADD .travis.yml $SOURCE_DIR/# Other filesADD bower.json $SOURCE_DIR/ADD Gruntfile.js $SOURCE_DIR/ADD LICENSE $SOURCE_DIR/ADD package.json $SOURCE_DIR/ADD README.md $SOURCE_DIR/# Add some git files for versioningADD .git/HEAD $SOURCE_DIR/.git/HEADADD .git/refs $SOURCE_DIR/.git/refs############################################################# Install and configure webserver software############################################################RUN apt-get -y update && \    export DEBIAN_FRONTEND=noninteractive && \    apt-get -y install \      apache2 \      libapache2-mod-auth-kerb \      libapache2-mod-proxy-html \      git \      nodejs \      nodejs-legacy \      npm \      --no-install-recommends && \    a2enmod proxy && \    a2enmod proxy_http && \    cd $SOURCE_DIR && \    export GITREF=$(cat .git/HEAD | cut -d" " -f2) && \    export GITSHA1=$(cat .git/$GITREF) && \    echo "{\"git\": {\"sha1\": \"$GITSHA1\", \"ref\": \"$GITREF\"}}" > $WWW_DIR/app-version.json && \    cd $SOURCE_DIR && \    rm -rf $SOURCE_DIR/.git && \    git config --global url."https://".insteadOf git:// && \    cd $SOURCE_DIR && \    npm install && \    node_modules/bower/bin/bower install --allow-root && \    node_modules/grunt-cli/bin/grunt build --allow-root && \    cp -rf $SOURCE_DIR/dist/* $WWW_DIR && \    rm -rf $SOURCE_DIR && \    apt-get -y --auto-remove purge git nodejs nodejs-legacy npm && \    apt-get -y autoremove && \    apt-get -y clean && \    rm -rf /var/lib/apt/lists/*############################################################# Add and enable the apache site and disable all other sites############################################################RUN a2dissite 000*ADD apache-site.conf /etc/apache2/sites-available/docker-site.confRUN a2ensite docker-site.confADD start-apache.sh $START_SCRIPTRUN chmod +x $START_SCRIPTENV APACHE_RUN_USER www-dataENV APACHE_RUN_GROUP www-dataENV APACHE_LOG_DIR /var/log/apache2# Let people know how this was builtADD Dockerfile /root/Dockerfile# Exposed portsEXPOSE 80 443VOLUME ["/etc/apache2/server.crt", "/etc/apache2/server.key"]CMD $START_SCRIPT

 

 

参考资料:

转载地址:https://www.cnblogs.com/junneyang/p/5250538.html 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:【云计算】开源的Docker Registry WebUI
下一篇:【云计算】Docker删除名称为none的Image镜像

发表评论

最新留言

做的很好,不错不错
[***.243.131.199]2024年04月18日 18时56分42秒