diff --git a/.env b/.env index aef828c..326d591 100644 --- a/.env +++ b/.env @@ -1 +1,4 @@ COMPOSE_PROJECT_NAME=m2_meanbee_serviceworker + +PROJECT_HOSTNAME=m2-meanbee-serviceworker.dev.docker +PROJECT_CERT=dev.docker diff --git a/README.md b/README.md index b94b3e5..da0e987 100644 --- a/README.md +++ b/README.md @@ -46,10 +46,8 @@ Magento 2 uses a timestamp version string in the URL for static files to allow b A Docker development environment is included with the project: - mkdir magento - docker-compose up -d db # Allow a few seconds for the db to initalise - docker-compose run --rm cli bash /src/setup.sh - docker-compose up -d + docker-compose run --rm cli magento-extension-installer Meanbee_ServiceWorker \ + && docker-compose up -d ### npm dependencies diff --git a/composer.json b/composer.json index efffdb4..48f96ce 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "meanbee/magento2-serviceworker", "description": "A Magento 2 extension that adds Service Worker support.", "type": "magento2-module", - "version": "2.0.0", + "version": "2.1.0", "license": [ "MIT" ], @@ -19,10 +19,10 @@ } }, "require": { - "magento/framework": "^100.1.2", + "magento/framework": "^102.0.0", "magento/module-backend": "^100.1.1", - "magento/module-config": "^100.1.1", - "magento/module-cms": "^101.0.2" + "magento/module-config": "^102.0.0", + "magento/module-cms": "^103.0.0" }, "autoload": { "files": [ diff --git a/docker-compose.yml b/docker-compose.yml index e2357af..a59591c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,82 +2,72 @@ version: "2" services: varnish: image: meanbee/magento2-varnish:latest - hostname: m2-meanbee-serviceworker.docker + hostname: ${PROJECT_HOSTNAME} ports: - 80 environment: - - VIRTUAL_HOST=m2-meanbee-serviceworker.docker - - VIRTUAL_PORT=80 - - HTTPS_METHOD=noredirect - - CERT_NAME=default + VIRTUAL_HOST: ${PROJECT_HOSTNAME} + VIRTUAL_PORT: 80 + HTTPS_METHOD: noredirect + CERT_NAME: ${PROJECT_CERT} links: - web web: image: meanbee/magento2-nginx:1.9 - hostname: web.m2-meanbee-serviceworker.docker + hostname: web.${PROJECT_HOSTNAME} ports: - 80 volumes_from: - - appdata - env_file: - - ./magento.env + - magento links: - fpm fpm: image: meanbee/magento2-php:7.0-fpm - hostname: fpm.m2-meanbee-serviceworker.docker + hostname: fpm.${PROJECT_HOSTNAME} ports: - 9000 volumes_from: - - appdata - env_file: - - ./magento.env + - magento environment: - - ENABLE_SENDMAIL=true - - PHP_ENABLE_XDEBUG + ENABLE_SENDMAIL: "true" + PHP_ENABLE_XDEBUG: links: - db cron: image: meanbee/magento2-php:7.0-cli - hostname: cron.m2-meanbee-serviceworker.docker + hostname: cron.${PROJECT_HOSTNAME} command: run-cron volumes_from: - - appdata - env_file: - - ./magento.env + - magento environment: - - ENABLE_SENDMAIL=true + ENABLE_SENDMAIL: "true" links: - db cli: image: meanbee/magento2-php:7.0-cli volumes_from: - - appdata - volumes: - - ~/.composer:/root/.composer - env_file: - - ./magento.env + - magento environment: - - COMPOSER_HOME=/root/.composer - - COMPOSER_ALLOW_SUPERUSER=1 - - M2SETUP_INSTALL_DB=true - - M2SETUP_VERSION=2.1.* - - M2SETUP_USE_SAMPLE_DATA=true - - M2SETUP_DB_HOST=db - - M2SETUP_DB_NAME=magento2 - - M2SETUP_DB_USER=magento2 - - M2SETUP_DB_PASSWORD=magento2 - - M2SETUP_BASE_URL=https://m2-meanbee-serviceworker.docker/ - - M2SETUP_BACKEND_FRONTNAME=admin - - M2SETUP_ADMIN_FIRSTNAME=Admin - - M2SETUP_ADMIN_LASTNAME=User - - M2SETUP_ADMIN_EMAIL=admin@example.com - - M2SETUP_ADMIN_USER=admin - - M2SETUP_ADMIN_PASSWORD=password123 + COMPOSER_HOME: /root/.composer + COMPOSER_ALLOW_SUPERUSER: 1 + M2SETUP_INSTALL_DB: "true" + M2SETUP_VERSION: 2.2.* + M2SETUP_USE_SAMPLE_DATA: "true" + M2SETUP_DB_HOST: db + M2SETUP_DB_NAME: magento2 + M2SETUP_DB_USER: magento2 + M2SETUP_DB_PASSWORD: magento2 + M2SETUP_BASE_URL: https://${PROJECT_HOSTNAME}/ + M2SETUP_BACKEND_FRONTNAME: admin + M2SETUP_ADMIN_FIRSTNAME: Admin + M2SETUP_ADMIN_LASTNAME: User + M2SETUP_ADMIN_EMAIL: admin@example.com + M2SETUP_ADMIN_USER: admin + M2SETUP_ADMIN_PASSWORD: password123 links: - db @@ -88,38 +78,29 @@ services: volumes: - ~/.npm:/.npm volumes_from: - - appdata + - magento db: image: mariadb:10 ports: - 3306 - volumes_from: - - dbdata - env_file: - - ./magento.env + volumes: + - dbdata:/var/lib/mysql environment: - - MYSQL_ROOT_PASSWORD=magento2 - - MYSQL_USER=magento2 - - MYSQL_PASSWORD=magento2 - - MYSQL_DATABASE=magento2 - - TERM=dumb + MYSQL_ROOT_PASSWORD: magento2 + MYSQL_USER: magento2 + MYSQL_PASSWORD: magento2 + MYSQL_DATABASE: magento2 + TERM: dumb - appdata: - image: cweagans/bg-sync + magento: + image: meanbee/magento2-data:2.2-sample volumes: - - /var/www/magento - - .:/src + - .:/extensions/Meanbee_ServiceWorker environment: - - SYNC_SOURCE=/var/www/magento - - SYNC_DESTINATION=/src/magento - - SYNC_VERBOSE=1 - - SYNC_MAX_INOTIFY_WATCHES=64000 + SYNC_DESTINATION: /extensions/Meanbee_ServiceWorker/magento privileged: true - restart: on-failure:5 +volumes: dbdata: - image: tianon/true - volumes: - - /var/lib/mysql - + # Database tables diff --git a/magento.env b/magento.env deleted file mode 100644 index 05eab49..0000000 --- a/magento.env +++ /dev/null @@ -1,2 +0,0 @@ -MAGENTO_RUN_MODE=production -PHP_MEMORY_LIMIT=2G diff --git a/setup.sh b/setup.sh deleted file mode 100644 index fe1806f..0000000 --- a/setup.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -set -e # Exit on error - -# Install Magento 2 if necessary -magento-installer - -cd $MAGENTO_ROOT - -# Add the extension via Composer -composer config repositories.meanbee_serviceworker '{"type": "path", "url": "/src", "options": {"symlink": true}}' - -composer require "meanbee/magento2-serviceworker" "@dev" - -# Workaround for Magento only allowing template paths within the install root -ln -s /src $MAGENTO_ROOT/src - -# Enable the extension and run migrations -magento-command module:enable Meanbee_ServiceWorker -magento-command setup:upgrade -magento-command setup:static-content:deploy -magento-command cache:flush diff --git a/src/view/frontend/layout/default.xml b/src/view/frontend/layout/default.xml index d841633..c8e4ca4 100644 --- a/src/view/frontend/layout/default.xml +++ b/src/view/frontend/layout/default.xml @@ -2,7 +2,7 @@ - +