ソースを参照

Merge branch 'master' of github.com:markshust/docker-magento

Mark Shust 3 年 前
コミット
3b480b6a0a

+ 2 - 2
README.md

@@ -3,10 +3,10 @@
 <div align="center">
   <p>Mark Shust's Docker Configuration for Magento</p>
   <img src="https://img.shields.io/badge/magento-2.X-brightgreen.svg?logo=magento&longCache=true&style=flat-square" alt="Supported Magento Versions" />
-  <img src="https://img.shields.io/badge/apple%20silicon%20support-coming%20soon-yellow" alt="Apple Silicon Support" />
-  <a href="https://hub.docker.com/r/markoshust/magento-nginx/" target="_blank"><img src="https://img.shields.io/docker/pulls/markoshust/magento-nginx.svg?label=nginx%20docker%20pulls" alt="Docker Hub Pulls - Nginx" /></a>
   <a href="https://hub.docker.com/r/markoshust/magento-php/" target="_blank"><img src="https://img.shields.io/docker/pulls/markoshust/magento-php.svg?label=php%20docker%20pulls" alt="Docker Hub Pulls - PHP" /></a>
+  <a href="https://hub.docker.com/r/markoshust/magento-nginx/" target="_blank"><img src="https://img.shields.io/docker/pulls/markoshust/magento-nginx.svg?label=nginx%20docker%20pulls" alt="Docker Hub Pulls - Nginx" /></a>
   <a href="https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity" target="_blank"><img src="https://img.shields.io/badge/maintained%3F-yes-brightgreen.svg?style=flat-square" alt="Maintained - Yes" /></a>
+  <img src="https://img.shields.io/badge/apple%20silicon%20support-yes-brightgreen" alt="Apple Silicon Support" />
   <a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/license-MIT-blue.svg" /></a>
 </div>
 

+ 178 - 0
compose/Makefile

@@ -0,0 +1,178 @@
+SHELL := /bin/bash
+
+args = `arg="$(filter-out $(firstword $(MAKECMDGOALS)),$(MAKECMDGOALS))" && echo $${arg:-${1}}`
+
+green  = $(shell printf "\e[32;01m$1\e[0m")
+yellow = $(shell printf "\e[33;01m$1\e[0m")
+red    = $(shell printf "\e[33;31m$1\e[0m")
+
+format = $(shell printf "%s %-38s %s" "$(call yellow,$1)" "$(call green,$2)" $3)
+
+comma:= ,
+
+.DEFAULT_GOAL:=help
+
+%:
+	@:
+
+help:
+	@echo ""
+	@echo "$(call green,Use the following CLI commands:)"
+	@echo "$(call red,===============================)"
+	@echo "$(call format,make,help,'Print list of commands with comment.')"
+	@echo "$(call format,make,bash,'Drop into the bash prompt of your Docker container.')"
+	@echo "$(call format,make,cache-clean,'Access the cache-clean CLI.')"
+	@echo "$(call format,make,cli,'Run any CLI command without going into the bash prompt.')"
+	@echo "$(call format,make,clinotty,'Run any CLI command with no TTY.')"
+	@echo "$(call format,make,cliq,'Run any CLI command but pipes all output to /dev/null.')"
+	@echo "$(call format,make,composer,'Run the composer binary.')"
+	@echo "$(call format,make,copyfromcontainer,'Copy folders or files from container to host.')"
+	@echo "$(call format,make,copytocontainer,'Copy folders or files from host to container.')"
+	@echo "$(call format,make,dev-urn-catalog-generate,'Generate URNs for PHPStorm and remap paths to local host.')"
+	@echo "$(call format,make,devconsole,'Alias for n98-magerun2 dev:console.')"
+	@echo "$(call format,make,devtools-cli-check,'Check & install the CLI devtools if missing from system.')"
+	@echo "$(call format,make,download,'Download & extract specific Magento version to the src directory.')"
+	@echo "$(call format,make,fixowns,'This will fix filesystem ownerships within the container.')"
+	@echo "$(call format,make,fixperms,'This will fix filesystem permissions within the container.')"
+	@echo "$(call format,make,grunt,'Run the grunt binary.')"
+	@echo "$(call format,make,magento,'Run the Magento CLI.')"
+	@echo "$(call format,make,mysql,'Run the MySQL CLI with database config from env/db.env.')"
+	@echo "$(call format,make,mysqldump,'Backup the Magento database.')"
+	@echo "$(call format,make,n98-magerun2,'Access the n98-magerun2 CLI.')"
+	@echo "$(call format,make,node,'Run the node binary.')"
+	@echo "$(call format,make,npm,'Run the npm binary.')"
+	@echo "$(call format,make,pwa-studio,'(BETA) Start the PWA Studio server.')"
+	@echo "$(call format,make,redis,'Run a command from the redis container.')"
+	@echo "$(call format,make,remove,'Remove all containers.')"
+	@echo "$(call format,make,removeall,'Remove all containers$(comma) networks$(comma) volumes$(comma) and images.')"
+	@echo "$(call format,make,removevolumes,'Remove all volumes.')"
+	@echo "$(call format,make,restart,'Stop and then start all containers.')"
+	@echo "$(call format,make,root,'Run any CLI command as root without going into the bash prompt.')"
+	@echo "$(call format,make,rootnotty,'Run any CLI command as root with no TTY.')"
+	@echo "$(call format,make,setup,'Run the Magento setup process to install Magento from the source code$(comma) with optional domain name.')"
+	@echo "$(call format,make,setup-grunt,'Install and configure Grunt JavaScript task runner.')"
+	@echo "$(call format,make,setup-pwa-studio,'(BETA) Install PWA Studio.')"
+	@echo "$(call format,make,setup-ssl,'Generate an SSL certificate for one or more domains.')"
+	@echo "$(call format,make,setup-ssl-ca,'Generate a certificate authority and copy it to the host.')"
+	@echo "$(call format,make,start,'Start all containers.')"
+	@echo "$(call format,make,status,'Check the container status.')"
+	@echo "$(call format,make,stop,'Stop all containers.')"
+	@echo "$(call format,make,update,'Stop all containers.')"
+	@echo "$(call format,make,xdebug,'Disable or enable Xdebug.')"
+
+bash:
+	@./bin/bash
+
+cache-clean:
+	@./bin/cache-clean $(call args)
+
+cli:
+	@./bin/cli $(call args)
+
+clinotty:
+	@./bin/clinotty $(call args)
+
+cliq:
+	@./bin/cliq $(call args)
+
+composer:
+	@./bin/composer $(call args)
+
+copyfromcontainer:
+	@./bin/copyfromcontainer $(call args)
+
+copytocontainer:
+	@./bin/copytocontainer $(call args)
+
+dev-urn-catalog-generate:
+	@./bin/dev-urn-catalog-generate
+
+devconsole:
+	@./bin/devconsole
+
+devtools-cli-check:
+	@./bin/devtools-cli-check
+
+download:
+	@./bin/download $(call args)
+
+fixowns:
+	@./bin/fixowns $(call args)
+
+fixperms:
+	@./bin/fixperms $(call args)
+
+grunt:
+	@./bin/grunt $(call args)
+
+magento:
+	@./bin/magento $(call args)
+
+mysql:
+	@./bin/mysql $(call args)
+
+mysqldump:
+	@./bin/mysqldump $(call args)
+
+n98-magerun2:
+	@./bin/n98-magerun2 $(call args)
+
+node:
+	@./bin/node $(call args)
+
+npm:
+	@./bin/npm $(call args)
+
+pwa-studio:
+	@./bin/pwa-studio
+
+redis:
+	@./bin/redis $(call args)
+
+remove:
+	@./bin/remove
+
+removeall:
+	@./bin/removeall
+
+removevolumes:
+	@./bin/removevolumes
+
+restart:
+	@./bin/restart $(call args)
+
+root:
+	@./bin/root $(call args)
+
+rootnotty:
+	@./bin/rootnotty $(call args)
+
+setup:
+	@./bin/setup $(call args)
+
+setup-grunt:
+	@./bin/setup-grunt
+
+setup-pwa-studio:
+	@./bin/setup-pwa-studio $(call args)
+
+setup-ssl:
+	@./bin/setup-ssl $(call args)
+
+setup-ssl-ca:
+	@./bin/setup-ssl-ca
+
+start:
+	@./bin/start $(call args)
+
+status:
+	@./bin/status
+
+stop:
+	@./bin/stop $(call args)
+
+update:
+	@./bin/update
+
+xdebug:
+	@./bin/xdebug $(call args)

+ 2 - 1
compose/bin/setup-grunt

@@ -3,6 +3,7 @@ DEFAULT_THEME_ID="select value from core_config_data where path = 'design/theme/
 THEME_PATH="select theme_path from theme where theme_id in ($DEFAULT_THEME_ID);"
 VENDOR_THEME=$(bin/n98-magerun2 db:query "$THEME_PATH" | sed -n 2p | cut -d$'\r' -f1)
 THEME=$(echo "$VENDOR_THEME" | cut -d'/' -f2)
+LOCALE_CODE=$(bin/magento config:show general/locale/code | cut -d$'\r' -f1 | sed 's/ *$//g')
 
 # Generate local-theme.js for custom theme
 read -r -d '' GEN_THEME_JS << EOM
@@ -13,7 +14,7 @@ var theme = require('./dev/tools/grunt/configs/themes');
 theme['$THEME'] = {
     area: 'frontend',
     name: '$VENDOR_THEME',
-    locale: 'en_US',
+    locale: '$LOCALE_CODE',
     files: [
         'css/styles-m',
         'css/styles-l'

+ 57 - 2
compose/bin/setup-ssl-ca

@@ -8,8 +8,63 @@ echo "System password requested to install certificate authority on host..."
 
 if [ "$(uname)" == "Darwin" ]; then
   sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain rootCA.pem
-  rm rootCA.pem
+
+  ### Check if Firefox is installed
+  FFoxBin="/Applications/Firefox.app/Contents/MacOS/firefox-bin"
+  if [ -f "$FFoxBin" ]; then
+    sudo echo "{\"policies\": {\"Certificates\": {\"ImportEnterpriseRoots\": true}}}" > policies.json
+
+    ### Check if distribution directory exists
+    DistDirectory="/Applications/Firefox.app/Contents/Resources/distribution"
+    if [ ! -d "$DistDirectory" ]; then
+      sudo mkdir "$DistDirectory"
+    fi
+    ### Move the newly created policies.json to the Certificates directory
+    sudo mv policies.json "$DistDirectory"/policies.json
+
+    ### Check if Certificates directory exists
+    CertDirectory="/Library/Application Support/Mozilla/Certificates"
+    if [ ! -d "$CertDirectory" ]; then
+      sudo mkdir "$CertDirectory"
+    fi
+
+    ### Move the newly created .pem to the Certificates directory
+    sudo mv rootCA.pem "$CertDirectory"/rootCA.pem
+  else
+    sudo rm rootCA.pem
+  fi
+
 else
-  sudo mv rootCA.pem /usr/local/share/ca-certificates/rootCA.pem
+
+  ### Requirement: apt install libnss3-tools
+  REQUIRED_PKG="libnss3-tools"
+  PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $REQUIRED_PKG|grep "install ok installed")
+  echo Checking for $REQUIRED_PKG: $PKG_OK
+  if [ "" = "$PKG_OK" ]; then
+    echo "No $REQUIRED_PKG found. Setting up $REQUIRED_PKG."
+    sudo apt-get --yes install $REQUIRED_PKG
+  fi
+
+  ### CA file to install (CUSTOMIZE!)
+  certfile="rootCA.pem"
+  certname="Root CA"
+
+  ### For cert8 (legacy - DBM)
+  for certDB in $(find ~/ -name "cert8.db")
+  do
+      certdir=$(dirname ${certDB});
+      certutil -D -n "${certname}" -i ${certfile} -d dbm:${certdir}
+      certutil -A -n "${certname}" -t "TCu,Cu,Tu" -i ${certfile} -d dbm:${certdir}
+  done
+
+  ### For cert9 (SQL)
+  for certDB in $(find ~/ -name "cert9.db")
+  do
+      certdir=$(dirname ${certDB});
+      certutil -D -n "${certname}" -i ${certfile} -d sql:${certdir}
+      certutil -A -n "${certname}" -t "TCu,Cu,Tu" -i ${certfile} -d sql:${certdir}
+  done
+
+  sudo mv rootCA.pem /usr/local/share/ca-certificates/rootCA.crt
   sudo update-ca-certificates
 fi

+ 4 - 2
images/php/7.3/Dockerfile

@@ -1,6 +1,8 @@
 FROM php:7.3-fpm-buster
 MAINTAINER Mark Shust <mark@shust.com>
 
+ARG APP_ID=1000
+
 RUN apt-get update && apt-get install -y \
   cron \
   git \
@@ -69,8 +71,8 @@ RUN pecl install ssh2-1.2 \
 RUN pecl install redis \
   && docker-php-ext-enable redis
 
-RUN groupadd -g 1000 app \
- && useradd -g 1000 -u 1000 -d /var/www -s /bin/bash app
+RUN groupadd -g "$APP_ID" app \
+  && useradd -g "$APP_ID" -u "$APP_ID" -d /var/www -s /bin/bash app
 
 RUN apt-get install -y gnupg \
   && curl -sL https://deb.nodesource.com/setup_14.x | bash - \

+ 4 - 2
images/php/7.4/Dockerfile

@@ -1,6 +1,8 @@
 FROM php:7.4-fpm-buster
 MAINTAINER Mark Shust <mark@shust.com>
 
+ARG APP_ID=1000
+
 RUN apt-get update && apt-get install -y \
   cron \
   git \
@@ -69,8 +71,8 @@ RUN pecl install ssh2-1.2 \
 RUN pecl install redis \
   && docker-php-ext-enable redis
 
-RUN groupadd -g 1000 app \
- && useradd -g 1000 -u 1000 -d /var/www -s /bin/bash app
+RUN groupadd -g "$APP_ID" app \
+  && useradd -g "$APP_ID" -u "$APP_ID" -d /var/www -s /bin/bash app
 
 RUN apt-get install -y gnupg \
   && curl -sL https://deb.nodesource.com/setup_14.x | bash - \

+ 4 - 2
images/php/8.0/Dockerfile

@@ -1,6 +1,8 @@
 FROM php:8.0-fpm-buster
 MAINTAINER Mark Shust <mark@shust.com>
 
+ARG APP_ID=1000
+
 RUN apt-get update && apt-get install -y \
   cron \
   default-mysql-client \
@@ -52,8 +54,8 @@ RUN pecl channel-update pecl.php.net \
 RUN pecl install redis \
   && docker-php-ext-enable redis
 
-RUN groupadd -g 1000 app \
- && useradd -g 1000 -u 1000 -d /var/www -s /bin/bash app
+RUN groupadd -g "$APP_ID" app \
+  && useradd -g "$APP_ID" -u "$APP_ID" -d /var/www -s /bin/bash app
 
 RUN apt-get install -y gnupg \
   && curl -sL https://deb.nodesource.com/setup_14.x | bash - \