-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathDockerfile
116 lines (92 loc) · 2.96 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
FROM php:8.2-fpm AS runtime
ENV APP_ENV=prod
ENV APP_DEBUG=0
RUN set -ex \
&& apt-get update -y \
&& apt-get upgrade -y \
&& apt-get install -y \
libzip4 \
libzip-dev \
libpng-tools \
libpng16-16 \
libpng-dev \
libxml2-dev \
libldap2-dev \
unzip \
zlib1g-dev \
&& docker-php-ext-install \
opcache \
pdo_mysql \
ldap \
zip \
xml \
gd \
intl \
# clean up
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false \
libzip-dev \
libpng-dev \
libxml2-dev \
zlib1g-dev \
libldap2-dev \
&& apt-get -y clean \
&& rm -rf /usr/src/* \
&& rm -rf /tmp/* \
&& rm -rf /var/tmp/* \
&& for logs in `find /var/log -type f`; do > ${logs}; done \
&& rm -rf /var/lib/apt/lists/* \
&& rm -f /var/cache/apt/*.bin \
&& rm -rf /usr/share/man/* \
/usr/share/groff/* \
/usr/share/info/* \
/usr/share/lintian/* \
/usr/share/linda/* \
/var/cache/man/* \
/usr/share/doc/*
FROM runtime AS devbox
RUN apt-get update -y
RUN apt-get install -y git unzip curl
# install composer
RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
# Add Node.js for webpack encore
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
RUN apt-get install -y nodejs
RUN npm install -g npm@latest
RUN pecl install pcov \
&& docker-php-ext-enable pcov
RUN git config --global --add safe.directory '*'
FROM devbox AS app_builder
COPY . /var/www/html
RUN npm install --legacy-peer-deps
# install the composer packages
WORKDIR /var/www/html
RUN composer install --no-dev --no-ansi
# should happen in entrypoint
#RUN composer dump-env prod
RUN mkdir -p var/log
RUN mkdir -p var/cache
RUN chmod ugo+rwX var/log var/cache
FROM app_builder AS assets_builder
RUN composer install --no-ansi
# Build webpack assets
RUN npm run build
FROM runtime AS production
COPY --from=app_builder /var/www/html/vendor /var/www/html/vendor
COPY --from=app_builder /var/www/html/public /var/www/html/public
COPY --from=app_builder /var/www/html/config /var/www/html/config
COPY --from=app_builder /var/www/html/bin /var/www/html/bin
COPY --from=app_builder /var/www/html/src /var/www/html/src
COPY --from=app_builder /var/www/html/templates /var/www/html/templates
COPY --from=app_builder /var/www/html/translations /var/www/html/translations
COPY --from=app_builder /var/www/html/var /var/www/html/var
COPY --from=app_builder /var/www/html/sql /var/www/html/sql
#COPY --from=app_builder /var/www/html/.env.local.php /var/www/html/.env.local.php
COPY --from=assets_builder /var/www/html/public/build /var/www/html/public/build
# replace entrypoint and add updating ca-certifcates
RUN echo "#!/bin/sh\nset -e\n/usr/sbin/update-ca-certificates\nexec \"\$@\"" > /usr/local/bin/docker-php-entrypoint
VOLUME /var/www/html/var/log /var/www/html/var/cache
EXPOSE 9000
WORKDIR /var/www/html
ENTRYPOINT ["docker-php-entrypoint"]
CMD ["php-fpm"]