Last active
September 6, 2018 08:19
-
-
Save abdala/8e758cacb5971057cfea37fc40cb43c7 to your computer and use it in GitHub Desktop.
Laracon Multi-stage Dockerfiles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:3.8 | |
WORKDIR /app | |
COPY . /app | |
RUN apk add --update php7-apache2 php7-mbstring php7-pdo_sqlite php7-tokenizer \ | |
php7-xml php7-xmlwriter php7-session php7-json composer \ | |
&& composer install --no-dev \ | |
&& sed -i 's#^DocumentRoot ".*#DocumentRoot "/app/public"#g' /etc/apache2/httpd.conf \ | |
&& sed -i 's#Directory "/var/www/localhost/htdocs.*#Directory "/app/public" >#g' /etc/apache2/httpd.conf \ | |
&& sed -i 's,#\(LoadModule rewrite_module modules/mod_rewrite.so\),\1,g' "/etc/apache2/httpd.conf" \ | |
&& sed -i 's#AllowOverride None#AllowOverride All#' /etc/apache2/httpd.conf \ | |
&& mkdir /run/apache2 | |
EXPOSE 80 | |
CMD httpd -DFOREGROUND |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:3.8 as php-dependencies | |
RUN apk add --update php7-mbstring php7-pdo_sqlite php7-tokenizer \ | |
php7-xml php7-xmlwriter php7-session php7-json php7-openssl | |
FROM php-dependencies as composer | |
WORKDIR /app | |
COPY . /app | |
RUN apk add --update composer \ | |
&& composer install --no-dev | |
FROM php-dependencies | |
RUN apk add --update php7-apache2 \ | |
&& sed -i 's#^DocumentRoot ".*#DocumentRoot "/app/public"#g' /etc/apache2/httpd.conf \ | |
&& sed -i 's#Directory "/var/www/localhost/htdocs.*#Directory "/app/public" >#g' /etc/apache2/httpd.conf \ | |
&& sed -i 's,#\(LoadModule rewrite_module modules/mod_rewrite.so\),\1,g' /etc/apache2/httpd.conf \ | |
&& sed -i 's#AllowOverride None#AllowOverride All#' /etc/apache2/httpd.conf \ | |
&& mkdir /run/apache2 | |
COPY --from=composer /app /app | |
EXPOSE 80 | |
CMD httpd -DFOREGROUND |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:7.2-apache | |
WORKDIR /var/www | |
COPY . /var/www | |
RUN apt-get update \ | |
&& apt-get install -y libzip-dev \ | |
&& docker-php-ext-install zip \ | |
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer \ | |
&& composer install --no-dev \ | |
&& mv /var/www/public/* /var/www/html \ | |
&& a2enmod rewrite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:7.2-apache as composer | |
WORKDIR /var/www | |
COPY . /var/www | |
RUN apt-get update \ | |
&& apt-get install -y libzip-dev \ | |
&& docker-php-ext-install zip \ | |
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer \ | |
&& composer install --no-dev | |
FROM php:7.2-apache | |
COPY --from=composer /var/www /var/www | |
RUN mv /var/www/public/* /var/www/html \ | |
&& a2enmod rewrite |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment