-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
90 lines (82 loc) · 3.8 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
FROM debian:10-slim
LABEL maintainer="pierstoval@gmail.com"
WORKDIR /srv
CMD ["/usr/local/bin/symfony", "serve", "--dir=/srv", "--allow-http", "--port=8000"]
EXPOSE 8000
ENTRYPOINT ["/bin/entrypoint"]
ENV PHP_VERSION=8.1 \
GOSU_VERSION=1.17 \
PANTHER_NO_SANDBOX=1 \
PATH=/home/.composer/vendor/bin:$PATH \
PATH=/home/.config/composer/vendor/bin:$PATH \
RUN_USER="_www"
COPY bin/entrypoint.sh /bin/entrypoint
COPY etc/php.ini /etc/php/${PHP_VERSION}/fpm/conf.d/99-custom.ini
COPY etc/php.ini /etc/php/${PHP_VERSION}/cli/conf.d/99-custom.ini
RUN set -xe \
&& apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
ca-certificates \
git \
curl \
wget \
openssh-client \
unzip \
chromium-driver `# For symfony/panther` \
dialog apt-utils `# Prevents having this issue: https://github.com/moby/moby/issues/27988` \
\
&& `# Deb Sury PHP repository` \
&& apt-get -y install apt-transport-https lsb-release ca-certificates curl \
&& wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg \
&& sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' \
&& apt-get update \
\
&& `# PHP and extensions` \
&& apt-get install -y \
php${PHP_VERSION} \
php${PHP_VERSION}-cli \
php${PHP_VERSION}-common \
php${PHP_VERSION}-curl \
php${PHP_VERSION}-fpm \
php${PHP_VERSION}-gd \
php${PHP_VERSION}-intl \
php${PHP_VERSION}-mbstring \
php${PHP_VERSION}-mysql \
php${PHP_VERSION}-opcache \
php${PHP_VERSION}-readline \
php${PHP_VERSION}-xml \
php${PHP_VERSION}-zip \
php${PHP_VERSION}-xdebug \
php${PHP_VERSION}-apcu \
\
&& `# User management for entrypoint` \
&& curl -L -s -o /bin/gosu https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture | awk -F- '{ print $NF }') \
&& chmod +x /bin/gosu \
&& mkdir -p /home \
&& groupadd ${RUN_USER} \
&& adduser --home=/home --shell=/bin/bash --ingroup=${RUN_USER} --disabled-password --quiet --gecos "" --force-badname ${RUN_USER} \
&& chown ${RUN_USER}:${RUN_USER} /home \
\
&& `# Composer` \
&& (curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer) \
\
&& `# Static analysis` \
&& runuser -l ${RUN_USER} -c 'composer global --no-interaction --no-progress require phpstan/phpstan' \
&& runuser -l ${RUN_USER} -c 'composer global --no-interaction --no-progress require phpstan/phpstan-symfony' \
&& runuser -l ${RUN_USER} -c 'composer global --no-interaction --no-progress require phpstan/phpstan-doctrine' \
&& runuser -l ${RUN_USER} -c 'composer global --no-interaction --no-progress require phpstan/phpstan-phpunit' \
&& runuser -l ${RUN_USER} -c 'composer global --no-interaction --no-progress require phpstan/phpstan-deprecation-rules' \
&& curl -L https://cs.symfony.com/download/php-cs-fixer-v3.phar -o /usr/local/bin/php-cs-fixer && chmod a+x /usr/local/bin/php-cs-fixer \
\
&& `# Symfony CLI` \
&& (wget https://get.symfony.com/cli/installer -O - | bash) \
&& mv /root/.symfony5/bin/symfony /usr/local/bin/symfony \
&& chown ${RUN_USER}:${RUN_USER} /usr/local/bin/symfony \
\
&& `# Clean apt and remove unused libs/packages to make image smaller` \
&& runuser -l $RUN_USER -c 'composer clearcache' \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $BUILD_LIBS \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/www/* /var/cache/* /home/.composer/cache