Compare commits

...

10 Commits

21 changed files with 298 additions and 36 deletions

3
.env
View File

@ -4,6 +4,7 @@ PROJECT_ROOT=./public_html
LEGACY_ROOT=./public_html_legacy
LOG_ROOT=./log
SOLR_CORES=./solr_cores
SOLR_DATA=./solr_data
DB_IMPORTE_FILE_D8=./ressources/materio_d8.sql
DB_IMPORTE_FILE_D7=./ressources/materio_d7.sql
@ -12,3 +13,5 @@ DB_NAME=materio_d8
DB_LEGACY_NAME=materio_d7
DB_USERNAME=materio
DB_PASSWORD=materio
XDEBUG_INI=./ressources/xdebug.ini

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ log/*
*.sql
bin/syncfiles.sh
solr_cores/*
ressources/xdebug.ini

View File

@ -2,7 +2,7 @@ server {
listen 80 default_server;
root /var/www/html/d8.materio.com/public_html/web;
index index.html index.php;
server_name *.materio.com;
server_name *.materio.com materio.sish.me;
charset utf-8;
@ -35,4 +35,25 @@ server {
location ~ /\.ht {
deny all;
}
gzip on;
gzip_types application/json;
gzip_http_version 1.0;
gzip_static on;
## PWA serviceworker support.
# location ~ ^/pwa/[0-9a-z]+/serviceworker.js {
# try_files $uri /index.php?$query_string;
# }
## PWA manifest support.
location ~ /manifest.json {
try_files $uri /index.php?$query_string;
}
location ~* \.(js|css|ttf|json)$ {
gzip_static on;
}
}

34
Docker/npm/Dockerfile Normal file
View File

@ -0,0 +1,34 @@
FROM node:lts-alpine
RUN apk update && apk --no-cache add shadow && \
usermod -u 1001 node && \
groupmod -g 1001 node
RUN find / -group 1000 -exec chgrp -h node {} \;
RUN find / -user 1000 -exec chown -h node {} \;
RUN apk add --no-cache openssh sshpass
ARG USER_UID
ARG USER_UNAME
ARG USER_GID
ARG USER_GNAME
# RUN addgroup -g 1000 gdp && \
# adduser -h /home/gdp -D -u 1000 gdp && \
RUN adduser -u ${USER_UID} -G users -s /bin/sh -D ${USER_UNAME}
# chown -R gdp:gdp /home/gdp
USER ${USER_UNAME}
COPY ./bashrc /home/${USER_UNAME}/.bashrc
COPY ./inputrc /home/${USER_UNAME}/.inputrc
COPY ./client-entrypoint.sh /usr/local/bin
USER root
RUN chmod +x /usr/local/bin/client-entrypoint.sh
USER ${USER_UNAME}
CMD ["/bin/sh","/usr/local/bin/client-entrypoint.sh"]

3
Docker/npm/bashrc Normal file
View File

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

View File

@ -0,0 +1,19 @@
#!/bin/sh
# cat /etc/passwd|grep 1000
cd /app
# echo "Cleaning node_modules"
# rm -rf node_modules
#
# echo "Cleaning npm cache"
# npm cache clean --f
#
# echo "Npm install"
# npm install
echo "Npm Clean Install"
npm ci
echo "Run npm dev"
npm run dev

2
Docker/npm/inputrc Normal file
View File

@ -0,0 +1,2 @@
set show-all-if-ambiguous on
set completion-ignore-case on

View File

@ -31,12 +31,13 @@ RUN export COMPOSER_HOME=/usr/local/composer && \
-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
# todo this is not building any more, do i really need this ? (22-10-2021)
# 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

View File

@ -1,15 +1,17 @@
FROM php:7.3-fpm
FROM php:7.4-fpm
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng-dev \
mysql-client \
default-mysql-client \
zip \
net-tools iproute2 \
libzip-dev && \
cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini && \
# docker-php-ext-install -j$(nproc) iconv && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ && \
apt-get install -y imagemagick libmagickwand-dev && \
pecl install imagick && docker-php-ext-enable imagick && \
docker-php-ext-install -j$(nproc) gd && \
@ -18,7 +20,7 @@ RUN apt-get update && apt-get install -y \
docker-php-ext-install bcmath && \
apt-get install -y git vim && \
pecl install redis-4.3.0 && \
pecl install xdebug-2.7.0 && \
pecl install xdebug-3.1.3 && \
docker-php-ext-enable redis xdebug
RUN export COMPOSER_HOME=/usr/local/composer && \
@ -31,12 +33,13 @@ RUN export COMPOSER_HOME=/usr/local/composer && \
-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
# todo this is not building any more, do i really need this ? (22-10-2021)
# 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
@ -45,8 +48,6 @@ 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
ARG USER_UID
ARG USER_UNAME
@ -56,6 +57,7 @@ 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} &&\
echo ${USER_UNAME}:${USER_UNAME} | chpasswd &&\
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} \
@ -67,4 +69,23 @@ RUN if getent group ${USER_GNAME} ; then groupdel ${USER_GNAME}; fi &&\
COPY ./bashrc /home/${USER_UNAME}/.bashrc
COPY ./inputrc /home/${USER_UNAME}/.inputrc
USER ${USER_UNAME}
# https://dev.to/s1ntaxe770r/how-to-setup-ssh-within-a-docker-container-i5i
RUN apt-get install -y openssh-server openssh-client
# RUN service ssh enable
RUN service ssh start
# as sshd will be launchd as ${USER_UNAME}
RUN chown -R ${USER_UNAME} /etc/ssh
EXPOSE 22
# CMD ["/usr/sbin/sshd","-D"]
# https://stackoverflow.com/questions/36964652/ssh-in-docker-container-causes-http-404
# use \n to make the content into multiple lines
RUN printf "whoami\nphp-fpm -D\n/usr/sbin/sshd -D" >> /start.sh
RUN chmod +x /start.sh
CMD ["/start.sh"]
# USER ${USER_UNAME}

View File

@ -1,4 +1,4 @@
PS1='\e[36m\e[1mPHP-7.0\e[0m:\e[90m\w\e[0m\n$ '
PS1='\e[36m\e[1mPHP-7.4\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,4 @@
memory_limit = 2048M
memory_limit = 8192M
upload_max_filesize = 50M
post_max_size = 50M
max_execution_time = 150

3
Docker/redis/Dockerfile Normal file
View File

@ -0,0 +1,3 @@
FROM redis:4
COPY redis.conf /usr/local/etc/redis/redis.conf
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]

2
Docker/redis/redis.conf Normal file
View File

@ -0,0 +1,2 @@
maxmemory 1gb
maxmemory-policy allkeys-lru

View File

@ -1,3 +1,3 @@
FROM solr:8
FROM solr:8.10
# COPY --chown=solr:solr ./server /opt/solr/server/solr/

View File

@ -7,6 +7,8 @@ USER_UNAME := $(shell id -un)
USER_GID := $(shell id -g)
USER_GNAME := $(shell id -gn)
DATE_NOW := $(shell date '+%Y-%m-%d_%H%M%S')
export USER_UID
export USER_UNAME
export USER_GID
@ -18,6 +20,28 @@ build:
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)
buildsolrnc:
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) solr-new
buildphp:
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) php
buildphpnc:
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) php
buildnginx:
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) nginx
buildnginxnc:
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) nginx
buildnpm:
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) npm
buildnpmnc:
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) npm
up:
docker-compose up -d
@ -30,17 +54,53 @@ ps:
logs:
docker-compose logs -f
logs_redis:
docker-compose logs -f redis
down:
docker-compose down
restart_solr:
docker-compose restart solr-new
restart_redis:
docker-compose restart redis
restart_php:
docker-compose restart php
restart_npm :
docker-compose restart npm
exec_php:
docker exec -it materiod8_php_1 bash
docker exec -it materiod8-php-1 bash
exec_nginx:
docker exec -it materiod8-nginx-1 bash
exec_npm:
docker exec -it materiod8-npm-1 sh
exec_mysql:
docker exec -it materiod8_mysql_1 bash
docker exec -it materiod8-mysql-1 bash
exec_solr:
docker exec -it materiod8_solr-new_1 bash
docker exec -it materiod8-solr-new-1 bash
exec_solrlegacy:
docker exec -it materiod8-solr-legacy-1 bash
phplegacy:
docker exec -it materiod8_php-legacy_1 bash
docker exec -it materiod8-php-legacy-1 bash
redis:
docker exec -it materiod8-redis-1 bash
update_solr_conf:
bin/update_solr_config.sh
dump_d8_db:
docker exec materiod8-mysql-1 sh -c 'exec mysqldump -uroot -pmaterio materio_d8' > ./ressources/materio-d8-$(DATE_NOW)-local.sql
sish:
ssh -p 2222 -R materio:80:dev:8890 CT-sish.me

11
bin/update_solr_config.sh Executable file
View File

@ -0,0 +1,11 @@
#! /bin/bash
docker exec -i materiod8-php-1 drush cdel search_api_solr.solr_field_type.text_edgestring_ascii_und_6_0_0
docker exec -i materiod8-php-1 drush cdel search_api_solr.solr_field_type.text_string_ascii_und_6_0_0
docker exec -i materiod8-php-1 drush dre materio_sapi
docker exec -i materiod8-php-1 drush solr-gsc database_search_autocomplete config.zip
mkdir ressources/solr/
mv public_html/web/config.zip ressources/solr/
unzip -o ressources/solr/config.zip -d var_solr/data/materio/conf
unzip -o ressources/solr/config.zip -d var_solr/data/materio_autocomplete/conf
docker-compose restart solr-new

View File

@ -35,9 +35,10 @@ services:
redis:
image: redis:4
command: ["redis-server", "--appendonly", "yes"]
command: redis-server /usr/local/etc/redis.conf
volumes:
- redis-data:/data
- ./Docker/redis/redis.conf:/usr/local/etc/redis.conf
networks:
- redis
ports:
@ -45,9 +46,10 @@ services:
redis-legacy:
image: redis:3
command: ["redis-server", "--appendonly", "yes"]
command: redis-server /usr/local/etc/redis.conf
volumes:
- redis-legacy-data:/data
- ./Docker/redis/redis.conf:/usr/local/etc/redis.conf
networks:
- redis
ports:
@ -55,11 +57,17 @@ services:
solr-new:
build: ./Docker/solr/
# user: ${USER_UID}:${USER_GID}
environment:
- SOLR_HOME=/opt/solr/server/solr
- SOLR_HOME=/var/solr
volumes:
- "${SOLR_CORES}:/opt/solr/server/solr"
# - solr-cores:/opt/solr/server/solr
- ./var_solr:/var/solr
# - solr-data: /var/solr
# - "${SOLR_CORES}:/var/solr/data"
# - "${SOLR_DATA}:/var/solr"
# - "${SOLR_CORES}:/opt/solr/server/solr"
command:
- solr-precreate
networks:
- solr
ports:
@ -79,18 +87,26 @@ services:
build: ./Docker/php/
expose:
- 9000
- 9001
- 22
user: ${USER_UID}:${USER_GID}
volumes:
- 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"
- "${XDEBUG_INI}:/usr/local/etc/php/conf.d/xdebug.ini"
working_dir: "/var/www/html/d8.materio.com/public_html"
networks:
- database
- redis
- server
- solr
# for xdebug
# https://github.com/docker/for-linux/issues/264#issuecomment-965465879
extra_hosts:
- host.docker.internal:host-gateway
# mem_limit: 512m
depends_on:
- mysql
- mysql-legacy
@ -156,6 +172,20 @@ services:
depends_on:
- php-legacy
npm:
build: ./Docker/npm
user: ${USER_UID}:${USER_GID}
volumes:
- "${PROJECT_ROOT}:/app"
- npm-user-data:/home/${USER_UNAME}
# ports:
# - 8788:8788
working_dir: "/app"
networks:
- server
environment:
- DRUPAL_ROOT=/var/www/html/d8.materio.com/public_html
- USER_UNAME=${USER_UNAME}
volumes:
php-user-data:
@ -165,7 +195,8 @@ volumes:
redis-data:
redis-legacy-data:
solr-cores-legacy:
solr-cores:
# solr-cores:
npm-user-data:
networks:
database:

@ -1 +1 @@
Subproject commit a95d44c92baea1050b3dde1e8dc8a08825a68c0c
Subproject commit 44df557f291754d513c4ad73879ef34af925bd68

@ -1 +1 @@
Subproject commit 094d6ec86f27a5eee82650daf1398b6147e8d761
Subproject commit 49a09444126bec720fcc084f9b55e54f49af4271

View File

@ -0,0 +1,50 @@
[xdebug]
; xdebug.remote_enable=1
xdebug.mode=debug
;Should use host.docker.internal but not working on linux
; xdebug.remote_host=172.20.0.1
; Replaced by xdebug.client_host.
xdebug.client_host=172.20.0.1
;Not working on docker context
; xdebug.remote_connect_back=0
; Replaced by xdebug.discover_client_host.
xdebug.discover_client_host=0
;9000 is already bound by php-fpm
; xdebug.remote_port=9001
; xdebug.remote_port #
; Replaced by xdebug.client_port.
; The default value has also changed from 9000 to 9003.
xdebug.client_port=9001
xdebug.remote_handler=dbgp
; xdebug.remote_mode=req
; xdebug.remote_mode #
; For the req value (the original default), use xdebug.mode=debug with xdebug.start_with_request=trigger. If the original xdebug.remote_autostart behaviour is necessary, use xdebug.start_with_request=yes instead of trigger.
; For the jit value, use xdebug.mode=debug and xdebug.start_upon_error=yes.
; xdebug.remote_autostart=true
; Use xdebug.mode=debug with xdebug.start_with_request=yes
xdebug.start_with_request=yes
; ?=XDEBUG_SESSION_START=1
;Log file is mounted on volume so you can follow it
; xdebug.remote_log=/var/log/xdebug-error.log
; Replaced by xdebug.log, which also includes log messages beyond Step Debugging.
xdebug.log=/var/log/xdebug-error.log
; xdebug.profiler_enable=0
; xdebug.profiler_enable_trigger=1
; Use xdebug.mode=profile with xdebug.start_with_request=trigger.
; xdebug.profiler_output_dir=/var/log/
; Use the generic xdebug.output_dir setting.
; Example: http://localhost:8080/test?XDEBUG_PROFILE=1

@ -1 +1 @@
Subproject commit a84090562cdfd454e920a336169443c94f05e688
Subproject commit afd61c4690f97d99034b8e394bf33da5c9780d39