-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (51 loc) · 2.42 KB
/
Copy pathDockerfile
File metadata and controls
69 lines (51 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# todo: https://laravel-news.com/php-opcache-docker consider for development maybe?
# todo: gd lib breaks https://stackoverflow.com/questions/13338339/imagecreatefromjpeg-and-similar-functions-are-not-working-in-php. Attempted to call function "imagecreatefromjpeg" from the global namespace
ARG PHP_VERSION=7.1.30
# Use this image as the base image for dev and prod.
FROM php:${PHP_VERSION}-apache as common
RUN apt-get update && apt-get install -y zlib1g-dev libicu-dev g++ libpng-dev build-essential libssl-dev libjpeg-dev libfreetype6-dev
RUN docker-php-ext-configure intl
RUN docker-php-ext-install intl
RUN docker-php-ext-install mysqli zip pdo pdo_mysql
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install gd
RUN a2enmod rewrite
# Optimizing php
RUN docker-php-ext-install opcache
RUN docker-php-ext-enable opcache
RUN echo "opcache.max_accelerated_files = 20000" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
# This is the image using in development.
FROM common as dev
RUN apt-get install -y zip unzip git; \
pecl install xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini;
# Copy composer binary from official Composer image.
COPY --from=composer /usr/bin/composer /usr/bin/composer
WORKDIR /var/www/html
# We enable the errors only in development.
ENV DISPLAY_ERRORS="On"
# In this image we will download the dependencies, but without the development dependencies.
# The dependencies are installed in the vendor folder that will be copied later into the prod image.
FROM composer as builder-prod
WORKDIR /app
COPY composer.json composer.lock /app/
RUN composer install \
--ignore-platform-reqs \
--no-ansi \
--no-dev \
--no-autoloader \
--no-interaction \
--no-scripts
# We need to copy our whole application so that we can generate the autoload file inside the vendor folder.
COPY . /app
RUN composer dump-autoload --optimize --no-dev --classmap-authoritative
# This is the image that will be deployed on production.
FROM common as prod
# No display errors to users in production.
ENV DISPLAY_ERRORS="Off"
# Copy our application
COPY . /var/www/html/
# Change files owner to apache
RUN chown -R www-data:www-data /var/www/html
# Copy the downloaded dependencies from the builder-prod stage.
COPY --from=builder-prod /app/vendor /var/www/html/vendor