Skip to content

Instantly share code, notes, and snippets.

@deleugpn
Last active December 30, 2018 16:55
Show Gist options
  • Save deleugpn/778a1d849d90dce1544be1a2f6ab0de6 to your computer and use it in GitHub Desktop.
Save deleugpn/778a1d849d90dce1544be1a2f6ab0de6 to your computer and use it in GitHub Desktop.
#BASE
FROM alpine:3.8 as base
RUN apk update \
&& apk add php7-pdo_mysql php7-json php7-tokenizer php7-mbstring php7-iconv php7-session php7-bcmath php7-simplexml
#DEPENDENCIES
FROM base as dependencies
COPY docker /
COPY . /app
WORKDIR /app
RUN apk add composer php7-curl php7-zip \
&& rm /etc/php7/conf.d/00_opcache.ini \
&& composer global require hirak/prestissimo \
&& composer install --no-dev --no-interaction
#ARTISAN
FROM dependencies as artisan
ENV PHP_INI_SCAN_DIR :/etc/php7/cli.conf.d/ php
RUN apk add php7
CMD ["echo", "You should specify the command you would like to run."]
#APP
FROM base
RUN apk add php7 php7-apache2 php7-opcache
COPY docker /
COPY --from=dependencies /app /app
RUN chown -R apache:apache /app/storage /app/bootstrap/cache \
&& sed -ri -e 's!^(\s*ServerTokens)\s+\S+!\1 Prod!g' "/etc/apache2/httpd.conf" \
&& sed -ri -e 's!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g' "/etc/apache2/httpd.conf" \
&& sed -ri -e 's!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g' "/etc/apache2/httpd.conf" \
&& sed -i 's,#\(LoadModule rewrite_module modules/mod_rewrite.so\),\1,g' "/etc/apache2/httpd.conf" \
&& mkdir /run/apache2
EXPOSE 80
CMD ["sh", "-c", "php /app/artisan optimize; httpd -DFOREGROUND"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment