Docker / Dockerfile:使用ENTRYPOINT进行git clone

时间:2016-06-01 16:57:55

标签: docker dockerfile

我正在尝试在我的Dockerfile中运行git clone命令作为入口点,这样它就不会被缓存,我保证拥有最新的源代码。目前我在Dockerfile中有以下代码:

kernel/examplepatch

要删除缓存,我更改了以下行:

FROM ubuntu:trusty
MAINTAINER Fernando Mayo <fernando@tutum.co>, Feng Honglin <hfeng@tutum.co>

# Install packages
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
  apt-get -y install vim supervisor git curl unzip apache2 libapache2-mod-php5 pwgen php-apc php5-mcrypt php5-mysql php5-curl&& \
  echo "ServerName localhost" >> /etc/apache2/apache2.conf


# Install Composer
RUN curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
RUN composer global require "laravel/installer"
ENV PATH ~/.composer/vendor/bin:$PATH

# Add image configuration and scripts
ADD start-apache2.sh /start-apache2.sh
ADD start-mysqld.sh /start-mysqld.sh
ADD run.sh /run.sh
RUN chmod 755 /*.sh
ADD my.cnf /etc/mysql/conf.d/my.cnf
ADD supervisord-apache2.conf /etc/supervisor/conf.d/supervisord-apache2.conf
ADD supervisord-mysqld.conf /etc/supervisor/conf.d/supervisord-mysqld.conf
ADD php.ini /etc/php5/cli/php.ini
ADD 000-default.conf /etc/apache2/sites-available/000-default.conf


# config to enable .htaccess
RUN a2enmod rewrite


# Copy over private key, and set permissions
ADD .ssh /root/.ssh


# Get aws stuff
RUN curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
RUN unzip awscli-bundle.zip
RUN ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

# Clone the repo
RUN rm -rd /var/www/html
RUN git clone ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/Laravel /var/www/html
# Set file permissions
RUN chmod -R 777 /var/www/html/storage 
RUN chmod -R 777 /var/www/html/bootstrap/cache


# Environment variables to configure php
ENV PHP_UPLOAD_MAX_FILESIZE 10M
ENV PHP_POST_MAX_SIZE 10M




EXPOSE 80 3306
CMD ["/run.sh"]

# Clone the repo
RUN rm -rd /var/www/html
RUN git clone ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/Laravel /var/www/html
# Set file permissions
RUN chmod -R 777 /var/www/html/storage 
RUN chmod -R 777 /var/www/html/bootstrap/cache

我可以构建这个Dockerfile但是当我运行它之前我可以做任何事情(我无法使用localhost访问它,我没有看到任何错误)。我对ENTRYPOINT做错了什么?

1 个答案:

答案 0 :(得分:1)

您的切入点只做一件事并退出。您可能希望在入口点运行服务器,以便容器可以粘贴。在您的情况下,您似乎想要运行run.sh

此外,只允许一个ENTRYPOINT。您应该将多个入口点转换为脚本并将其用作入口点。来自documentation

  

只有Dockerfile中的最后一条ENTRYPOINT指令才会有   效果。