From 38915832d4622282674b484a54a331eb6a35be68 Mon Sep 17 00:00:00 2001 From: vbuck Date: Thu, 9 Apr 2020 11:45:56 -0400 Subject: [PATCH 1/9] Add support for Magepack --- commands/env-init.cmd | 1 + commands/env.cmd | 3 +++ .../magento2/magento2.magepack.base.yml | 19 +++++++++++++++++++ environments/magento2/magepack/Dockerfile | 13 +++++++++++++ environments/magento2/magepack/bundle.sh | 3 +++ environments/magento2/magepack/generate.sh | 3 +++ 6 files changed, 42 insertions(+) create mode 100644 environments/magento2/magento2.magepack.base.yml create mode 100644 environments/magento2/magepack/Dockerfile create mode 100755 environments/magento2/magepack/bundle.sh create mode 100755 environments/magento2/magepack/generate.sh diff --git a/commands/env-init.cmd b/commands/env-init.cmd index 32322aab..1b69e13f 100644 --- a/commands/env-init.cmd +++ b/commands/env-init.cmd @@ -65,6 +65,7 @@ if [[ "${WARDEN_ENV_TYPE}" == "magento2" ]]; then WARDEN_SPLIT_SALES=0 WARDEN_SPLIT_CHECKOUT=0 WARDEN_TEST_DB=0 + WARDEN_MAGEPACK=0 BLACKFIRE_CLIENT_ID= BLACKFIRE_CLIENT_TOKEN= diff --git a/commands/env.cmd b/commands/env.cmd index ce89d3d7..8d101ea4 100644 --- a/commands/env.cmd +++ b/commands/env.cmd @@ -41,6 +41,9 @@ fi [[ ${WARDEN_SELENIUM} -eq 1 ]] \ && appendEnvPartialIfExists "selenium.base" +[[ ${WARDEN_MAGEPACK} -eq 1 ]] \ + && appendEnvPartialIfExists "magepack.base" + if [[ -f "${WARDEN_ENV_PATH}/.warden/warden-env.yml" ]]; then DOCKER_COMPOSE_ARGS+=("-f") DOCKER_COMPOSE_ARGS+=("${WARDEN_ENV_PATH}/.warden/warden-env.yml") diff --git a/environments/magento2/magento2.magepack.base.yml b/environments/magento2/magento2.magepack.base.yml new file mode 100644 index 00000000..204432a0 --- /dev/null +++ b/environments/magento2/magento2.magepack.base.yml @@ -0,0 +1,19 @@ +version: "3.5" +services: + magepack: + hostname: magepack + build: + context: ./environments/magento2/magepack + dockerfile: Dockerfile + environment: + - TRAEFIK_DOMAIN + - TRAEFIK_SUBDOMAIN + extra_hosts: + - ${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0} + - ${TRAEFIK_SUBDOMAIN:-app}.${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0} + depends_on: + - nginx + volumes: + - appdata:/var/www/html + networks: + - default diff --git a/environments/magento2/magepack/Dockerfile b/environments/magento2/magepack/Dockerfile new file mode 100644 index 00000000..925d3660 --- /dev/null +++ b/environments/magento2/magepack/Dockerfile @@ -0,0 +1,13 @@ +FROM zenika/alpine-chrome:with-puppeteer + +USER root + +WORKDIR /var/www/html +COPY generate.sh /usr/bin/generate +COPY bundle.sh /usr/bin/bundle + +RUN mkdir -p /var/www/html && \ + npm install -g git+https://github.com/vbuck/magepack.git && \ + npm cache clean --force + +ENTRYPOINT ["tail", "-f", "/dev/null"] diff --git a/environments/magento2/magepack/bundle.sh b/environments/magento2/magepack/bundle.sh new file mode 100755 index 00000000..dcaf2116 --- /dev/null +++ b/environments/magento2/magepack/bundle.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +/usr/bin/magepack bundle diff --git a/environments/magento2/magepack/generate.sh b/environments/magento2/magepack/generate.sh new file mode 100755 index 00000000..ff76e9c6 --- /dev/null +++ b/environments/magento2/magepack/generate.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +/usr/bin/magepack generate "$@" From bef0ef7a1f2b70cfc9f53305d748d67e58d7c1ca Mon Sep 17 00:00:00 2001 From: vbuck Date: Tue, 14 Apr 2020 21:11:00 -0400 Subject: [PATCH 2/9] Change to official NPM package, adjust runtime user to match php-fpm container --- environments/magento2/magepack/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/environments/magento2/magepack/Dockerfile b/environments/magento2/magepack/Dockerfile index 925d3660..3e27d2b2 100644 --- a/environments/magento2/magepack/Dockerfile +++ b/environments/magento2/magepack/Dockerfile @@ -7,7 +7,9 @@ COPY generate.sh /usr/bin/generate COPY bundle.sh /usr/bin/bundle RUN mkdir -p /var/www/html && \ - npm install -g git+https://github.com/vbuck/magepack.git && \ + npm install -g magepack@^2.3 && \ npm cache clean --force ENTRYPOINT ["tail", "-f", "/dev/null"] + +USER chrome From 274772f4af61751df7672e4ac48a324014f0df05 Mon Sep 17 00:00:00 2001 From: David Alger Date: Wed, 3 Jun 2020 10:39:57 -0500 Subject: [PATCH 3/9] Updated volume configuration for proper linux/darwin support --- environments/magento2/magento2.magepack.base.yml | 2 -- environments/magento2/magento2.magepack.darwin.yml | 8 ++++++++ environments/magento2/magento2.magepack.linux.yml | 7 +++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 environments/magento2/magento2.magepack.darwin.yml create mode 100644 environments/magento2/magento2.magepack.linux.yml diff --git a/environments/magento2/magento2.magepack.base.yml b/environments/magento2/magento2.magepack.base.yml index 204432a0..b250d548 100644 --- a/environments/magento2/magento2.magepack.base.yml +++ b/environments/magento2/magento2.magepack.base.yml @@ -13,7 +13,5 @@ services: - ${TRAEFIK_SUBDOMAIN:-app}.${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0} depends_on: - nginx - volumes: - - appdata:/var/www/html networks: - default diff --git a/environments/magento2/magento2.magepack.darwin.yml b/environments/magento2/magento2.magepack.darwin.yml new file mode 100644 index 00000000..f18c0187 --- /dev/null +++ b/environments/magento2/magento2.magepack.darwin.yml @@ -0,0 +1,8 @@ +version: "3.5" + +x-volumes: &volumes + - .${WARDEN_WEB_ROOT:-}/pub/media:/var/www/html/pub/media:delegated + - appdata:/var/www/html + +services: + magepack: { volumes: *volumes } diff --git a/environments/magento2/magento2.magepack.linux.yml b/environments/magento2/magento2.magepack.linux.yml new file mode 100644 index 00000000..0ce55331 --- /dev/null +++ b/environments/magento2/magento2.magepack.linux.yml @@ -0,0 +1,7 @@ +version: "3.5" + +x-volumes: &volumes + - .${WARDEN_WEB_ROOT:-}/:/var/www/html + +services: + magepack: { volumes: *volumes } From b348dedffc2e72a8151b29d5975ea260b1661e7b Mon Sep 17 00:00:00 2001 From: David Alger Date: Wed, 3 Jun 2020 10:40:19 -0500 Subject: [PATCH 4/9] Changed dependency to php-fpm as that is where files are synced into the appdata volume --- environments/magento2/magento2.magepack.base.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/environments/magento2/magento2.magepack.base.yml b/environments/magento2/magento2.magepack.base.yml index b250d548..d016044f 100644 --- a/environments/magento2/magento2.magepack.base.yml +++ b/environments/magento2/magento2.magepack.base.yml @@ -12,6 +12,4 @@ services: - ${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0} - ${TRAEFIK_SUBDOMAIN:-app}.${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0} depends_on: - - nginx - networks: - - default + - php-fpm From 2e135be4846cebeeadc1016f18c4b6d453405deb Mon Sep 17 00:00:00 2001 From: David Alger Date: Wed, 3 Jun 2020 10:41:25 -0500 Subject: [PATCH 5/9] Updated to use pre-built magepack image hosted on docker.io --- environments/magento2/magento2.magepack.base.yml | 6 ++---- .../magento2/magepack => images/magepack/2.3}/Dockerfile | 0 .../magento2/magepack => images/magepack/context}/bundle.sh | 0 .../magepack => images/magepack/context}/generate.sh | 0 4 files changed, 2 insertions(+), 4 deletions(-) rename {environments/magento2/magepack => images/magepack/2.3}/Dockerfile (100%) rename {environments/magento2/magepack => images/magepack/context}/bundle.sh (100%) rename {environments/magento2/magepack => images/magepack/context}/generate.sh (100%) diff --git a/environments/magento2/magento2.magepack.base.yml b/environments/magento2/magento2.magepack.base.yml index d016044f..fb77e16d 100644 --- a/environments/magento2/magento2.magepack.base.yml +++ b/environments/magento2/magento2.magepack.base.yml @@ -1,10 +1,8 @@ version: "3.5" services: magepack: - hostname: magepack - build: - context: ./environments/magento2/magepack - dockerfile: Dockerfile + hostname: "${WARDEN_ENV_NAME}-magepack" + image: docker.io/wardenenv/magepack:${MAGEPACK_VERSION:-2.3} environment: - TRAEFIK_DOMAIN - TRAEFIK_SUBDOMAIN diff --git a/environments/magento2/magepack/Dockerfile b/images/magepack/2.3/Dockerfile similarity index 100% rename from environments/magento2/magepack/Dockerfile rename to images/magepack/2.3/Dockerfile diff --git a/environments/magento2/magepack/bundle.sh b/images/magepack/context/bundle.sh similarity index 100% rename from environments/magento2/magepack/bundle.sh rename to images/magepack/context/bundle.sh diff --git a/environments/magento2/magepack/generate.sh b/images/magepack/context/generate.sh similarity index 100% rename from environments/magento2/magepack/generate.sh rename to images/magepack/context/generate.sh From de6b1cb03586510221c9b78882ffe3e1a99c95d5 Mon Sep 17 00:00:00 2001 From: David Alger Date: Wed, 3 Jun 2020 10:42:40 -0500 Subject: [PATCH 6/9] Added CI workflow to build the magepack image --- .github/workflows/docker-image-magepack.yml | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/docker-image-magepack.yml diff --git a/.github/workflows/docker-image-magepack.yml b/.github/workflows/docker-image-magepack.yml new file mode 100644 index 00000000..989db75d --- /dev/null +++ b/.github/workflows/docker-image-magepack.yml @@ -0,0 +1,22 @@ +name: Docker Image Magepack +on: + schedule: + - cron: "0 6 * * 1" # 6 AM UTC on Monday + push: + paths: + - version + - images/.trigger + - images/magepack/** + branches: + - develop +jobs: + magepack: + name: Magepack + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - run: ./images/scripts/build.sh --push "${BUILD_GROUP}" + env: + BUILD_GROUP: magepack + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} From 036b5f0618b5afd61e8b76cbf7214c4cbc6d7927 Mon Sep 17 00:00:00 2001 From: David Alger Date: Wed, 3 Jun 2020 11:10:54 -0500 Subject: [PATCH 7/9] Updated magepack partial loading for compat with 0.5.0 refactoring --- commands/env.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/env.cmd b/commands/env.cmd index d3f33e5b..f7496fda 100644 --- a/commands/env.cmd +++ b/commands/env.cmd @@ -83,7 +83,7 @@ fi && appendEnvPartialIfExists "selenium" [[ ${WARDEN_MAGEPACK} -eq 1 ]] \ - && appendEnvPartialIfExists "magepack.base" + && appendEnvPartialIfExists "${WARDEN_ENV_TYPE}.magepack" if [[ -f "${WARDEN_ENV_PATH}/.warden/warden-env.yml" ]]; then DOCKER_COMPOSE_ARGS+=("-f") From 8a1391223b642352a6ef2446969f52b0794ec658 Mon Sep 17 00:00:00 2001 From: David Alger Date: Wed, 3 Jun 2020 11:12:18 -0500 Subject: [PATCH 8/9] Changed entrypoint to cmd so it's possible to run and get inside container image by overriding the cmd --- images/magepack/2.3/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/magepack/2.3/Dockerfile b/images/magepack/2.3/Dockerfile index 3e27d2b2..da203fb5 100644 --- a/images/magepack/2.3/Dockerfile +++ b/images/magepack/2.3/Dockerfile @@ -10,6 +10,6 @@ RUN mkdir -p /var/www/html && \ npm install -g magepack@^2.3 && \ npm cache clean --force -ENTRYPOINT ["tail", "-f", "/dev/null"] +CMD tail -f /dev/null USER chrome From e9713aa4dbccd0a6518795e842d5064b138d0a2e Mon Sep 17 00:00:00 2001 From: David Alger Date: Wed, 3 Jun 2020 11:12:38 -0500 Subject: [PATCH 9/9] Removed mkdir from dockerfile since it's not needed --- images/magepack/2.3/Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/images/magepack/2.3/Dockerfile b/images/magepack/2.3/Dockerfile index da203fb5..a2df7d5f 100644 --- a/images/magepack/2.3/Dockerfile +++ b/images/magepack/2.3/Dockerfile @@ -6,9 +6,7 @@ WORKDIR /var/www/html COPY generate.sh /usr/bin/generate COPY bundle.sh /usr/bin/bundle -RUN mkdir -p /var/www/html && \ - npm install -g magepack@^2.3 && \ - npm cache clean --force +RUN npm install -g magepack@^2.3 && npm cache clean --force CMD tail -f /dev/null