diff --git a/.gitignore b/.gitignore index 74d774790..48ca5b7eb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ src/* !src/composer.* !.gitignore !**/.gitkeep +mutagen.*.lock diff --git a/Dockerfile b/Dockerfile index ce57278a0..d41091088 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,5 @@ # hadolint ignore=DL3007 FROM scandipwa/php:latest -LABEL maintainer="Scandiweb " -LABEL authors="Jurijs Jegorovs jurijs+oss@scandiweb.com; Ilja Lapkovskis info@scandiweb.com" # Set bash by default SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -60,7 +58,7 @@ RUN { \ echo 'from no-reply@docker'; \ echo 'account default'; \ } | tee /etc/msmtprc - + # Start script, executed upon container creation from image COPY deploy/start.sh /start.sh RUN chmod +x /start.sh @@ -85,4 +83,4 @@ CMD ["/start.sh"] RUN echo "$(tput setaf 3)php, composer$(tput sgr0)";\ composer diagnose; printf "\n";\ echo "$(tput setaf 3)nodejs, npm$(tput sgr0)";\ - npm doctor; printf "\n"; \ No newline at end of file + npm doctor; printf "\n"; diff --git a/Makefile b/Makefile index b97dc22d4..5975c7d23 100644 --- a/Makefile +++ b/Makefile @@ -1,57 +1,11 @@ # Define available commands -.PHONY: build full-rebuild push up recreate down cert pull \ - down-rm-volumes applogs logs flushall core-up core-down core-logs \ - exec +.PHONY: cert # Variables current_dir := $(shell pwd) uid := $(shell id -u) gid := $(shell id -g) -# Warning! Do not use soft tabs! -up: - docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml up -d - -core-up: - docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.core.yml -f docker-compose.ssl.yml up -d - -build: - docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml build - -pull: - docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml pull - -down: - docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml down --remove-orphans - -core-down: - docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.core.yml -f docker-compose.ssl.yml down --remove-orphans - -down-rm-volumes: - docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml down -v - -applogs: - docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml logs -f app - -logs: - docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml logs -f - -core-logs: - docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.core.yml -f docker-compose.ssl.yml logs -f --tail 100 - -full-rebuild: - docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml build --pull --no-cache - -flushall: - docker-compose -f docker-compose.yml -f docker-compose.local.yml exec varnish varnishadm "ban req.url ~ /" - docker-compose -f docker-compose.yml -f docker-compose.local.yml exec redis redis-cli FLUSHALL - -exec: - docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.core.yml -f docker-compose.ssl.yml exec -u user app $(filter-out $@,$(MAKECMDGOALS)) - -%: - @true - cert: mkdir -p opt/cert docker run -it --rm --init \ diff --git a/build/frontend/Dockerfile b/build/frontend/Dockerfile index be5d49af4..0bebc8d01 100644 --- a/build/frontend/Dockerfile +++ b/build/frontend/Dockerfile @@ -1,16 +1,11 @@ ARG NODEJS_VERSION=10 FROM node:$NODEJS_VERSION -LABEL authors="Alfred Genkins, Ilja Lapkovskis info@scandiweb.com" -ARG BASEPATH=/var/www/public +LABEL maintainer="Alfreds Genkins alfreds@scandipwa.com" +LABEL author="Ilja Lapkovskis info@scandiweb.com" -# Set working directory so any relative configuration or scripts wont fail -WORKDIR $BASEPATH +RUN npm install pm2 forever -g COPY start.sh /start.sh -COPY start-core.sh /start-core.sh RUN chmod +x /start.sh -RUN chmod +x /start-core.sh - -CMD ["/bin/bash", "/start.sh"] diff --git a/build/frontend/start-core.sh b/build/frontend/start-core.sh deleted file mode 100644 index ae3178bd0..000000000 --- a/build/frontend/start-core.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -npm ci -npm install pm2 forever -g -pm2-runtime process-core.yml diff --git a/build/frontend/start.sh b/build/frontend/start.sh index 19a1cb9a5..cf1b19a5b 100644 --- a/build/frontend/start.sh +++ b/build/frontend/start.sh @@ -1,4 +1,58 @@ #!/bin/bash + +mutagen="0" +core="0" + +helpFunction() +{ + echo "" + echo "Usage: $0 [-M] [-C]" + echo -e "\t-M Wait for Mutagen to sync files before start" + echo -e "\t-C Start core watching script" + exit 1 # Exit script after printing help +} + +while getopts "MC" opt +do + case "$opt" in + M ) mutagen="1" ;; + C ) core="1" ;; + ? ) helpFunction ;; + esac +done + +PATH_TO_THEME="/var/www/public" + +if [ "$core" = "1" ] +then + PATH_TO_THEME="$PATH_TO_THEME/localmodules/base-theme/" +else + PATH_TO_THEME="$PATH_TO_THEME/app/design/frontend/Scandiweb/pwa/" +fi + +if [ -d $PATH_TO_THEME ] +then + cd $PATH_TO_THEME; +else + echo "ERROR: $PATH_TO_THEME is empty!" + exit 1 +fi + +if [ "$mutagen" = "1" ] +then + echo "Waiting for Mutagen to sync initial files" + while ! [ -f ./package.json -a -f ./package-lock.json ] + do + sleep 2 + done +fi + +echo "Installing node modules" npm ci -npm install pm2 forever -g -pm2-runtime process.yml + +if [ "$core" = "1" ] +then + pm2-runtime process-core.yml +else + pm2-runtime process.yml +fi diff --git a/build/php/Dockerfile b/build/php/Dockerfile index 679c3eea8..648e2ab38 100644 --- a/build/php/Dockerfile +++ b/build/php/Dockerfile @@ -1,5 +1,6 @@ FROM ubuntu:bionic -LABEL maintainer="Ilja Lapkovskis ilja+oss@scandiweb.com" +LABEL author="Ilja Lapkovskis ilja+oss@scandiweb.com" +LABEL maintainer="Alfreds Genkins alfreds@scandipwa.com" ARG COMPOSER_HOME=/var/lib/composer ARG COMPOSER_VERSION=latest @@ -55,7 +56,7 @@ ENV PHPIZE_DEPS \ libxslt1-dev \ libsodium-dev \ libargon2-0-dev - + # Update server packages to latest versions RUN apt-get -qq update &&\ apt-get -qq dist-upgrade -y &&\ diff --git a/build/rendertron/Dockerfile b/build/rendertron/Dockerfile index a6c2b64db..6608a1115 100644 --- a/build/rendertron/Dockerfile +++ b/build/rendertron/Dockerfile @@ -1,5 +1,7 @@ FROM node:10 +LABEL maintainer="Alfreds Genkins alfreds@scandipwa.com" + # Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others) # Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer # installs, work. diff --git a/build/varnish/Dockerfile b/build/varnish/Dockerfile index 21654e8b4..030ac8b1c 100644 --- a/build/varnish/Dockerfile +++ b/build/varnish/Dockerfile @@ -1,6 +1,7 @@ FROM debian:stretch-slim -LABEL maintainer="Ilja Lapkovskis admin@scandiweb.com" +LABEL maintainer="Alfreds Genkins alfreds@scandipwa.com" LABEL author="Jurijs Jegorovs admin@scandiweb.com" + ENV DEBIAN_FRONTEND=noninteractive \ VARNISH_VERSION=5.2 \ VARNISH_VERSION_FLATTEN=52\ diff --git a/build/xdebug/Dockerfile b/build/xdebug/Dockerfile index 0cd148f84..bbaba2ad0 100644 --- a/build/xdebug/Dockerfile +++ b/build/xdebug/Dockerfile @@ -1,6 +1,7 @@ FROM scandipwa/base -LABEL authors="Jurijs Jegorovs jurijs+oss@scandiweb.com" -LABEL maintainer="Jurijs Jegorovs jurijs+oss@scandiweb.com" + +LABEL maintainer="Alfreds Genkins alfreds@scandipwa.com" + ENV DEBIAN_FRONTEND=noninteractive # Install required PHP extensions diff --git a/deploy/development/application b/deploy/development/application deleted file mode 100644 index 42e742f69..000000000 --- a/deploy/development/application +++ /dev/null @@ -1,14 +0,0 @@ -# MySQL settings -MYSQL_HOST=mysql -MYSQL_PORT=3306 -MYSQL_ROOT_PASSWORD=scandipwa -MYSQL_USER=magento -MYSQL_PASSWORD=magento -MYSQL_DATABASE=magento - -MAGENTO_FIRST_NAME=Scandiweb -MAGENTO_LAST_NAME=Developer -MAGENTO_EMAIL=developer@scandipwa -MAGENTO_USER=admin -MAGENTO_PASSWORD=scandipwa123 -MAGENTO_ADMINURI=admin diff --git a/deploy/development/env b/deploy/development/env deleted file mode 100644 index 54ea38fe0..000000000 --- a/deploy/development/env +++ /dev/null @@ -1,50 +0,0 @@ -## Local configuration, used for developer setup with docker-compose -## Note: this file already referenced in docker-compose.yml, alter this file to override options - -# Use for forcing container to run even errors occurs during the run -DOCKER_DEBUG=true - -# Service versions (ENV) -MYSQL_VERSION=5.7 -NGINX_VERSION=alpine -REDIS_VERSION=alpine -VARNISH_VERSION=5.0 -ELASTICSEARCH_VERSION=5.5.3 -RABBITMQ_VERSION=alpine - -# Service configurations (ENV) -VARNISH_PORT=8080 -# Varnish memory limit, defaults to 256m -#VARNISH_MEMORY=512m -NGINX_BIND_PORT=3001 -MYSQL_PORT=3307 -REDIS_PORT=6379 -ELASTICSEARCH_PORT=9200 -RABBITMQ_PORT=15672 -MAILDEV_PORT=1080 -RENDERTRON_PORT=8083 - -### General settings (ARG) -# These settings used in build and deploy stages, set them once, recheck and deploy. -BASEPATH=/var/www/public -PROJECT_TAG=development - -# PHP Composer uses plain version number, fail if not existing -# version list, manual download section: https://getcomposer.org/download/ -# default COMPOSER version: latest -COMPOSER_HOME=/var/lib/composer -# Set version for override, or leave the "latest", updated on each build -COMPOSER_VERSION=latest -COMPOSER_ALLOW_SUPERUSER=1 - -# Node.js is installed via n -# node versions: `n list` or https://nodejs.org/dist/ -# default NODEJS version: latest LTS -NODEJS_DIR=/var/lib/node -NODEJS_VERSION=10 -NPM_CONFIG_LOGLEVEL=warn - -# Ruby is installed via rbenv -# rbenv recognizes RBENV_ROOT as is. Value is also used for extending PATH definition -D_RBENV_ROOT=/var/lib/ruby -D_RBENV_VERSION=2.5.1 diff --git a/deploy/development/magento/env.sample.php b/deploy/development/magento/env.sample.php deleted file mode 100644 index cd0ced424..000000000 --- a/deploy/development/magento/env.sample.php +++ /dev/null @@ -1,32 +0,0 @@ - - [ - 'date' => 'Thu, 10 May 2018 09:09:15 +0000', - ], - 'cache_types' => [ - 'config' => 1, - 'layout' => 1, - 'block_html' => 1, - 'collections' => 1, - 'reflection' => 1, - 'db_ddl' => 1, - 'eav' => 1, - 'customer_notification' => 1, - 'config_integration' => 1, - 'config_integration_api' => 1, - 'full_page' => 1, - 'translate' => 1, - 'config_webservice' => 1 - ], - 'cache' => [ - 'persisted-query' => [ - 'redis' => [ - 'host' => 'redis', - 'scheme' => 'tcp', - 'port' => '6379', - 'database' => '5' - ] - ] - ], -]; diff --git a/deploy/entrypoint.sh b/deploy/entrypoint.sh index 023a5ad57..d62309cf3 100755 --- a/deploy/entrypoint.sh +++ b/deploy/entrypoint.sh @@ -7,16 +7,26 @@ chmod augo+rwx /dev/stdout /dev/stderr /proc/self/fd/1 /proc/self/fd/2 # Check if set UID variable, if empty, execute as root if [[ -n "$LOCAL" ]]; then - HOST_UID=$(stat -c "%u" $BASEPATH) - echo "Starting with UID : $HOST_UID" useradd --shell /bin/bash -u $HOST_UID -o -c "" -m user export HOME=/home/user - exec gosu user "$@" - else echo "Starting as root" exec "$@" -fi +fi + +# Add every user, to every group, to eliminate permission issue +adduser root www-data +adduser root user +adduser user www-data +adduser user root +adduser www-data root +adduser www-data user +usermod -aG user root +usermod -aG user www-data +usermod -aG root user +usermod -aG root www-data +usermod -aG www-data user +usermod -aG www-data root diff --git a/deploy/frontend/conf/nginx/cache-router.conf b/deploy/frontend/conf/nginx/cache-router.conf index 55748ea5b..2732e3fed 100644 --- a/deploy/frontend/conf/nginx/cache-router.conf +++ b/deploy/frontend/conf/nginx/cache-router.conf @@ -2,6 +2,7 @@ server { listen 80; server_name _; resolver 127.0.0.11; + client_max_body_size 64M; # Route all traffic to app location / { diff --git a/deploy/shared/conf/nginx/cache-router.conf b/deploy/shared/conf/nginx/cache-router.conf index 24e74886d..b497c16fb 100644 --- a/deploy/shared/conf/nginx/cache-router.conf +++ b/deploy/shared/conf/nginx/cache-router.conf @@ -2,18 +2,16 @@ server { listen 80; server_name _; resolver 127.0.0.11; + client_max_body_size 64M; # Route all traffic to varnish location / { set $prerender 0; - if ( $http_user_agent ~* 'Googlebot|slackbot') { + + if ($http_user_agent ~* 'Googlebot|slackbot') { set $prerender 1; } - - if ( $http_x_renderer ~* 'rendertron' ) { - set $prerender 0; - } - + if ($uri ~* "\.(js|css|xml|less|png|jpg|jpeg|webp|gif|pdf|doc|txt|ico|rss|zip|mp3|rar|exe|wmv|doc|avi|ppt|mpg|mpeg|tif|wav|mov|psd|ai|xls|mp4|m4a|swf|dat|dmg|iso|flv|m4v|torrent|ttf|woff|svg|eot)") { set $prerender 0; } @@ -27,6 +25,7 @@ server { if ($prerender = 1) { proxy_pass http://rendertron:8083/render/https://$host$request_uri; } + if ($prerender = 0) { proxy_pass http://varnish:80; } diff --git a/deploy/shared/conf/nginx/ssl-terminator.conf b/deploy/shared/conf/nginx/ssl-terminator.conf index 2c51dd436..eb0866b77 100644 --- a/deploy/shared/conf/nginx/ssl-terminator.conf +++ b/deploy/shared/conf/nginx/ssl-terminator.conf @@ -13,6 +13,8 @@ server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name _; + client_max_body_size 64M; + ssl_certificate /etc/nginx/cert/server_crt.pem; ssl_certificate_key /etc/nginx/cert/server_key.pem; ssl_trusted_certificate /etc/nginx/cert/scandipwa-fullchain.pem; diff --git a/deploy/shared/conf/php/zz-docker.conf b/deploy/shared/conf/php/zz-docker.conf index 1adefd08c..203bae5a0 100644 --- a/deploy/shared/conf/php/zz-docker.conf +++ b/deploy/shared/conf/php/zz-docker.conf @@ -4,10 +4,10 @@ daemonize = no [www] pm = dynamic pm.max_children = 32 -pm.start_servers = 8 -pm.min_spare_servers = 6 -pm.max_spare_servers = 12 +pm.start_servers = 15 +pm.min_spare_servers = 5 +pm.max_spare_servers = 10 pm.max_requests = 5000 pm.process_idle_timeout = 10s pm.status_path = /fpmstatus -listen = [::]:9000 \ No newline at end of file +listen = [::]:9000 diff --git a/deploy/staging/application b/deploy/staging/application deleted file mode 100644 index 467478c49..000000000 --- a/deploy/staging/application +++ /dev/null @@ -1,19 +0,0 @@ -# MySQL settings -MYSQL_HOST=mysql -MYSQL_PORT=3306 -MYSQL_ROOT_PASSWORD=scandipwa -MYSQL_USER=magento -MYSQL_PASSWORD=magento -MYSQL_DATABASE=magento - -MAGENTO_FIRST_NAME=Scandiweb -MAGENTO_LAST_NAME=Developer -MAGENTO_EMAIL=developer@scandipwa -MAGENTO_USER=admin -MAGENTO_PASSWORD=scandipwa123 -MAGENTO_ADMINURI=admin - -MAGENTO_MODE=developer -# You might experience some session-related issues when using localhost, use 127.0.0.1 instead! -MAGENTO_BASEURL=http://localhost -MAGENTO_SECURE_BASEURL=https://localhost diff --git a/deploy/staging/env b/deploy/staging/env deleted file mode 100644 index 6c955a9ab..000000000 --- a/deploy/staging/env +++ /dev/null @@ -1,50 +0,0 @@ -## Local configuration, used for developer setup with docker-compose -## Note: this file already referenced in docker-compose.yml, alter this file to override options - -# Use for forcing container to run even errors occurs during the run -DOCKER_DEBUG=true - -# Service versions (ENV) -MYSQL_VERSION=5.7 -NGINX_VERSION=alpine -REDIS_VERSION=alpine -VARNISH_VERSION=5.0 -ELASTICSEARCH_VERSION=5.5.3 -RABBITMQ_VERSION=alpine - -# Service configurations (ENV) -VARNISH_PORT=3002 -# Varnish memory limit, defaults to 256m -#VARNISH_MEMORY=512m -NGINX_BIND_PORT=8081 -MYSQL_PORT=3308 -REDIS_PORT=6380 -ELASTICSEARCH_PORT=9201 -RABBITMQ_PORT=15673 -MAILDEV_PORT=1081 -RENDERTRON_PORT=8083 - -### General settings (ARG) -# These settings used in build and deploy stages, set them once, recheck and deploy. -BASEPATH=/var/www/public -PROJECT_TAG=staging - -# PHP Composer uses plain version number, fail if not existing -# version list, manual download section: https://getcomposer.org/download/ -# default COMPOSER version: latest -D_COMPOSER_HOME=/var/lib/composer -# Set version for override, or leave the "latest", updated on each build -COMPOSER_VERSION=latest -COMPOSER_ALLOW_SUPERUSER=1 - -# Node.js is installed via n -# node versions: `n list` or https://nodejs.org/dist/ -# default NODEJS version: latest LTS -NODEJS_DIR=/var/lib/node -NODEJS_VERSION=10 -NPM_CONFIG_LOGLEVEL=warn - -# Ruby is installed via rbenv -# rbenv recognizes RBENV_ROOT as is. Value is also used for extending PATH definition -D_RBENV_ROOT=/var/lib/ruby -D_RBENV_VERSION=2.5.1 diff --git a/deploy/staging/magento/env.sample.php b/deploy/staging/magento/env.sample.php deleted file mode 100644 index 40d40ef2e..000000000 --- a/deploy/staging/magento/env.sample.php +++ /dev/null @@ -1,32 +0,0 @@ - - [ - 'date' => 'Thu, 10 May 2018 09:09:15 +0000', - ], - 'cache_types' => [ - 'config' => 0, - 'layout' => 1, - 'block_html' => 1, - 'collections' => 1, - 'reflection' => 1, - 'db_ddl' => 1, - 'eav' => 1, - 'customer_notification' => 1, - 'config_integration' => 1, - 'config_integration_api' => 1, - 'full_page' => 1, - 'translate' => 1, - 'config_webservice' => 1 - ], - 'cache' => [ - 'persisted-query' => [ - 'redis' => [ - 'host' => 'redis', - 'scheme' => 'tcp', - 'port' => '6379', - 'database' => '5' - ] - ] - ], -]; diff --git a/deploy/start.sh b/deploy/start.sh index 9cc187cb8..960c574d5 100755 --- a/deploy/start.sh +++ b/deploy/start.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash set -euo pipefail +mutagen="0" +frontend="0" + start_time="$(date -u +%s.%N)" ### Debug options start # Uncomment next line for script debug @@ -57,16 +60,22 @@ export bash_colors function pwa_theme_install { echo "${blue}${bold}Register PWA theme in Magento${normal}" + # Theme setup magento scandipwa:theme:bootstrap Scandiweb/pwa -n || true php bin/magento setup:upgrade - # Theme build + if [ $? -eq 0 ]; then - echo "${blue}${bold}Building PWA theme${normal}" - cd $BASEPATH/app/design/frontend/Scandiweb/pwa - npm ci - npm run build - cd $BASEPATH + if [ "$frontend" != "1" ] + then + echo "${blue}${bold}Building PWA theme${normal}" + cd $BASEPATH/app/design/frontend/Scandiweb/pwa + npm ci + npm run build + cd $BASEPATH + else + echo "${blue}${bold}Frontend container will build PWA theme${normal}" + fi fi } @@ -264,6 +273,33 @@ function exit_catch { ### Deploy pipe start +helpFunction() +{ + echo "" + echo "Usage: $0 [-M] [-F]" + echo -e "\t-F Let frontend container handle theme build" + echo -e "\t-M Wait for Mutagen to sync files before start" + exit 1 # Exit script after printing help +} + +while getopts "MF" opt +do + case "$opt" in + M ) mutagen="1" ;; + F ) frontend="1" ;; + ? ) helpFunction ;; + esac +done + +if [ "$mutagen" = "1" ] +then + echo "${blue}${bold}Waiting for Mutagen to sync initial filese${normal}" + while ! [ -f ./composer.json -a -f ./composer.lock ] + do + sleep 2 + done +fi + # Switch current execution directory to WORKDIR (BASEPATH) in_basepath # Installing PHP Composer and packages @@ -309,5 +345,3 @@ trap exit_catch EXIT echo "${blue}${bold}Staring php fpm, ready to rock${normal}" php-fpm -R - - diff --git a/docker-compose.core.mutagen.yml b/docker-compose.core.mutagen.yml new file mode 100644 index 000000000..b0cd3bc8f --- /dev/null +++ b/docker-compose.core.mutagen.yml @@ -0,0 +1,6 @@ +version: '3.6' +services: + frontend: + command: ["/start.sh", "-M", "-C"] + app: + command: ["/wait-for-it.sh", "mysql:3306", "--", "/start.sh", "-F", "-M"] diff --git a/docker-compose.core.yml b/docker-compose.core.yml index df8154d83..8457e7f59 100644 --- a/docker-compose.core.yml +++ b/docker-compose.core.yml @@ -1,4 +1,4 @@ -version: '3' +version: '3.6' services: nginx: volumes: @@ -6,16 +6,19 @@ services: depends_on: - frontend frontend: - image: scandipwa/frontend:${PROJECT_IMAGE} + image: scandipwa/frontend:latest build: context: build/frontend args: - - BASEPATH=${BASEPATH} - NODEJS_VERSION=${NODEJS_VERSION} volumes: - - ./src/localmodules/base-theme:/var/www/public - working_dir: "/var/www/public" + - app-data:/var/www/public + # Uncomment line below only for testing launch script without rebuild + # - ./build/frontend/start.sh:/start.sh env_file: .env - command: ["/bin/bash", "/start-core.sh"] + working_dir: "/var/www/public" + command: ["/start.sh", "-C"] expose: - 3003 + app: + command: ["/wait-for-it.sh", "mysql:3306", "--", "/start.sh", "-F"] diff --git a/docker-compose.frontend.mutagen.yml b/docker-compose.frontend.mutagen.yml new file mode 100644 index 000000000..c606f8bd3 --- /dev/null +++ b/docker-compose.frontend.mutagen.yml @@ -0,0 +1,6 @@ +version: '3.6' +services: + frontend: + command: ["/start.sh", "-M"] + app: + command: ["/wait-for-it.sh", "mysql:3306", "--", "/start.sh", "-F", "-M"] diff --git a/docker-compose.frontend.yml b/docker-compose.frontend.yml index 8ff6759c3..c32280ad6 100644 --- a/docker-compose.frontend.yml +++ b/docker-compose.frontend.yml @@ -1,24 +1,24 @@ -version: '3' +version: '3.6' services: nginx: volumes: - ./deploy/frontend/conf/nginx/cache-router.conf:/etc/nginx/conf.d/cache-router.conf - links: - - frontend depends_on: - frontend frontend: - image: scandipwa/frontend:${PROJECT_IMAGE} + image: scandipwa/frontend:latest build: context: build/frontend args: - - BASEPATH=${BASEPATH} - NODEJS_VERSION=${NODEJS_VERSION} volumes: - - ./src/app/design/frontend/Scandiweb/pwa:/var/www/public/app/design/frontend/Scandiweb/pwa - - ./src/vendor/scandipwa/source:/var/www/public/vendor/scandipwa/source - command: ["npm", "run", "pm2-watch"] - working_dir: "/var/www/public/app/design/frontend/Scandiweb/pwa/" + - app-data:/var/www/public + # Uncomment line below only for testing launch script without rebuild + # - ./build/frontend/start.sh:/start.sh env_file: .env + working_dir: "/var/www/public" + command: ["/start.sh"] expose: - 3003 + app: + command: ["/wait-for-it.sh", "mysql:3306", "--", "/start.sh", "-F"] diff --git a/docker-compose.local.mutagen.yml b/docker-compose.local.mutagen.yml new file mode 100644 index 000000000..db38703c4 --- /dev/null +++ b/docker-compose.local.mutagen.yml @@ -0,0 +1,27 @@ +version: '3.6' +services: + app: + container_name: mutagen-powered-app + environment: + # This variable is required to run local setup on Linux, determines the switch from root to user + - LOCAL=true + volumes: + # PHP configuration mount + - ./deploy/shared/conf/php/php.ini:/usr/local/etc/php/php.ini + # PHP FPM pool settings + - ./deploy/shared/conf/php/zz-docker.conf:/usr/local/etc/php-fpm.d/zz-docker.conf + # Uncomment to use custom configuration with xdebug image + - ./deploy/shared/conf/xdebug/xdebug-config.ini:/usr/local/etc/php/conf.d/xdebug-config.ini + # Uncomment line below only for testing launch script without rebuild + # - ./deploy/start.sh:/start.sh + kibana: + image: docker.elastic.co/kibana/kibana:${ELASTICSEARCH_VERSION} + restart: on-failure:5 + environment: + - xpack.security.enabled=false + ports: + - 5601:5601 + depends_on: + - elasticsearch + networks: + - default diff --git a/docker-compose.local.yml b/docker-compose.local.yml index 4fde79f90..4dc2dc136 100644 --- a/docker-compose.local.yml +++ b/docker-compose.local.yml @@ -1,4 +1,4 @@ -version: '3' +version: '3.6' services: app: environment: @@ -14,15 +14,7 @@ services: # Uncomment to use custom configuration with -debug image - ./deploy/shared/conf/xdebug/xdebug-config.ini:/usr/local/etc/php/conf.d/xdebug-config.ini # Uncomment line below only for testing launch script without rebuild - - ./deploy/start.sh:/start.sh - nginx: - volumes: - - ./src:/var/www/public:cached - networks: - - default - redis: - ports: - - ${REDIS_PORT}:6379 + # - ./deploy/start.sh:/start.sh kibana: image: docker.elastic.co/kibana/kibana:${ELASTICSEARCH_VERSION} restart: on-failure:5 diff --git a/docker-compose.mutagen.yml b/docker-compose.mutagen.yml new file mode 100644 index 000000000..ad6c3d489 --- /dev/null +++ b/docker-compose.mutagen.yml @@ -0,0 +1,4 @@ +version: '3.6' +services: + app: + command: ["/wait-for-it.sh", "mysql:3306", "--", "/wait-for-it.sh", "varnish:80", "--", "/start.sh", "-M"] diff --git a/docker-compose.remote.yml b/docker-compose.remote.yml index 7a5a01323..87f5f081b 100644 --- a/docker-compose.remote.yml +++ b/docker-compose.remote.yml @@ -1,8 +1,8 @@ -version: '3' +version: '3.6' services: app: volumes: - media-data:/var/www/public/pub/media nginx: volumes: - - media-data:/var/www/public/pub/media \ No newline at end of file + - media-data:/var/www/public/pub/media diff --git a/docker-compose.ssl.yml b/docker-compose.ssl.yml index 58fb0dac5..c7881040f 100644 --- a/docker-compose.ssl.yml +++ b/docker-compose.ssl.yml @@ -1,4 +1,4 @@ -version: '3' +version: '3.6' services: ssl-term: image: nginx:${NGINX_VERSION} diff --git a/docker-compose.yml b/docker-compose.yml index 0ee12990d..a5898cdc0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3' +version: '3.6' services: app: image: scandipwa/base:${PROJECT_IMAGE} @@ -95,13 +95,13 @@ services: env_file: .env volumes: - redis-data:/data -# Removed due bug-report: https://github.com/docker-library/redis/issues/235 -# ports: -# - ${REDIS_PORT}:6379 + # Removed due bug-report: https://github.com/docker-library/redis/issues/235 + # ports: + # - ${REDIS_PORT}:6379 expose: - 6379 networks: - - default + - default maildev: image: djfarrelly/maildev ports: @@ -135,6 +135,7 @@ volumes: mysql-data: redis-data: elasticsearch-data: + nginx-data: networks: default: diff --git a/mutagen.core.yml b/mutagen.core.yml new file mode 100644 index 000000000..0b77897b0 --- /dev/null +++ b/mutagen.core.yml @@ -0,0 +1,44 @@ +beforeCreate: + - > + docker-compose + -f docker-compose.yml + -f docker-compose.ssl.yml + -f docker-compose.core.yml + -f docker-compose.core.mutagen.yml + -f docker-compose.local.mutagen.yml + up -d --force-recreate +afterCreate: + - > + docker-compose + -f docker-compose.yml + -f docker-compose.ssl.yml + -f docker-compose.core.yml + -f docker-compose.core.mutagen.yml + -f docker-compose.local.mutagen.yml + logs -f app +afterTerminate: + - > + docker-compose + -f docker-compose.yml + -f docker-compose.ssl.yml + -f docker-compose.core.yml + -f docker-compose.core.mutagen.yml + -f docker-compose.local.mutagen.yml + down +sync: + app: + alpha: "./src" + beta: "docker://mutagen-powered-app/var/www/public" + configurationBeta: + permissions: + defaultGroup: "user" + defaultFileMode: 666 + defaultDirectoryMode: 777 + ignore: + vcs: true + paths: + - "**/node_modules/" + - "**/vendor/" + mode: two-way-resolved + symlink: + mode: "ignore" diff --git a/mutagen.frontend.yml b/mutagen.frontend.yml new file mode 100644 index 000000000..a679e1218 --- /dev/null +++ b/mutagen.frontend.yml @@ -0,0 +1,44 @@ +beforeCreate: + - > + docker-compose + -f docker-compose.yml + -f docker-compose.ssl.yml + -f docker-compose.frontend.yml + -f docker-compose.frontend.mutagen.yml + -f docker-compose.local.mutagen.yml + up -d --force-recreate +afterCreate: + - > + docker-compose + -f docker-compose.yml + -f docker-compose.ssl.yml + -f docker-compose.frontend.yml + -f docker-compose.frontend.mutagen.yml + -f docker-compose.local.mutagen.yml + logs -f app +afterTerminate: + - > + docker-compose + -f docker-compose.yml + -f docker-compose.ssl.yml + -f docker-compose.frontend.yml + -f docker-compose.frontend.mutagen.yml + -f docker-compose.local.mutagen.yml + down +sync: + app: + alpha: "./src" + beta: "docker://mutagen-powered-app/var/www/public" + configurationBeta: + permissions: + defaultGroup: "user" + defaultFileMode: 666 + defaultDirectoryMode: 777 + ignore: + vcs: true + paths: + - "**/node_modules/" + - "**/vendor/" + mode: two-way-resolved + symlink: + mode: "ignore" diff --git a/mutagen.local.yml b/mutagen.local.yml new file mode 100644 index 000000000..9b4012318 --- /dev/null +++ b/mutagen.local.yml @@ -0,0 +1,41 @@ +beforeCreate: + - > + docker-compose + -f docker-compose.yml + -f docker-compose.ssl.yml + -f docker-compose.mutagen.yml + -f docker-compose.local.mutagen.yml + up -d --force-recreate +afterCreate: + - > + docker-compose + -f docker-compose.yml + -f docker-compose.ssl.yml + -f docker-compose.mutagen.yml + -f docker-compose.local.mutagen.yml + logs -f app +afterTerminate: + - > + docker-compose + -f docker-compose.yml + -f docker-compose.ssl.yml + -f docker-compose.mutagen.yml + -f docker-compose.local.mutagen.yml + down +sync: + app: + alpha: "./src" + beta: "docker://mutagen-powered-app/var/www/public" + configurationBeta: + permissions: + defaultGroup: "user" + defaultFileMode: 666 + defaultDirectoryMode: 777 + ignore: + vcs: true + paths: + - "**/node_modules/" + - "**/vendor/" + mode: two-way-resolved + symlink: + mode: "ignore"