diff --git a/.env b/.env index fea4d39..b465c9d 100644 --- a/.env +++ b/.env @@ -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 diff --git a/Docker/nginx/default.conf b/Docker/nginx/default.conf index b1faff8..ac1c935 100644 --- a/Docker/nginx/default.conf +++ b/Docker/nginx/default.conf @@ -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; @@ -43,9 +43,9 @@ server { gzip_static on; ## PWA serviceworker support. - location ~ ^/pwa/[0-9a-z]+/serviceworker.js { - try_files $uri /index.php?$query_string; - } + # location ~ ^/pwa/[0-9a-z]+/serviceworker.js { + # try_files $uri /index.php?$query_string; + # } ## PWA manifest support. location ~ /manifest.json { diff --git a/Docker/npm/Dockerfile b/Docker/npm/Dockerfile index 8915447..e48e0b9 100644 --- a/Docker/npm/Dockerfile +++ b/Docker/npm/Dockerfile @@ -7,6 +7,8 @@ RUN apk update && apk --no-cache add shadow && \ 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 @@ -23,6 +25,8 @@ 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 diff --git a/Docker/php-legacy/Dockerfile b/Docker/php-legacy/Dockerfile index a03bcf7..21f546b 100644 --- a/Docker/php-legacy/Dockerfile +++ b/Docker/php-legacy/Dockerfile @@ -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 diff --git a/Docker/php/Dockerfile b/Docker/php/Dockerfile index 614d06d..48cffd4 100644 --- a/Docker/php/Dockerfile +++ b/Docker/php/Dockerfile @@ -1,16 +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 && \ @@ -19,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 && \ @@ -32,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 @@ -46,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 @@ -57,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} \ @@ -68,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} \ No newline at end of file diff --git a/Docker/php/bashrc b/Docker/php/bashrc index 70f55f9..e82cf1b 100644 --- a/Docker/php/bashrc +++ b/Docker/php/bashrc @@ -1,4 +1,4 @@ -PS1='\e[36m\e[1mPHP-7.3\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' diff --git a/Docker/redis/Dockerfile b/Docker/redis/Dockerfile new file mode 100644 index 0000000..cdd3571 --- /dev/null +++ b/Docker/redis/Dockerfile @@ -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" ] \ No newline at end of file diff --git a/Docker/redis/redis.conf b/Docker/redis/redis.conf new file mode 100644 index 0000000..9cd0f14 --- /dev/null +++ b/Docker/redis/redis.conf @@ -0,0 +1,2 @@ +maxmemory 1gb +maxmemory-policy allkeys-lru \ No newline at end of file diff --git a/Docker/solr/Dockerfile b/Docker/solr/Dockerfile index fedda73..cee8770 100644 --- a/Docker/solr/Dockerfile +++ b/Docker/solr/Dockerfile @@ -1,3 +1,3 @@ -FROM solr:8 +FROM solr:8.10 # COPY --chown=solr:solr ./server /opt/solr/server/solr/ diff --git a/Makefile b/Makefile index fe75bda..69a4b37 100644 --- a/Makefile +++ b/Makefile @@ -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,26 +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 + 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 + docker exec -it materiod8-redis-1 bash update_solr_conf: - bin/update_solr_config.sh \ No newline at end of file + 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 \ No newline at end of file diff --git a/bin/update_solr_config.sh b/bin/update_solr_config.sh index 8b922c9..0e62a73 100755 --- a/bin/update_solr_config.sh +++ b/bin/update_solr_config.sh @@ -1,8 +1,11 @@ #! /bin/bash -docker exec -i materiod8_php_1 drush solr-gsc database_search_autocomplete config.zip +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 solr_cores/materio/conf -unzip -o ressources/solr/config.zip -d solr_cores/materio_autocomplete/conf +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 diff --git a/docker-compose.yml b/docker-compose.yml index 3616148..9b95c1d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: @@ -80,6 +88,7 @@ services: expose: - 9000 - 9001 + - 22 user: ${USER_UID}:${USER_GID} volumes: - php-user-data:/home/${USER_UNAME} @@ -93,9 +102,11 @@ services: - redis - server - solr - # extra_hosts: - # - "host.docker.internal:192.168.144.4" - # - "testhost:192.168.0.21" + # 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 @@ -167,9 +178,14 @@ services: volumes: - "${PROJECT_ROOT}:/app" - npm-user-data:/home/${USER_UNAME} - ports: - - 8788:8788 + # 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: @@ -179,7 +195,7 @@ volumes: redis-data: redis-legacy-data: solr-cores-legacy: - solr-cores: + # solr-cores: npm-user-data: networks: diff --git a/public_html b/public_html index 2b67b22..44df557 160000 --- a/public_html +++ b/public_html @@ -1 +1 @@ -Subproject commit 2b67b22ce5c29948d9f2caaedd30ee6b15900fb4 +Subproject commit 44df557f291754d513c4ad73879ef34af925bd68 diff --git a/ressources/xdebug.ini.example b/ressources/xdebug.ini.example index 51277b6..9053d17 100644 --- a/ressources/xdebug.ini.example +++ b/ressources/xdebug.ini.example @@ -1,13 +1,50 @@ [xdebug] -xdebug.remote_enable=1 +; xdebug.remote_enable=1 +xdebug.mode=debug ;Should use host.docker.internal but not working on linux -xdebug.remote_host=172.20.0.1 + +; 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 +; 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=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_autostart=true + +; 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 +; 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 diff --git a/solr_cores b/solr_cores index 82bc5b7..afd61c4 160000 --- a/solr_cores +++ b/solr_cores @@ -1 +1 @@ -Subproject commit 82bc5b7e78529f3e26d5684b061c2aaf8ee1f552 +Subproject commit afd61c4690f97d99034b8e394bf33da5c9780d39