1

I am trying to run a git clone command inside my Dockerfile as entrypoint so that it is not cached and I am guaranteed to have the most up to date source code. Currently I have the following code in the Dockerfile:

FROM ubuntu:trusty MAINTAINER Fernando Mayo <[email protected]>, Feng Honglin <[email protected]> # 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"] 

To remove the cache I changed the following lines:

# 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 

with

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

I can build this Dockerfile but when I run it stops before I can do anything (I can't access it with localhost and I don't see any errors). What am I doing wrong with ENTRYPOINT?

1 Answer 1

1

Your entry point just does one thing and exits. You probably want to run your server in your entry point so the container sticks around. In your case, it seems like you want to run run.sh.

Additionally, only one ENTRYPOINT is allowed. You should convert your multiple entry points to a script and use that as the entry point. From the documentation:

Only the last ENTRYPOINT instruction in the Dockerfile will have an effect.

Sign up to request clarification or add additional context in comments.

Comments