-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Committing .env file (https://symfony.com/doc/4.4/configuration.html) * Add container setup * Use modern Symfony style configuration * Copying build artifacts from nodejs image to nginx image * Making PHP-FPM port configurable * Add php entrypoint script * Update dependencies * Update grumphp configuration * Update symfony lock file * Add reference to source of script * Pass environmental variables to php-fpm * Use composer version 2 * Keep configuration backwards compatible
- Loading branch information
Showing
17 changed files
with
3,383 additions
and
963 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
###> symfony/framework-bundle ### | ||
.env | ||
.env.local | ||
/public/bundles/ | ||
/var/ | ||
!/var/repo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
############################################################# | ||
# PHP-FPM # | ||
############################################################# | ||
ARG PHP_VERSION=7.4 | ||
ARG NODE_VERSION=14 | ||
ARG NGINX_VERSION=1.21 | ||
|
||
FROM php:${PHP_VERSION}-fpm-alpine AS server-for-symfony-flex-php | ||
|
||
WORKDIR /srv/server-for-symfony-flex | ||
|
||
# persistent / runtime deps | ||
RUN apk add --no-cache \ | ||
acl \ | ||
bash \ | ||
file \ | ||
gettext \ | ||
git \ | ||
mariadb-client \ | ||
openssh-client \ | ||
libxml2 \ | ||
libuuid \ | ||
bind-tools \ | ||
; | ||
|
||
ARG XDEBUG_VERSION=3.0.4 | ||
|
||
RUN set -eux; \ | ||
apk add --no-cache --virtual .build-deps \ | ||
$PHPIZE_DEPS \ | ||
coreutils \ | ||
freetype-dev \ | ||
icu-dev \ | ||
libjpeg-turbo-dev \ | ||
libpng-dev \ | ||
libtool \ | ||
libwebp-dev \ | ||
libzip-dev \ | ||
mariadb-dev \ | ||
zlib-dev \ | ||
libxml2-dev \ | ||
util-linux-dev \ | ||
; \ | ||
\ | ||
docker-php-ext-configure gd --with-jpeg --with-webp --with-freetype; \ | ||
docker-php-ext-configure zip --with-zip; \ | ||
docker-php-ext-install -j$(nproc) \ | ||
exif \ | ||
gd \ | ||
intl \ | ||
pdo_mysql \ | ||
zip \ | ||
bcmath \ | ||
sockets \ | ||
soap \ | ||
; \ | ||
pecl install xdebug-${XDEBUG_VERSION}; \ | ||
pecl clear-cache; \ | ||
docker-php-ext-enable \ | ||
xdebug \ | ||
; \ | ||
runDeps="$( \ | ||
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ | ||
| tr ',' '\n' \ | ||
| sort -u \ | ||
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ | ||
)"; \ | ||
apk add --no-cache --virtual .sylius-phpexts-rundeps $runDeps; \ | ||
\ | ||
apk del .build-deps | ||
|
||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer | ||
|
||
COPY docker/php/php.ini /usr/local/etc/php/php.ini | ||
|
||
ARG FPM_PORT=9000 | ||
COPY docker/php/www.conf.template /usr/local/etc/php-fpm.d/www.conf.template | ||
RUN envsubst '${FPM_PORT}' < /usr/local/etc/php-fpm.d/www.conf.template > /usr/local/etc/php-fpm.d/www.conf | ||
RUN sed -i s/9000/$FPM_PORT/g /usr/local/etc/php-fpm.d/zz-docker.conf | ||
|
||
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser | ||
ENV COMPOSER_ALLOW_SUPERUSER=1 | ||
ENV PATH="${PATH}:/root/.composer/vendor/bin" | ||
|
||
COPY composer.json composer.lock symfony.lock ./ | ||
|
||
RUN set -eux; \ | ||
composer install --prefer-dist --no-autoloader --no-scripts --no-progress --no-dev; \ | ||
composer clear-cache | ||
|
||
COPY .env ./ | ||
COPY assets assets/ | ||
COPY bin bin/ | ||
COPY config config/ | ||
COPY public public/ | ||
COPY src src/ | ||
COPY templates templates/ | ||
|
||
RUN set -eux; \ | ||
mkdir -p var/cache var/log; \ | ||
chown -R www-data:www-data var/log; \ | ||
composer dump-autoload --classmap-authoritative; \ | ||
composer run-script post-install-cmd; \ | ||
chmod +x bin/console; \ | ||
sync | ||
|
||
COPY docker/php/php-entrypoint.sh /usr/local/bin/docker-entrypoint | ||
RUN chmod +x /usr/local/bin/docker-entrypoint | ||
|
||
ENTRYPOINT ["docker-entrypoint"] | ||
CMD ["php-fpm"] | ||
|
||
############################################################# | ||
# NODEJS # | ||
############################################################# | ||
FROM node:${NODE_VERSION}-alpine AS server-for-symfony-flex-nodejs | ||
|
||
WORKDIR /srv/server-for-symfony-flex | ||
|
||
RUN set -eux; \ | ||
apk add --no-cache \ | ||
g++ \ | ||
gcc \ | ||
git \ | ||
make \ | ||
python2 \ | ||
; | ||
|
||
COPY package.json package-lock.json webpack.config.js ./ | ||
COPY assets ./assets | ||
|
||
RUN set -eux; \ | ||
npm install ; \ | ||
npm cache clean --force | ||
|
||
RUN npm run build | ||
|
||
COPY docker/nodejs/docker-entrypoint.sh /usr/local/bin/docker-entrypoint | ||
RUN chmod +x /usr/local/bin/docker-entrypoint | ||
|
||
ENTRYPOINT ["docker-entrypoint"] | ||
CMD ["npm", "run", "watch"] | ||
|
||
############################################################# | ||
# NGINX # | ||
############################################################# | ||
FROM nginx:${NGINX_VERSION}-alpine AS server-for-symfony-flex-nginx | ||
|
||
WORKDIR /srv/server-for-symfony-flex | ||
|
||
COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf | ||
|
||
ARG NGINX_PORT=8080 | ||
ARG FPM_PORT=9000 | ||
COPY docker/nginx/conf.d/default.conf.template /etc/nginx/conf.d/default.conf.template | ||
RUN envsubst '${NGINX_PORT} ${FPM_PORT}' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf | ||
|
||
COPY --from=server-for-symfony-flex-php /srv/server-for-symfony-flex/public public/ | ||
COPY --from=server-for-symfony-flex-nodejs /srv/server-for-symfony-flex/public public/ | ||
|
||
RUN apk add --no-cache bash | ||
|
||
COPY docker/nginx/wait-for-it.sh / | ||
RUN chmod +x /wait-for-it.sh | ||
|
||
ENV FPM_PORT=$FPM_PORT | ||
CMD /wait-for-it.sh -t 0 localhost:$FPM_PORT -- nginx -g "daemon off;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.