2
0
Эх сурвалжийг харах

Major updates that replace docker-sync with delegated volumes, minor bug fixes

Mark Shust 7 жил өмнө
parent
commit
a0ca93ea97

+ 28 - 28
README.md

@@ -1,23 +1,27 @@
-Mark Shust's Magento Docker Configuration
+Mark Shust's Docker Configuration for Magento
 
 ## Docker Hub
 
 View Dockerfiles:
 
-- <a href="https://hub.docker.com/r/markoshust/magento-nginx/" target="_blank">markoshust/magento-nginx (Docker Hub)</a>
+- [markoshust/magento-nginx (Docker Hub)](https://hub.docker.com/r/markoshust/magento-nginx/)
 	- 1.13
-		- [`latest`, `1.13`, `1.13-1`](https://github.com/markoshust/magento-docker/tree/master/images/nginx/1.13)
-		- [`1.13-0`](https://github.com/markoshust/magento-docker/tree/11.0.0/images/nginx/1.13)
-- <a href="https://hub.docker.com/r/markoshust/magento-php/" target="_blank">markoshust/magento-php (Docker Hub)</a>
+		- [`latest`, `1.13`, `1.13-2`](https://github.com/markoshust/docker-magento/tree/master/images/nginx/1.13)
+		- [`1.13-1`](https://github.com/markoshust/docker-magento/tree/11.1.5/images/nginx/1.13)
+		- [`1.13-0`](https://github.com/markoshust/docker-magento/tree/11.0.0/images/nginx/1.13)
+- [markoshust/magento-php (Docker Hub)](https://hub.docker.com/r/markoshust/magento-php/)
 	- 7.1
-		- [`latest`, `7.1-fpm`, `7.1-fpm-1`](https://github.com/markoshust/magento-docker/tree/master/images/php/7.1)
-		- [`7.1-fpm-0`](https://github.com/markoshust/magento-docker/tree/11.0.0/images/php/7.1)
+		- [`latest`, `7.1-fpm`, `7.1-fpm-2`](https://github.com/markoshust/docker-magento/tree/master/images/php/7.1)
+		- [`7.1-fpm-1`](https://github.com/markoshust/docker-magento/tree/11.1.5/images/php/7.1)
+		- [`7.1-fpm-0`](https://github.com/markoshust/docker-magento/tree/11.0.0/images/php/7.1)
 	- 7.0
-		- [`7.0-fpm`, `7.0-fpm-1`](https://github.com/markoshust/magento-docker/tree/master/images/php/7.0)
-		- [`7.0-fpm-0`](https://github.com/markoshust/magento-docker/tree/11.0.0/images/php/7.0)
+		- [`7.0-fpm`, `7.0-fpm-2`](https://github.com/markoshust/docker-magento/tree/master/images/php/7.0)
+		- [`7.0-fpm-1`](https://github.com/markoshust/docker-magento/tree/11.1.5/images/php/7.0)
+		- [`7.0-fpm-0`](https://github.com/markoshust/docker-magento/tree/11.0.0/images/php/7.0)
 	- 5.6
-		- [`5.6-fpm`, `5.6-fpm-1`](https://github.com/markoshust/magento-docker/tree/master/images/php/5.6)
-		- [`5.6-fpm-0`](https://github.com/markoshust/magento-docker/tree/11.0.0/images/php/5.6)
+		- [`5.6-fpm`, `5.6-fpm-2`](https://github.com/markoshust/docker-magento/tree/master/images/php/5.6)
+		- [`5.6-fpm-1`](https://github.com/markoshust/docker-magento/tree/11.1.5/images/php/5.6)
+		- [`5.6-fpm-0`](https://github.com/markoshust/docker-magento/tree/11.0.0/images/php/5.6)
 
 ## Usage
 
@@ -28,19 +32,17 @@ Folders:
 - `images`: Docker images for nginx and php
 - `compose`: sample setups with Docker Compose
 
-Nginx assumes you are running Magento 2, however you can easily run it with Magento 1 using [the provided configuration file](https://github.com/markoshust/magento-docker/blob/master/images/nginx/1.13/conf/default.magento1.conf). Here is an [example of this setup with Docker Compose](https://github.com/markoshust/magento-docker/tree/master/compose/magento-1).
+Nginx assumes you are running Magento 2, however you can easily run it with Magento 1 using [the provided configuration file](https://github.com/markoshust/docker-magento/blob/master/images/nginx/1.13/conf/default.magento1.conf). Here is an [example of this setup with Docker Compose](https://github.com/markoshust/docker-magento/tree/master/compose/magento-1).
 
 The PHP images are fairly agnostic to which version of Magento you are running. The PHP 5 images do assume you are running Magento 1, and the PHP 7 images do assume you are running Magento 2, however the main difference is cronjob setup, and they can be easily modified for inverse usage.
 
 ## Prerequisites
 
-This setup relies on <a href="http://docker-sync.io/" target="_blank">docker-sync</a> for syncing host files to the container volume, and vice versa.
+This setup assumes you are running Docker on a computer with at least 16GB RAM, a quad-core, and an SSD hard drive. [Download & Install Docker Community Edition](https://www.docker.com/community-edition#/download).
 
-- `gem install docker-sync`
-- `brew install coreutils`
-- Ensure ports `80|443|3306|9000|9001` are not in use
+This configuration has been tested on Mac, but should also work on Mac, Windows and Linux.
 
-You will also need to <a href="https://www.docker.com/community-edition#/download" target="_blank">Download & Install Docker Community Edition</a> on the host machine. This configuration has been tested on Mac, but should also work on Mac, Windows and Linux.
+If you are using a Mac, it is strongly recommended for you to apply [these performance tuning changes](http://markshust.com/2018/01/30/performance-tuning-docker-mac) to Docker for Mac before starting.
 
 ## Setup a New Magento 2 Project
 
@@ -49,7 +51,7 @@ You will also need to <a href="https://www.docker.com/community-edition#/downloa
 ```
 mkdir magento2 && cd $_
 git init
-git remote add origin git@github.com:markoshust/magento-docker.git
+git remote add origin git@github.com:markoshust/docker-magento.git
 git fetch origin
 git checkout origin/master -- compose/magento-2
 mv compose/magento-2/* .
@@ -57,19 +59,17 @@ rm -rf compose .git
 git init
 ```
 
-2. Set a custom name for the external volume. Within `docker-sync.yml` and `docker-compose-dev.yml` there are three references to `magento2_appdata`. Feel free to change these values to your project's name, for example `myapp_appdata`. This will be important when you want to run multiple Docker Compose setups with multiple projects.
+2. Download the Magento source code to the `src` folder with: `./bin/download 2.2.2`
 
-3. Download the Magento source code to the `src` folder with: `./bin/download 2.2.2`
+3. Setup your ip loopback for proper IP resolution with Docker: `./bin/initloopback`
 
-4. Start your Docker containers with: `./bin/start`. It will take a few moments (or many moments) for docker-sync to initially sync all of your host files back to the containers. Magento 2 has many, many files, so please be patient.
+4. Add an entry to `/etc/hosts` with your custom domain: `10.254.254.254 magento2.test` (assuming the domain  you want to setup is `magento2.test`). Be sure to use a `.test` tld, as `.localhost` and `.dev` will present issues with domain resolution.
 
-5. Setup your ip loopback for proper IP resolution with Docker: `./bin/initloopback`
+5. Start your Docker containers with: `./bin/start`.
 
-6. Add an entry to `/etc/hosts` with your custom domain: `10.254.254.254 magento2.test` (assuming the domain  you want to setup is `magento2.test`). Be sure to use a `.test` tld, as `.localhost` and `.dev` will present issues with domain resolution.
+6. Run Magento's setup install process with the command: `./bin/setup`. Feel free to edit this file to your liking; at the very least you will probably need to update the `base-url` value to the domain you setup in step 6.
 
-7. Run Magento's setup install process with the command: `./bin/setup`. Feel free to edit this file to your liking; at the very least you will probably need to update the `base-url` value to the domain you setup in step 6.
-
-8. You may now access your site at `http://magento2.test` (or whatever domain you setup). Note that initial page loads will take a bit of time. Once items are primed, everything should load quite fast.
+7. You may now access your site at `http://magento2.test` (or whatever domain you setup).
 
 ## Existing Magento Project Setup
 
@@ -108,11 +108,11 @@ Create a new server at  `PHPStorm > Preferences > Languages & Frameworks > PHP >
 
 Create a new `PHP Remote Debug` configuration at `Run > Edit Configurations`. Name it `localhost`. Check `Filter debug connection by IDE Key`, select server `localhost`, and set IDE key to `PHPSTORM`.
 
-Open up `src/pub/index.php`, and set a breakpoint near the end of the file. Go to `Run > Debug localhost`, and open up a web browser. Be sure to install a plugin like <a href="https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc" target="_blank">Xdebug helper</a> which sets the IDE key to `PHPStorm` automatically for you. Enable the browser extension and activate it on the site, and reload the site. Xdebug within PHPStorm should now enable the debugger and stop at the toggled breakpoint.
+Open up `src/pub/index.php`, and set a breakpoint near the end of the file. Go to `Run > Debug localhost`, and open up a web browser. Be sure to install a plugin like [Xdebug helper](https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc) which sets the IDE key to `PHPStorm` automatically for you. Enable the browser extension and activate it on the site, and reload the site. Xdebug within PHPStorm should now enable the debugger and stop at the toggled breakpoint.
 
 ### Composer Authentication
 
-Please first setup Magento Marketplace authentication (details at <a href="http://devdocs.magento.com/guides/v2.0/install-gde/prereq/connect-auth.html" target="_blank">http://devdocs.magento.com/guides/v2.0/install-gde/prereq/connect-auth.html</a>).
+Please first setup Magento Marketplace authentication (details in the [DevDocs](http://devdocs.magento.com/guides/v2.0/install-gde/prereq/connect-auth.html)).
 
 Place your auth token at `~/.composer/auth.json` with the following contents, like so:
 

+ 1 - 1
compose/magento-1/bin/composer

@@ -1,2 +1,2 @@
 #!/bin/bash
-eval "./bin/cli su -c \"composer "$@"\" -s /bin/bash app"
+./bin/cli composer "$@"

+ 0 - 2
compose/magento-1/bin/fixperms

@@ -1,8 +1,6 @@
 #!/bin/bash
 echo "Correcting filesystem permissions..."
 
-./bin/cli chown -R app:app /var/www
-
 ./bin/cli find media var -type f -exec chmod u+w {} \;
 ./bin/cli find media var -type d -exec chmod u+w {} \;
 ./bin/cli chmod u+x mage

+ 1 - 1
compose/magento-1/bin/start

@@ -1,2 +1,2 @@
 #!/bin/bash
-docker-sync-stack start
+docker-compose up

+ 0 - 22
compose/magento-1/docker-compose-dev.yml

@@ -1,22 +0,0 @@
-# Mark Shust's Magento Docker Compose (https://github.com/markoshust/magento-docker)
-# Version 11.1.5
-
-version: "3"
-
-services:
-  app:
-    volumes: &appvolumes
-      - magento1_appdata:/var/www/html:nocopy
-      - ~/.composer:/var/www/.composer
-
-  phpfpm:
-    volumes: *appvolumes
-
-  db:
-    volumes:
-      - dbdata:/var/lib/mysql
-
-volumes:
-  dbdata:
-  magento1_appdata:
-    external: true

+ 21 - 3
compose/magento-1/docker-compose.yml

@@ -1,5 +1,5 @@
-# Mark Shust's Magento Docker Compose (https://github.com/markoshust/magento-docker)
-# Version 11.1.5
+# Mark Shust's Docker Configuration for Magento (https://github.com/markoshust/docker-magento)
+# Version 12.0.0
 
 version: "3"
 
@@ -7,18 +7,36 @@ services:
   app:
     build: images/nginx
     ports:
-      - 80:80
+      - 80:8000
     links:
       - db
       - phpfpm
+    volumes: &appvolumes
+      - ./src:/var/www/html:delegated
+      - ~/.composer:/var/www/.composer:delegated
 
   phpfpm:
     image: markoshust/magento-php:5.6-fpm
     links:
       - db
+    volumes: *appvolumes
+
+  cron:
+    image: markoshust/magento-php:5.6-fpm
+    user: root
+    command: /usr/local/bin/cronstart
+    tty: true
+    links:
+      - db
+    volumes: *appvolumes
 
   db:
     image: percona:5.7
     ports:
       - 3306:3306
     env_file: env/db.env
+    volumes:
+      - dbdata:/var/lib/mysql
+
+volumes:
+  dbdata:

+ 0 - 13
compose/magento-1/docker-sync.yml

@@ -1,13 +0,0 @@
-# Mark Shust's Magento Docker Compose (https://github.com/markoshust/magento-docker)
-# Version 11.1.5
-
-version: "2"
-
-syncs:
-  magento1_appdata:
-    notify_terminal: false
-    src: ./src
-    sync_strategy: native_osx
-    sync_userid: 1000
-    sync_groupid: 1000
-    sync_excludes: ['.idea', '.git*', 'var/cache', 'var/full_page_cache', 'var/session']

+ 3 - 2
compose/magento-1/images/nginx/conf/default.conf

@@ -1,12 +1,13 @@
 upstream fastcgi_backend {
-  server PHP_HOST:PHP_PORT;
+  server phpfpm:9000;
 }
 
 server {
-  listen 80;
+  listen 8000;
   server_name localhost;
 
   set $MAGE_ROOT /var/www/html;
+  set $MAGE_IS_DEVELOPER_MODE true;
 
   root $MAGE_ROOT;
 

+ 1 - 1
compose/magento-2/bin/composer

@@ -1,2 +1,2 @@
 #!/bin/bash
-eval "./bin/cli su -c \"composer "$@"\" -s /bin/bash app"
+./bin/cli composer "$@"

+ 0 - 2
compose/magento-2/bin/fixperms

@@ -1,8 +1,6 @@
 #!/bin/bash
 echo "Correcting filesystem permissions..."
 
-./bin/cli chown -R app:app /var/www
-
 ./bin/cli find var vendor pub/static pub/media app/etc -type f -exec chmod u+w {} \;
 ./bin/cli find var vendor pub/static pub/media app/etc -type d -exec chmod u+w {} \;
 ./bin/cli chmod u+x bin/magento

+ 1 - 1
compose/magento-2/bin/magento

@@ -1,2 +1,2 @@
 #!/bin/bash
-eval "./bin/cli su -c \"./bin/magento "$@"\" -s /bin/bash app"
+./bin/cli ./bin/magento "$@"

+ 1 - 2
compose/magento-2/bin/setup

@@ -1,7 +1,7 @@
 #!/bin/bash
 ./bin/cli chmod u+x bin/magento
 
-docker-compose exec phpfpm su -c "/usr/local/bin/php ./bin/magento setup:install \
+docker-compose exec phpfpm /usr/local/bin/php ./bin/magento setup:install \
   --db-host=db \
   --db-name=magento \
   --db-user=magento \
@@ -15,7 +15,6 @@ docker-compose exec phpfpm su -c "/usr/local/bin/php ./bin/magento setup:install
   --language=en_US \
   --currency=USD \
   --timezone=America/New_York \
-" -s /bin/bash app
 
 ./bin/fixperms
 

+ 1 - 1
compose/magento-2/bin/start

@@ -1,2 +1,2 @@
 #!/bin/bash
-docker-sync-stack start
+docker-compose up

+ 0 - 22
compose/magento-2/docker-compose-dev.yml

@@ -1,22 +0,0 @@
-# Mark Shust's Magento Docker Compose (https://github.com/markoshust/magento-docker)
-# Version 11.1.5
-
-version: "3"
-
-services:
-  app:
-    volumes: &appvolumes
-      - magento2_appdata:/var/www/html:nocopy
-      - ~/.composer:/var/www/html/var/composer_home
-
-  phpfpm:
-    volumes: *appvolumes
-
-  db:
-    volumes:
-      - dbdata:/var/lib/mysql
-
-volumes:
-  dbdata:
-  magento2_appdata:
-    external: true

+ 21 - 3
compose/magento-2/docker-compose.yml

@@ -1,5 +1,5 @@
-# Mark Shust's Magento Docker Compose (https://github.com/markoshust/magento-docker)
-# Version 11.1.5
+# Mark Shust's Docker Configuration for Magento (https://github.com/markoshust/docker-magento)
+# Version 12.0.0
 
 version: "3"
 
@@ -7,18 +7,36 @@ services:
   app:
     image: markoshust/magento-nginx:1.13
     ports:
-      - 80:80
+      - 80:8000
     links:
       - db
       - phpfpm
+    volumes: &appvolumes
+      - ./src:/var/www/html:delegated
+      - ~/.composer:/var/www/html/var/composer_home:delegated
 
   phpfpm:
     image: markoshust/magento-php:7.1-fpm
     links:
       - db
+    volumes: *appvolumes
+
+  cron:
+    image: markoshust/magento-php:7.1-fpm
+    user: root
+    command: /usr/local/bin/cronstart
+    tty: true
+    links:
+      - db
+    volumes: *appvolumes
 
   db:
     image: percona:5.7
     ports:
       - 3306:3306
     env_file: env/db.env
+    volumes:
+      - dbdata:/var/lib/mysql
+
+volumes:
+  dbdata:

+ 0 - 13
compose/magento-2/docker-sync.yml

@@ -1,13 +0,0 @@
-# Mark Shust's Magento Docker Compose (https://github.com/markoshust/magento-docker)
-# Version 11.1.5
-
-version: "2"
-
-syncs:
-  magento2_appdata:
-    notify_terminal: false
-    src: ./src
-    sync_strategy: native_osx
-    sync_userid: 1000
-    sync_groupid: 1000
-    sync_excludes: ['.idea', '.git*', 'pub/media', 'pub/static', 'var/cache', 'var/composer_home', 'var/page_cache', 'var/session', 'var/tmp', 'var/view_preprocessed']

+ 6 - 7
images/nginx/1.13/Dockerfile

@@ -3,15 +3,14 @@ MAINTAINER Mark Shust <mark@shust.com>
 
 RUN groupadd -g 1000 app \
  && useradd -g 1000 -u 1000 -d /var/www -s /bin/bash app
-
-ENV PHP_HOST phpfpm
-ENV PHP_PORT 9000
-ENV APP_MAGE_MODE developer
+RUN touch /var/run/nginx.pid
+RUN chown -R app:app /var/cache/nginx/ /var/run/nginx.pid
 
 COPY ./conf/nginx.conf /etc/nginx/
 COPY ./conf/default.conf /etc/nginx/conf.d/
-COPY ./bin/start /usr/local/bin/start
 
-WORKDIR /var/www/html
+USER app:app
 
-CMD ["/usr/local/bin/start"]
+VOLUME /var/www
+
+WORKDIR /var/www/html

+ 0 - 6
images/nginx/1.13/bin/start

@@ -1,6 +0,0 @@
-#!/bin/bash
-[ ! -z "${PHP_HOST}" ] && sed -i "s/PHP_HOST/${PHP_HOST}/" /etc/nginx/conf.d/default.conf
-[ ! -z "${PHP_PORT}" ] && sed -i "s/PHP_PORT/${PHP_PORT}/" /etc/nginx/conf.d/default.conf
-[ ! -z "${APP_MAGE_MODE}" ] && sed -i "s/APP_MAGE_MODE/${APP_MAGE_MODE}/" /etc/nginx/conf.d/default.conf
-
-/usr/sbin/nginx -g "daemon off;"

+ 3 - 3
images/nginx/1.13/conf/default.conf

@@ -1,13 +1,13 @@
 upstream fastcgi_backend {
-  server PHP_HOST:PHP_PORT;
+  server phpfpm:9000;
 }
 
 server {
-  listen 80;
+  listen 8000;
   server_name localhost;
 
   set $MAGE_ROOT /var/www/html;
-  set $MAGE_MODE APP_MAGE_MODE;
+  set $MAGE_MODE developer;
 
   root $MAGE_ROOT/pub;
 

+ 3 - 2
images/nginx/1.13/conf/default.magento1.conf

@@ -1,12 +1,13 @@
 upstream fastcgi_backend {
-  server PHP_HOST:PHP_PORT;
+  server phpfpm:9000;
 }
 
 server {
-  listen 80;
+  listen 8000;
   server_name localhost;
 
   set $MAGE_ROOT /var/www/html;
+  set $MAGE_IS_DEVELOPER_MODE true;
 
   root $MAGE_ROOT;
 

+ 0 - 1
images/nginx/1.13/conf/nginx.conf

@@ -1,4 +1,3 @@
-user app;
 worker_processes 1;
 
 error_log /var/log/nginx/error.log debug;

+ 7 - 5
images/php/5.6/Dockerfile

@@ -39,17 +39,19 @@ RUN curl -sS https://getcomposer.org/installer | \
 RUN groupadd -g 1000 app \
  && useradd -g 1000 -u 1000 -d /var/www -s /bin/bash app
 
-RUN printf '* *\t* * *\tapp\t%s/usr/local/bin/php /var/www/html/cron.php\n#' >> /etc/crontab
+RUN printf '* *\t* * *\tapp\t%s/usr/local/bin/php /var/www/html/cron.php\n#\n' >> /etc/crontab
 
 COPY conf/www.conf /usr/local/etc/php-fpm.d/
 COPY conf/php.ini /usr/local/etc/php/
 COPY conf/php-fpm.conf /usr/local/etc/
-COPY bin/start /usr/local/bin/
+COPY bin/cronstart /usr/local/bin/
 
-RUN chmod +x /usr/local/bin/start
+RUN chown -R app:app /usr/local/etc/php/conf.d
+
+USER app:app
+
+VOLUME /var/www
 
 WORKDIR /var/www/html
 
 EXPOSE 9001
-
-CMD ["/usr/local/bin/start"]

+ 4 - 0
images/php/5.6/bin/cronstart

@@ -0,0 +1,4 @@
+#!/bin/bash
+service cron start
+
+/usr/bin/crontab

+ 0 - 7
images/php/5.6/bin/start

@@ -1,7 +0,0 @@
-#!/bin/bash
-
-# Start the cron service
-/usr/sbin/cron
-
-# Start the php-fpm service
-/usr/local/sbin/php-fpm

+ 9 - 7
images/php/7.0/Dockerfile

@@ -39,19 +39,21 @@ RUN curl -sS https://getcomposer.org/installer | \
 RUN groupadd -g 1000 app \
  && useradd -g 1000 -u 1000 -d /var/www -s /bin/bash app
 
-RUN printf '* *\t* * *\tapp\t%s/usr/local/bin/php /var/www/html/update/cron.php\n#' >> /etc/crontab
-RUN printf '* *\t* * *\tapp\t%s/usr/local/bin/php /var/www/html/bin/magento cron:run\n#' >> /etc/crontab
-RUN printf '* *\t* * *\tapp\t%s/usr/local/bin/php /var/www/html/bin/magento setup:cron:run\n#' >> /etc/crontab
+RUN printf '* *\t* * *\tapp\t%s/usr/local/bin/php /var/www/html/update/cron.php\n' >> /etc/crontab
+RUN printf '* *\t* * *\tapp\t%s/usr/local/bin/php /var/www/html/bin/magento cron:run\n' >> /etc/crontab
+RUN printf '* *\t* * *\tapp\t%s/usr/local/bin/php /var/www/html/bin/magento setup:cron:run\n#\n' >> /etc/crontab
 
 COPY conf/www.conf /usr/local/etc/php-fpm.d/
 COPY conf/php.ini /usr/local/etc/php/
 COPY conf/php-fpm.conf /usr/local/etc/
-COPY bin/start /usr/local/bin/
+COPY bin/cronstart /usr/local/bin/
 
-RUN chmod +x /usr/local/bin/start
+RUN chown -R app:app /usr/local/etc/php/conf.d
+
+USER app:app
+
+VOLUME /var/www
 
 WORKDIR /var/www/html
 
 EXPOSE 9001
-
-CMD ["/usr/local/bin/start"]

+ 7 - 0
images/php/7.0/bin/cronstart

@@ -0,0 +1,7 @@
+#!/bin/bash
+service cron start
+
+touch /var/www/html/var/.setup_cronjob_status /var/www/html/var/.update_cronjob_status
+chown app:app /var/www/html/var/.setup_cronjob_status /var/www/html/var/.update_cronjob_status
+
+/usr/bin/crontab

+ 0 - 7
images/php/7.0/bin/start

@@ -1,7 +0,0 @@
-#!/bin/bash
-
-# Start the cron service
-/usr/sbin/cron
-
-# Start the php-fpm service
-/usr/local/sbin/php-fpm

+ 9 - 7
images/php/7.1/Dockerfile

@@ -39,19 +39,21 @@ RUN curl -sS https://getcomposer.org/installer | \
 RUN groupadd -g 1000 app \
  && useradd -g 1000 -u 1000 -d /var/www -s /bin/bash app
 
-RUN printf '* *\t* * *\tapp\t%s/usr/local/bin/php /var/www/html/update/cron.php\n#' >> /etc/crontab
-RUN printf '* *\t* * *\tapp\t%s/usr/local/bin/php /var/www/html/bin/magento cron:run\n#' >> /etc/crontab
-RUN printf '* *\t* * *\tapp\t%s/usr/local/bin/php /var/www/html/bin/magento setup:cron:run\n#' >> /etc/crontab
+RUN printf '* *\t* * *\tapp\t%s/usr/local/bin/php /var/www/html/update/cron.php\n' >> /etc/crontab
+RUN printf '* *\t* * *\tapp\t%s/usr/local/bin/php /var/www/html/bin/magento cron:run\n' >> /etc/crontab
+RUN printf '* *\t* * *\tapp\t%s/usr/local/bin/php /var/www/html/bin/magento setup:cron:run\n#\n' >> /etc/crontab
 
 COPY conf/www.conf /usr/local/etc/php-fpm.d/
 COPY conf/php.ini /usr/local/etc/php/
 COPY conf/php-fpm.conf /usr/local/etc/
-COPY bin/start /usr/local/bin/
+COPY bin/cronstart /usr/local/bin/
 
-RUN chmod +x /usr/local/bin/start
+RUN chown -R app:app /usr/local/etc/php/conf.d
+
+USER app:app
+
+VOLUME /var/www
 
 WORKDIR /var/www/html
 
 EXPOSE 9001
-
-CMD ["/usr/local/bin/start"]

+ 7 - 0
images/php/7.1/bin/cronstart

@@ -0,0 +1,7 @@
+#!/bin/bash
+service cron start
+
+touch /var/www/html/var/.setup_cronjob_status /var/www/html/var/.update_cronjob_status
+chown app:app /var/www/html/var/.setup_cronjob_status /var/www/html/var/.update_cronjob_status
+
+/usr/bin/crontab

+ 0 - 7
images/php/7.1/bin/start

@@ -1,7 +0,0 @@
-#!/bin/bash
-
-# Start the cron service
-/usr/sbin/cron
-
-# Start the php-fpm service
-/usr/local/sbin/php-fpm

+ 2 - 2
images/php/7.1/conf/php-fpm.conf

@@ -11,8 +11,8 @@ daemonize = no
 ; if we send this to /proc/self/fd/1, it never appears
 access.log = /proc/self/fd/2
 
-user = app
-group = app
+;user = app
+;group = app
 
 listen = [::]:9000