forked from perftools/xhgui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
51 lines (41 loc) · 1.64 KB
/
Dockerfile
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
# This dockerfile is optimized to have efficient layers caching.
# for example composer install is ran only if composer related files are updated.
# also modifying source, would not need to rebuild extensions layer.
# Author: Elan Ruusamäe <[email protected]>
FROM php:7.3-fpm-alpine AS base
RUN set -x \
&& apk add --no-cache --virtual .build-deps ${PHPIZE_DEPS} \
&& pecl install mongodb && docker-php-ext-enable mongodb \
&& apk del .build-deps
# prepare sources
FROM scratch AS source
WORKDIR /app
COPY . .
# mkdir "vendor" dir, so the next stage can use external vendor optionally
WORKDIR /app/vendor
# install composer vendor
FROM base AS build
WORKDIR /app
ARG COMPOSER_FLAGS="--no-interaction --no-suggest --ansi --no-dev"
COPY --from=composer:1.8 /usr/bin/composer /usr/bin/
COPY --from=source /app/composer.* ./
COPY --from=source /app/vendor ./vendor
# install in two steps to cache composer run based on composer.* files
RUN composer require --update-no-dev --no-scripts alcaeus/mongo-php-adapter ^1.1
RUN composer install $COMPOSER_FLAGS --no-scripts --no-autoloader
# copy rest of the project. copy in order that is least to most changed
COPY --from=source /app/webroot ./webroot
COPY --from=source /app/src ./src
COPY --from=source /app/config ./config
# second run to invoke (possible) scripts and create autoloader
RUN composer install $COMPOSER_FLAGS --classmap-authoritative
# not needed runtime, cleanup
RUN rm -vf composer.* vendor/composer/*.json
# build runtime image
FROM base
#ARG APPDIR=/app
ARG APPDIR=/var/www/xhgui
ARG WEBROOT=$APPDIR/webroot
WORKDIR $APPDIR
RUN mkdir -p cache && chmod -R 777 cache
COPY --from=build /app $APPDIR/