improved php using current user instead of root, improved timeout limit

This commit is contained in:
Bachir Soussi Chiadmi 2019-11-06 12:46:11 +01:00
parent ceaf3963b0
commit 5eb02ec37b
9 changed files with 121 additions and 21 deletions

View File

@ -29,7 +29,7 @@ server {
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
# fastcgi_read_timeout 150;
fastcgi_read_timeout 150;
}
location ~ /\.ht {

View File

@ -1,5 +1,4 @@
FROM php:5.6-fpm
FROM php:7.3-fpm
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
@ -7,27 +6,44 @@ RUN apt-get update && apt-get install -y \
libmcrypt-dev \
libpng-dev \
mysql-client \
zip && \
docker-php-ext-install -j$(nproc) iconv mcrypt && \
zip \
libzip-dev && \
# docker-php-ext-install -j$(nproc) iconv && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
apt-get install -y imagemagick libmagickwand-dev && \
pecl install imagick && docker-php-ext-enable imagick && \
docker-php-ext-install -j$(nproc) gd && \
docker-php-ext-install pdo_mysql zip && \
docker-php-ext-install opcache && \
docker-php-ext-install bcmath && \
apt-get install -y git vim && \
pecl install redis-3.1.0 && \
pecl install xdebug-2.5.0 && \
docker-php-ext-enable redis xdebug && \
export COMPOSER_HOME=/usr/local/composer && \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
composer global require drush/drush:8 && \
composer global install && \
ln -s /usr/local/composer/vendor/drush/drush/drush /usr/local/bin/drush
pecl install redis-4.3.0 && \
pecl install xdebug-2.7.0 && \
docker-php-ext-enable redis xdebug
RUN export COMPOSER_HOME=/usr/local/composer && \
curl -sS https://getcomposer.org/installer \
| php -- --install-dir=/usr/local/bin --filename=composer && \
curl https://drupalconsole.com/installer \
-L -o /usr/local/bin/drupal && \
chmod +x /usr/local/bin/drupal && \
curl https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar \
-L -o /usr/local/bin/drush && \
chmod +x /usr/local/bin/drush
RUN apt-get install -y curl && \
curl -sL https://deb.nodesource.com/setup_11.x | bash - && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
apt-get install -y nodejs yarn
RUN apt-get install -y rsyslog
COPY ./rsyslog-drupal.conf /etc/rsyslog.d/drupal.conf
# ENTRYPOINT ["sh", "-c", "service rsyslog start ; tail -f /dev/null"]
COPY ./php-custom.ini /usr/local/etc/php/conf.d/php-custom.ini
# COPY ./php-fpm-custom.conf /usr/local/etc/php-fpm.d/php-fpm-custom.conf
COPY ./bashrc /root/.bashrc
COPY ./inputrc /root/.inputrc

View File

@ -1,4 +1,4 @@
PS1='\e[36m\e[1mPHP-5.6\e[0m:\e[90m\w\e[0m\n$ '
PS1='\e[36m\e[1mPHP-7.0\e[0m:\e[90m\w\e[0m\n$ '
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'

View File

@ -1,4 +1,7 @@
memory_limit = 526M
memory_limit = 2048M
upload_max_filesize = 50M
post_max_size = 50M
;max_execution_time = 150
; Log level
; Possible Values: alert, error, warning, notice, debug

View File

@ -45,5 +45,26 @@ COPY ./rsyslog-drupal.conf /etc/rsyslog.d/drupal.conf
COPY ./php-custom.ini /usr/local/etc/php/conf.d/php-custom.ini
# COPY ./php-fpm-custom.conf /usr/local/etc/php-fpm.d/php-fpm-custom.conf
COPY ./bashrc /root/.bashrc
COPY ./inputrc /root/.inputrc
# COPY ./bashrc /root/.bashrc
# COPY ./inputrc /root/.inputrc
ARG USER_UID
ARG USER_UNAME
ARG USER_GID
ARG USER_GNAME
RUN if getent group ${USER_GNAME} ; then groupdel ${USER_GNAME}; fi &&\
groupadd -g ${USER_GID} ${USER_GNAME} &&\
useradd -l -u ${USER_UID} -g ${USER_GNAME} ${USER_UNAME} &&\
install -d -m 0755 -o ${USER_UNAME} -g ${USER_GNAME} /home/${USER_UNAME} &&\
chown --changes --silent --no-dereference --recursive \
--from=33:33 ${USER_UID}:${USER_GID} \
/home/${USER_UNAME}
# /.composer \
# /var/run/php-fpm \
# /var/lib/php/sessions \
COPY ./bashrc /home/${USER_UNAME}/.bashrc
COPY ./inputrc /home/${USER_UNAME}/.inputrc
USER ${USER_UNAME}

View File

@ -1,7 +1,7 @@
memory_limit = 1024M
memory_limit = 2048M
upload_max_filesize = 50M
post_max_size = 50M
;max_execution_time = 150
max_execution_time = 150
; Log level
; Possible Values: alert, error, warning, notice, debug

34
Makefile Normal file
View File

@ -0,0 +1,34 @@
#!/usr/bin/make
SHELL = /bin/sh
USER_UID := $(shell id -u)
USER_UNAME := $(shell id -un)
USER_GID := $(shell id -g)
USER_GNAME := $(shell id -gn)
export USER_UID
export USER_UNAME
export USER_GID
export USER_GNAME
build:
docker-compose build --build-arg USER_UID=$(USER_UID) --build-arg USER_UNAME=$(USER_UNAME) --build-arg USER_GID=$(USER_GID) --build-arg USER_GNAME=$(USER_GNAME)
buildnc:
docker-compose build --no-cache --build-arg USER_UID=$(USER_UID) --build-arg USER_UNAME=$(USER_UNAME) --build-arg USER_GID=$(USER_GID) --build-arg USER_GNAME=$(USER_GNAME)
up:
docker-compose up -d
upbuild:
docker-compose up -d --build
down:
docker-compose down
php:
docker exec -it materiod8_php_1 bash
phplegacy:
docker exec -it materiod8_php-legacy_1 bash

View File

@ -111,6 +111,31 @@ sudo docker exec -it materiod8_mysql_1 bash
```
once inside the mysql container you can use mysql command to drop then create and load the db with your file
## Makefile
```makefile
build:
docker-compose build --build-arg USER_UID=$(USER_UID) --build-arg USER_UNAME=$(USER_UNAME) --build-arg USER_GID=$(USER_GID) --build-arg USER_GNAME=$(USER_GNAME)
buildnc:
docker-compose build --no-cache --build-arg USER_UID=$(USER_UID) --build-arg USER_UNAME=$(USER_UNAME) --build-arg USER_GID=$(USER_GID) --build-arg USER_GNAME=$(USER_GNAME)
up:
docker-compose up -d
upbuild:
docker-compose up -d --build
down:
docker-compose down
php:
docker exec -it materiod8_php_1 bash
phplegacy:
docker exec -it materiod8_php-legacy_1 bash
```
# sources
https://www.ostraining.com/blog/drupal/docker/

View File

@ -77,8 +77,9 @@ services:
build: ./Docker/php/
expose:
- 9000
user: ${USER_UID}:${USER_GID}
volumes:
- php-root-data:/root
- php-user-data:/home/${USER_UNAME}
- "${PROJECT_ROOT}:/var/www/html/d8.materio.com/public_html"
- "${LEGACY_ROOT}:/var/www/html/d7.materio.com/public_html"
- "${LOG_ROOT}/php:/var/log:rw"
@ -155,7 +156,7 @@ services:
volumes:
php-root-data:
php-user-data:
php-legacy-root-data:
db-data:
db-data-legacy: