diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 30f2145..2dddcc8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -154,9 +154,24 @@ jobs: - path: sphinx tags: - riptidepy/sphinx:latest - - path: shopify + - path: shopify/n18.19.0/p8.1 + tags: + - riptidepy/shopify:n18.19_p8.1 + - path: shopify/n18.19.0/p8.2 + tags: + - riptidepy/shopify:n18.19_p8.2 + - path: shopify/n18.19.0/p8.3 tags: - riptidepy/shopify:n18.19_p8.3 + - path: shopify/n20.11.0/p8.1 + tags: + - riptidepy/shopify:n20.11_p8.1 + - path: shopify/n20.11.0/p8.2 + tags: + - riptidepy/shopify:n20.11_p8.2 + - path: shopify/n20.11.0/p8.3 + tags: + - riptidepy/shopify:n20.11_p8.3 - path: keycloak/latest tags: - riptidepy/keycloak:latest diff --git a/shopify/README.md b/shopify/README.md index dab119e..94e721a 100644 --- a/shopify/README.md +++ b/shopify/README.md @@ -68,8 +68,15 @@ Please update your projects to use a version following the new scheme: {firstLowercaseCharacterOfLanguage[anOptionalSecondCharacter]}{version} divided by underscores e.g.: `n20.11_p8.1` Ruby and Rust are skipped for now since we assume that there is no need for containers with specific versions of these languages. +The Rust version in all of these images is updated to the latest version available in the Alpine version +used at build time. See below for current versions. + | V | Node | PHP | Ruby | Rust | |-------------|-------|-----|------|------| -| latest | 18.16 | 8.1 | | | -| n20.11_p8.1 | 20.11 | 8.1 | 3.1 | 1.60 | -| n18.19_p8.3 | 18.19 | 8.3 | 3.1 | 1.60 | +| latest | 18.16 | 8.1 | | 1.60 | +| n18.19_p8.1 | 18.19 | 8.1 | 3.1 | 1.78 | +| n18.19_p8.2 | 18.19 | 8.2 | 3.1 | 1.78 | +| n18.19_p8.3 | 18.19 | 8.3 | 3.1 | 1.78 | +| n20.11_p8.1 | 20.11 | 8.1 | 3.1 | 1.78 | +| n20.11_p8.2 | 20.11 | 8.2 | 3.1 | 1.78 | +| n20.11_p8.3 | 20.11 | 8.3 | 3.1 | 1.78 | diff --git a/shopify/Makefile b/shopify/builder/Makefile similarity index 100% rename from shopify/Makefile rename to shopify/builder/Makefile diff --git a/shopify/builder/README.md b/shopify/builder/README.md new file mode 100644 index 0000000..24ea80c --- /dev/null +++ b/shopify/builder/README.md @@ -0,0 +1,12 @@ +shopify builder +=============== + +Build script to update the individual images. + +Creates the Dockerfile's in the other directories. + +Needs requirements: + +``` +pip3 install jinja2 +``` \ No newline at end of file diff --git a/shopify/base.makefile b/shopify/builder/base.makefile similarity index 100% rename from shopify/base.makefile rename to shopify/builder/base.makefile diff --git a/shopify/builder/build.py b/shopify/builder/build.py new file mode 100755 index 0000000..e3e8e3c --- /dev/null +++ b/shopify/builder/build.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +import os.path +import shutil + +from jinja2 import Environment, FileSystemLoader + +NODE_VERSIONS = { + # Checksum + "18.19.0": "10b7b23b6b867a25f060a433b83f5c3ecb3bcf7cdba1c0ce46443065a832fd41", + "20.11.0": "a8bec39586538896715be7a2ca7ef08727a58ad94d25876c5db11cafacff4c37", +} +PHP_VERSIONS = ["8.1", "8.2", "8.3"] +ALPINE_VERSION = "3.20" # Rust 1.78 +COPY_FILES = [ + "base.makefile", + "entrypoint.sh", + "Makefile", + "shopify-app.md" +] +BASE_DIR = os.path.join(os.path.dirname(__file__), "..") +BUILDER_DIR = os.path.join(BASE_DIR, "builder") + +if __name__ == "__main__": + env = Environment( + loader=FileSystemLoader(os.path.join(BUILDER_DIR, "jinja_tpl")), + ) + template = env.get_template("Dockerfile.jinja2") + + for node_version, node_checksum in NODE_VERSIONS.items(): + for php_version in PHP_VERSIONS: + outdir = os.path.join(BASE_DIR, f"n{node_version}", f"p{php_version}") + shutil.rmtree(outdir, ignore_errors=True) + os.makedirs(outdir) + for file in COPY_FILES: + shutil.copy( + os.path.join(BUILDER_DIR, file), + os.path.join(outdir, file), + ) + + with open(os.path.join(outdir, "Dockerfile"), "w") as f: + f.write(template.render( + alpine_version=ALPINE_VERSION, + node_version=node_version, + php_version=php_version, + node_checksum=node_checksum + )) diff --git a/shopify/entrypoint.sh b/shopify/builder/entrypoint.sh similarity index 100% rename from shopify/entrypoint.sh rename to shopify/builder/entrypoint.sh diff --git a/shopify/builder/jinja_tpl/Dockerfile.jinja2 b/shopify/builder/jinja_tpl/Dockerfile.jinja2 new file mode 100644 index 0000000..a70aa73 --- /dev/null +++ b/shopify/builder/jinja_tpl/Dockerfile.jinja2 @@ -0,0 +1,168 @@ +FROM php:{{ php_version }}-cli-alpine{{ alpine_version }} + +ARG XDEBUG_CLIENT_HOST=host.docker.internal +ENV XDEBUG_CLIENT_HOST $XDEBUG_CLIENT_HOST + +ARG DOCKER_USER=docker + +# add run dependencies +RUN apk add --no-cache \ + openrc \ + bash \ + postgresql-libs \ + ruby ruby-dev ruby-ffi libzip-dev \ + alpine-sdk \ + gcompat \ + icu \ + linux-headers \ + freetype libjpeg-turbo libpng libwebp + +# add build dependencies +RUN apk add --no-cache -t .build-deps \ + postgresql-dev \ + libxml2-dev \ + icu-dev \ + freetype-dev libpng-dev libjpeg-turbo-dev libwebp-dev \ + autoconf g++ make && \ +# install bundler for extension deployment + gem install bundler && \ +# configure xdebug + pecl install xdebug-3.3.1 && docker-php-ext-enable xdebug && \ + echo 'xdebug.mode=off' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo "xdebug.client_host=${XDEBUG_CLIENT_HOST}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo 'xdebug.cli_color=1' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo 'xdebug.start_with_request=yes' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ +# further php configuration and permissions + docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql && \ + docker-php-ext-configure simplexml && docker-php-ext-install simplexml && \ + docker-php-ext-configure pgsql && docker-php-ext-install pdo_pgsql && \ + docker-php-ext-configure zip && docker-php-ext-install zip && \ + docker-php-ext-configure intl && docker-php-ext-install intl && \ + docker-php-ext-configure gd --with-jpeg --with-webp --with-freetype && docker-php-ext-install gd && \ + chgrp 1000 /usr/local/etc/php/conf.d/ -R && \ + chmod g+w /usr/local/etc/php/conf.d/ -R && \ +# remove build dependencies + apk del --purge .build-deps + +# install composer +COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer + +# use the default production configuration for PHP +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" + +# Node and YARN installation steps taken from https://github.com/nodejs/docker-node/blob/ab5769dc69feb4007d9aafb03316ea0e3edb4227/18/alpine3.19/Dockerfile + +ENV NODE_VERSION {{ node_version }} + +RUN addgroup -g 1000 ${DOCKER_USER} \ + && adduser -u 1000 -G ${DOCKER_USER} -s /bin/sh -D ${DOCKER_USER} \ + && apk add --no-cache \ + libstdc++ \ + && apk add --no-cache --virtual .build-deps \ + curl \ + && ARCH= OPENSSL_ARCH='linux*' && alpineArch="$(apk --print-arch)" \ + && case "${alpineArch##*-}" in \ + x86_64) ARCH='x64' CHECKSUM="{{ node_checksum }}" OPENSSL_ARCH=linux-x86_64;; \ + x86) OPENSSL_ARCH=linux-elf;; \ + aarch64) OPENSSL_ARCH=linux-aarch64;; \ + arm*) OPENSSL_ARCH=linux-armv4;; \ + ppc64le) OPENSSL_ARCH=linux-ppc64le;; \ + s390x) OPENSSL_ARCH=linux-s390x;; \ + *) ;; \ + esac \ + && if [ -n "${CHECKSUM}" ]; then \ + set -eu; \ + curl -fsSLO --compressed "https://unofficial-builds.nodejs.org/download/release/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz"; \ + echo "$CHECKSUM node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" | sha256sum -c - \ + && tar -xJf "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \ + && ln -s /usr/local/bin/node /usr/local/bin/nodejs; \ + else \ + echo "Building from source" \ + # backup build + && apk add --no-cache --virtual .build-deps-full \ + binutils-gold \ + g++ \ + gcc \ + gnupg \ + libgcc \ + linux-headers \ + make \ + python3 \ + # use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150 + && export GNUPGHOME="$(mktemp -d)" \ + # gpg keys listed at https://github.com/nodejs/node#release-keys + && for key in \ + 4ED778F539E3634C779C87C6D7062848A1AB005C \ + 141F07595B7B3FFE74309A937405533BE57C7D57 \ + 74F12602B6F1C4E913FAA37AD3A89613643B6201 \ + DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7 \ + 61FC681DFB92A079F1685E77973F295594EC4689 \ + 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \ + C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ + 890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4 \ + C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \ + 108F52B48DB57BB0CC439B2997B01419BD92F80A \ + A363A499291CBBC940DD62E41F10027AF002F8B0 \ + ; do \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \ + done \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ + && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ + && gpgconf --kill all \ + && rm -rf "$GNUPGHOME" \ + && grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ + && tar -xf "node-v$NODE_VERSION.tar.xz" \ + && cd "node-v$NODE_VERSION" \ + && ./configure \ + && make -j$(getconf _NPROCESSORS_ONLN) V= \ + && make install \ + && apk del .build-deps-full \ + && cd .. \ + && rm -Rf "node-v$NODE_VERSION" \ + && rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt; \ + fi \ + && rm -f "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" \ + # Remove unused OpenSSL headers to save ~34MB. See this NodeJS issue: https://github.com/nodejs/node/issues/46451 + && find /usr/local/include/node/openssl/archs -mindepth 1 -maxdepth 1 ! -name "$OPENSSL_ARCH" -exec rm -rf {} \; \ + && apk del .build-deps \ + # smoke tests + && node --version \ + && npm --version + +ENV YARN_VERSION 1.22.19 + +RUN apk add --no-cache --virtual .build-deps-yarn curl gnupg tar \ + # use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150 + && export GNUPGHOME="$(mktemp -d)" \ + && for key in \ + 6A010C5166006599AA17F08146C2130DFD2497F5 \ + ; do \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \ + done \ + && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ + && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \ + && gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && gpgconf --kill all \ + && rm -rf "$GNUPGHOME" \ + && mkdir -p /opt \ + && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ + && rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && apk del .build-deps-yarn \ + # smoke test + && yarn --version + +RUN apk --no-cache add gettext git htop tree linux-headers libc-dev + +# Install Rust +RUN apk --no-cache add rust rust-wasm cargo +RUN cargo install cargo-wasi --root=/usr/local +RUN chmod 777 /usr/local/bin + +COPY base.makefile Makefile shopify-app.md /assets/ +COPY entrypoint.sh /usr/local/bin/ +ENTRYPOINT ["entrypoint.sh"] diff --git a/shopify/shopify-app.md b/shopify/builder/shopify-app.md similarity index 100% rename from shopify/shopify-app.md rename to shopify/builder/shopify-app.md diff --git a/shopify/Dockerfile b/shopify/n18.19.0/p8.1/Dockerfile similarity index 99% rename from shopify/Dockerfile rename to shopify/n18.19.0/p8.1/Dockerfile index 15b628e..3dd3449 100644 --- a/shopify/Dockerfile +++ b/shopify/n18.19.0/p8.1/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.3-cli-alpine3.17 +FROM php:8.1-cli-alpine3.20 ARG XDEBUG_CLIENT_HOST=host.docker.internal ENV XDEBUG_CLIENT_HOST $XDEBUG_CLIENT_HOST @@ -165,4 +165,4 @@ RUN chmod 777 /usr/local/bin COPY base.makefile Makefile shopify-app.md /assets/ COPY entrypoint.sh /usr/local/bin/ -ENTRYPOINT ["entrypoint.sh"] +ENTRYPOINT ["entrypoint.sh"] \ No newline at end of file diff --git a/shopify/n18.19.0/p8.1/Makefile b/shopify/n18.19.0/p8.1/Makefile new file mode 100644 index 0000000..ef7fbc2 --- /dev/null +++ b/shopify/n18.19.0/p8.1/Makefile @@ -0,0 +1,15 @@ +include base.makefile + +# Add additional targets here or extend(::)/override(:) some, e.g.: + +# New target +#install-my-project: ## description for install-my-project +# @echo project installation steps + +# Extend: Further init directories +#init-directories:: +# @[ -d ~/dir ] || mkdir ~/dir + +# Override: New Node.js installation steps +#install-nodejs: +# @echo install it some other way diff --git a/shopify/n18.19.0/p8.1/base.makefile b/shopify/n18.19.0/p8.1/base.makefile new file mode 100644 index 0000000..3f1b1f4 --- /dev/null +++ b/shopify/n18.19.0/p8.1/base.makefile @@ -0,0 +1,127 @@ +# DON'T MODIFY THIS FILE, IT WILL BE OVERWRITTEN +# use Makefile instead to extend this file + +PROJECT_PATH=$(shell pwd) +RIPTIDE_BIN=$(shell which riptide) +RIPTIDE_SERVICE=shopify +RIPTIDE_SOURCE=/src +APP_NAME=$(shell basename $(CURDIR)) +DOCKER_IMAGE=riptidepy/shopify:latest +DOCKER_USER=docker + +## Make all targets .PHONY +.PHONY: + +## Self documentation +## @see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +## --------------------------------------------------------------------------------------------------------------------- +help:: # Show list of targets with short description (default) + @echo " " + @echo "Passing arguments:" + @echo " " + @echo "make target key1=value1 key2=value2" + @echo " " + @echo List of targets: + @echo " " + @grep -E -ho '[a-zA-Z_-]+::?.*?## ?.*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = "::?.*?##\\s?"}; {}; {printf "\033[36m%-40s\033[0m %s\n", $$1, $$2}' + +## check if variable is set +## use this as pre recipe for targets with arguments +arg-guard-%:: + @#echo "${$*}" + @if [ -z '${${*}}' ]; then $(MAKE); echo; echo 'Variable $* not set'; echo; exit 1; fi + +init-directories:: ## initialize directories + @[ -d ~/.config/shopify ] || mkdir ~/.config/shopify + @[ -d ~/.config/shopify-cli-kit-nodejs ] || mkdir ~/.config/shopify-cli-kit-nodejs + @[ -d ~/.config/shopify-cli-app-nodejs ] || mkdir ~/.config/shopify-cli-app-nodejs + @[ -d ~/.config/shopify-cli-host-theme-conf-nodejs ] || mkdir ~/.config/shopify-cli-host-theme-conf-nodejs + @[ -d ~/.cache/shopify-cli-nodejs ] || mkdir ~/.cache/shopify-cli-nodejs + @[ -d ~/.cache/shopify ] || mkdir ~/.cache/shopify + @[ -d ~/.cache/@shopify ] || mkdir ~/.cache/@shopify + @[ -d ~/.cache/shopify-gems-nodejs ] || mkdir ~/.cache/shopify-gems-nodejs + @[ -d ~/.config/composer ] || mkdir ~/.config/composer + @[ -d ~/.cache/composer ] || mkdir ~/.cache/composer + @[ -d ~/.config/ngrok ] || mkdir ~/.config/ngrok + @[ -d ~/.cache/yarn ] || mkdir ~/.cache/yarn + @[ -d ~/.npm ] || mkdir ~/.npm + +define move-from-subdir-cmd + @export RIPTIDE_DONT_SHOW_EXEC_WARNING=1 && \ + $(RIPTIDE_BIN) start -s $(RIPTIDE_SERVICE) -c keep_running && \ + $(RIPTIDE_BIN) exec --command "rm -rf $(RIPTIDE_SOURCE)/${APP_NAME}/.git" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "bash -c 'for i in \$$(ls -d {"$(RIPTIDE_SOURCE)/${APP_NAME}/"*,"$(RIPTIDE_SOURCE)/${APP_NAME}/".*} | tail -n +3); do rm -rf $(RIPTIDE_SOURCE)/\$${i#$(RIPTIDE_SOURCE)/${APP_NAME}/}; mv \$$i $(RIPTIDE_SOURCE)/; done;'" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "rm -rf \"$(RIPTIDE_SOURCE)/${APP_NAME}\"" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) stop -s $(RIPTIDE_SERVICE) +endef + +create-php: ## newly create app from php template + @$(RIPTIDE_BIN) cmd yarn create @shopify/app --template php --name=${APP_NAME} + $(move-from-subdir-cmd) + +install-php: init-directories ## install dev environment for php + @$(RIPTIDE_BIN) cmd yarn install + @export RIPTIDE_DONT_SHOW_EXEC_WARNING=1 && \ + $(RIPTIDE_BIN) start -s $(RIPTIDE_SERVICE) -c keep_running && \ + $(RIPTIDE_BIN) exec --command "cp $(RIPTIDE_SOURCE)/web/.env.example $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "sed -i \"s/APP_NAME=.*/APP_NAME=${APP_NAME}/\" $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "sed -i 's/DB_DATABASE=.*/DB_DATABASE=\\$(RIPTIDE_SOURCE)\/web\/storage\/db.sqlite/' $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "touch $(RIPTIDE_SOURCE)/web/storage/db.sqlite" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) stop -s $(RIPTIDE_SERVICE) + @$(RIPTIDE_BIN) cmd composer install + @$(RIPTIDE_BIN) cmd artisan key:generate + @$(RIPTIDE_BIN) cmd artisan migrate + +create-nodejs: ## newly create app from nodejs template + @$(RIPTIDE_BIN) cmd yarn create @shopify/app --template node --name=${APP_NAME} + $(move-from-subdir-cmd) + +install-nodejs: ## install dev environment for nodejs + @echo Install root dependencies... + @$(RIPTIDE_BIN) cmd yarn install + @echo Install backend dependencies... + @cd web && $(RIPTIDE_BIN) cmd yarn install + @echo Install frontend dependencies... + @cd web/frontend && $(RIPTIDE_BIN) cmd yarn install + +define dev-container-run-cmd + @docker run --rm -it \ + -u $(DOCKER_USER) \ + --network=host \ + -v ~/.config/composer:/home/$(DOCKER_USER)/.config/composer \ + -v ~/.cache/composer:/home/$(DOCKER_USER)/.cache/composer \ + -v ~/.config/shopify:/home/$(DOCKER_USER)/.config/shopify \ + -v ~/.config/shopify-cli-kit-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-kit-nodejs \ + -v ~/.config/shopify-cli-app-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-app-nodejs \ + -v ~/.config/shopify-cli-host-theme-conf-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-host-theme-conf-nodejs \ + -v ~/.cache/shopify-cli-nodejs:/home/$(DOCKER_USER)/.cache/shopify-cli-nodejs \ + -v ~/.cache/@shopify:/home/$(DOCKER_USER)/.cache/@shopify \ + -v ~/.cache/shopify:/home/$(DOCKER_USER)/.cache/shopify \ + -v ~/.cache/shopify-gems-nodejs:/home/$(DOCKER_USER)/.cache/shopify-gems-nodejs \ + -v ~/.config/ngrok:/home/$(DOCKER_USER)/.config/ngrok \ + -v ~/.cache/yarn:/home/$(DOCKER_USER)/.cache/yarn \ + -v ~/.npm:/home/$(DOCKER_USER)/.npm \ + -v $(shell pwd):$(RIPTIDE_SOURCE) \ + -w $(RIPTIDE_SOURCE) \ + --env-file $(shell pwd)/.env \ + $(DOCKER_IMAGE) +endef + +app-dev: init-directories ## start dev app + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app dev" ||: + +init-app: init-directories ## initialize app + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app dev --reset" ||: + +init-deploy: init-directories ## initialize deploy + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app deploy --reset" ||: + +run-in-container: init-directories ## run command in Shopify container, pass argument command + $(dev-container-run-cmd) $(command) + +## default target +## --------------------------------------------------------------------------------------------------------------------- +.DEFAULT_GOAL:= help diff --git a/shopify/n18.19.0/p8.1/entrypoint.sh b/shopify/n18.19.0/p8.1/entrypoint.sh new file mode 100755 index 0000000..de0bb63 --- /dev/null +++ b/shopify/n18.19.0/p8.1/entrypoint.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +if [ "${XDEBUG#-off}" = "on" ]; then + echo "Setting xdebug.mode 'debug'..." + sed -i 's/xdebug.mode=.*/xdebug.mode=debug/' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +if [ "${XDEBUG_CLIENT_HOST#-host.docker.internal}" != "host.docker.internal" ]; then + echo "Setting xdebug client host '${XDEBUG_CLIENT_HOST}'..." + sed -i "s/xdebug.client_host=.*/xdebug.client_host=${XDEBUG_CLIENT_HOST}/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +set -e + +# Run command with node if the first argument contains a "-" or is not a system command. The last +# part inside the "{}" is a workaround for the following bug in ash/dash: +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264 +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then + echo Prefix with node... + set -- node "$@" +fi + +RIPTIDE_SRC="/src/" +if [ -d "$RIPTIDE_SRC" ]; then + # Keep Makefile and documentation up to date + cp /assets/base.makefile "$RIPTIDE_SRC" + if [ ! -f "$RIPTIDE_SRC""Makefile" ]; then + cp /assets/Makefile "$RIPTIDE_SRC" + fi + if [ ! -f "$RIPTIDE_SRC"".env" ]; then + touch "$RIPTIDE_SRC"".env" + fi + cp /assets/shopify-app.md "$RIPTIDE_SRC" + + # Create app configuration if missing + if [ ! -f "$RIPTIDE_SRC""shopify.app.toml" ] && [ -f "$RIPTIDE_SRC""template.shopify.app.toml" ]; then + cp "$RIPTIDE_SRC""template.shopify.app.toml" "$RIPTIDE_SRC""shopify.app.toml" + fi +fi + +exec "$@" diff --git a/shopify/n18.19.0/p8.1/shopify-app.md b/shopify/n18.19.0/p8.1/shopify-app.md new file mode 100644 index 0000000..ee79e02 --- /dev/null +++ b/shopify/n18.19.0/p8.1/shopify-app.md @@ -0,0 +1,100 @@ +# Shopify App + + +## Setup development environment + +### Setup Riptide project + +```shell +riptide setup +``` + +### Update images + +```shell +riptide update +``` + +Note: Make sure riptide is in your PATH (not just an alias to your bin), so it could be found with `which`. + + +## Create new app + +You can jump to the next step, if you have existing app code. + +### Create new app framework + +For Node.js +```shell +make create-nodejs +``` + +For PHP +```shell +make create-php +``` + + +## Setup existing app + +### Install dependencies + +For Node.js +```shell +make install-nodejs +``` + +For PHP +```shell +make install-php +``` + +### Connect app with Shopify + +```shell +make init-app +``` + +### Connect app extensions with Shopify + +```shell +make init-deploy +``` + + +## Run app + +If you have not installed the Riptide shell extensions, prepend `riptide cmd`. + +```shell +shopify app dev +``` + +If this quits silently after "Dependencies installed", run `shopify auth logout`, `make init-app` and try again. + + +## Deploy extensions + +If you have not installed the Riptide shell extensions, prepend `riptide cmd`. + +```shell +shopify app deploy +``` + + +## Node.js Debugging + +To enable debugging add this to the script section in `web/package.json` (replace with your desired port): + +```json +"debug": "cross-env NODE_ENV=development nodemon --inspect=127.0.0.1: index.js --ignore ./frontend", +``` + +Update the `web/shopify.web.toml` to contain this: + +```toml +[commands] +dev = "npm run debug" +``` + +If you now run `shopify app dev` you could connect your debugging client to the specified port. diff --git a/shopify/n18.19.0/p8.2/Dockerfile b/shopify/n18.19.0/p8.2/Dockerfile new file mode 100644 index 0000000..82b040b --- /dev/null +++ b/shopify/n18.19.0/p8.2/Dockerfile @@ -0,0 +1,168 @@ +FROM php:8.2-cli-alpine3.20 + +ARG XDEBUG_CLIENT_HOST=host.docker.internal +ENV XDEBUG_CLIENT_HOST $XDEBUG_CLIENT_HOST + +ARG DOCKER_USER=docker + +# add run dependencies +RUN apk add --no-cache \ + openrc \ + bash \ + postgresql-libs \ + ruby ruby-dev ruby-ffi libzip-dev \ + alpine-sdk \ + gcompat \ + icu \ + linux-headers \ + freetype libjpeg-turbo libpng libwebp + +# add build dependencies +RUN apk add --no-cache -t .build-deps \ + postgresql-dev \ + libxml2-dev \ + icu-dev \ + freetype-dev libpng-dev libjpeg-turbo-dev libwebp-dev \ + autoconf g++ make && \ +# install bundler for extension deployment + gem install bundler && \ +# configure xdebug + pecl install xdebug-3.3.1 && docker-php-ext-enable xdebug && \ + echo 'xdebug.mode=off' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo "xdebug.client_host=${XDEBUG_CLIENT_HOST}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo 'xdebug.cli_color=1' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo 'xdebug.start_with_request=yes' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ +# further php configuration and permissions + docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql && \ + docker-php-ext-configure simplexml && docker-php-ext-install simplexml && \ + docker-php-ext-configure pgsql && docker-php-ext-install pdo_pgsql && \ + docker-php-ext-configure zip && docker-php-ext-install zip && \ + docker-php-ext-configure intl && docker-php-ext-install intl && \ + docker-php-ext-configure gd --with-jpeg --with-webp --with-freetype && docker-php-ext-install gd && \ + chgrp 1000 /usr/local/etc/php/conf.d/ -R && \ + chmod g+w /usr/local/etc/php/conf.d/ -R && \ +# remove build dependencies + apk del --purge .build-deps + +# install composer +COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer + +# use the default production configuration for PHP +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" + +# Node and YARN installation steps taken from https://github.com/nodejs/docker-node/blob/ab5769dc69feb4007d9aafb03316ea0e3edb4227/18/alpine3.19/Dockerfile + +ENV NODE_VERSION 18.19.0 + +RUN addgroup -g 1000 ${DOCKER_USER} \ + && adduser -u 1000 -G ${DOCKER_USER} -s /bin/sh -D ${DOCKER_USER} \ + && apk add --no-cache \ + libstdc++ \ + && apk add --no-cache --virtual .build-deps \ + curl \ + && ARCH= OPENSSL_ARCH='linux*' && alpineArch="$(apk --print-arch)" \ + && case "${alpineArch##*-}" in \ + x86_64) ARCH='x64' CHECKSUM="10b7b23b6b867a25f060a433b83f5c3ecb3bcf7cdba1c0ce46443065a832fd41" OPENSSL_ARCH=linux-x86_64;; \ + x86) OPENSSL_ARCH=linux-elf;; \ + aarch64) OPENSSL_ARCH=linux-aarch64;; \ + arm*) OPENSSL_ARCH=linux-armv4;; \ + ppc64le) OPENSSL_ARCH=linux-ppc64le;; \ + s390x) OPENSSL_ARCH=linux-s390x;; \ + *) ;; \ + esac \ + && if [ -n "${CHECKSUM}" ]; then \ + set -eu; \ + curl -fsSLO --compressed "https://unofficial-builds.nodejs.org/download/release/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz"; \ + echo "$CHECKSUM node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" | sha256sum -c - \ + && tar -xJf "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \ + && ln -s /usr/local/bin/node /usr/local/bin/nodejs; \ + else \ + echo "Building from source" \ + # backup build + && apk add --no-cache --virtual .build-deps-full \ + binutils-gold \ + g++ \ + gcc \ + gnupg \ + libgcc \ + linux-headers \ + make \ + python3 \ + # use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150 + && export GNUPGHOME="$(mktemp -d)" \ + # gpg keys listed at https://github.com/nodejs/node#release-keys + && for key in \ + 4ED778F539E3634C779C87C6D7062848A1AB005C \ + 141F07595B7B3FFE74309A937405533BE57C7D57 \ + 74F12602B6F1C4E913FAA37AD3A89613643B6201 \ + DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7 \ + 61FC681DFB92A079F1685E77973F295594EC4689 \ + 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \ + C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ + 890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4 \ + C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \ + 108F52B48DB57BB0CC439B2997B01419BD92F80A \ + A363A499291CBBC940DD62E41F10027AF002F8B0 \ + ; do \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \ + done \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ + && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ + && gpgconf --kill all \ + && rm -rf "$GNUPGHOME" \ + && grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ + && tar -xf "node-v$NODE_VERSION.tar.xz" \ + && cd "node-v$NODE_VERSION" \ + && ./configure \ + && make -j$(getconf _NPROCESSORS_ONLN) V= \ + && make install \ + && apk del .build-deps-full \ + && cd .. \ + && rm -Rf "node-v$NODE_VERSION" \ + && rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt; \ + fi \ + && rm -f "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" \ + # Remove unused OpenSSL headers to save ~34MB. See this NodeJS issue: https://github.com/nodejs/node/issues/46451 + && find /usr/local/include/node/openssl/archs -mindepth 1 -maxdepth 1 ! -name "$OPENSSL_ARCH" -exec rm -rf {} \; \ + && apk del .build-deps \ + # smoke tests + && node --version \ + && npm --version + +ENV YARN_VERSION 1.22.19 + +RUN apk add --no-cache --virtual .build-deps-yarn curl gnupg tar \ + # use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150 + && export GNUPGHOME="$(mktemp -d)" \ + && for key in \ + 6A010C5166006599AA17F08146C2130DFD2497F5 \ + ; do \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \ + done \ + && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ + && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \ + && gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && gpgconf --kill all \ + && rm -rf "$GNUPGHOME" \ + && mkdir -p /opt \ + && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ + && rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && apk del .build-deps-yarn \ + # smoke test + && yarn --version + +RUN apk --no-cache add gettext git htop tree linux-headers libc-dev + +# Install Rust +RUN apk --no-cache add rust rust-wasm cargo +RUN cargo install cargo-wasi --root=/usr/local +RUN chmod 777 /usr/local/bin + +COPY base.makefile Makefile shopify-app.md /assets/ +COPY entrypoint.sh /usr/local/bin/ +ENTRYPOINT ["entrypoint.sh"] \ No newline at end of file diff --git a/shopify/n18.19.0/p8.2/Makefile b/shopify/n18.19.0/p8.2/Makefile new file mode 100644 index 0000000..ef7fbc2 --- /dev/null +++ b/shopify/n18.19.0/p8.2/Makefile @@ -0,0 +1,15 @@ +include base.makefile + +# Add additional targets here or extend(::)/override(:) some, e.g.: + +# New target +#install-my-project: ## description for install-my-project +# @echo project installation steps + +# Extend: Further init directories +#init-directories:: +# @[ -d ~/dir ] || mkdir ~/dir + +# Override: New Node.js installation steps +#install-nodejs: +# @echo install it some other way diff --git a/shopify/n18.19.0/p8.2/base.makefile b/shopify/n18.19.0/p8.2/base.makefile new file mode 100644 index 0000000..3f1b1f4 --- /dev/null +++ b/shopify/n18.19.0/p8.2/base.makefile @@ -0,0 +1,127 @@ +# DON'T MODIFY THIS FILE, IT WILL BE OVERWRITTEN +# use Makefile instead to extend this file + +PROJECT_PATH=$(shell pwd) +RIPTIDE_BIN=$(shell which riptide) +RIPTIDE_SERVICE=shopify +RIPTIDE_SOURCE=/src +APP_NAME=$(shell basename $(CURDIR)) +DOCKER_IMAGE=riptidepy/shopify:latest +DOCKER_USER=docker + +## Make all targets .PHONY +.PHONY: + +## Self documentation +## @see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +## --------------------------------------------------------------------------------------------------------------------- +help:: # Show list of targets with short description (default) + @echo " " + @echo "Passing arguments:" + @echo " " + @echo "make target key1=value1 key2=value2" + @echo " " + @echo List of targets: + @echo " " + @grep -E -ho '[a-zA-Z_-]+::?.*?## ?.*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = "::?.*?##\\s?"}; {}; {printf "\033[36m%-40s\033[0m %s\n", $$1, $$2}' + +## check if variable is set +## use this as pre recipe for targets with arguments +arg-guard-%:: + @#echo "${$*}" + @if [ -z '${${*}}' ]; then $(MAKE); echo; echo 'Variable $* not set'; echo; exit 1; fi + +init-directories:: ## initialize directories + @[ -d ~/.config/shopify ] || mkdir ~/.config/shopify + @[ -d ~/.config/shopify-cli-kit-nodejs ] || mkdir ~/.config/shopify-cli-kit-nodejs + @[ -d ~/.config/shopify-cli-app-nodejs ] || mkdir ~/.config/shopify-cli-app-nodejs + @[ -d ~/.config/shopify-cli-host-theme-conf-nodejs ] || mkdir ~/.config/shopify-cli-host-theme-conf-nodejs + @[ -d ~/.cache/shopify-cli-nodejs ] || mkdir ~/.cache/shopify-cli-nodejs + @[ -d ~/.cache/shopify ] || mkdir ~/.cache/shopify + @[ -d ~/.cache/@shopify ] || mkdir ~/.cache/@shopify + @[ -d ~/.cache/shopify-gems-nodejs ] || mkdir ~/.cache/shopify-gems-nodejs + @[ -d ~/.config/composer ] || mkdir ~/.config/composer + @[ -d ~/.cache/composer ] || mkdir ~/.cache/composer + @[ -d ~/.config/ngrok ] || mkdir ~/.config/ngrok + @[ -d ~/.cache/yarn ] || mkdir ~/.cache/yarn + @[ -d ~/.npm ] || mkdir ~/.npm + +define move-from-subdir-cmd + @export RIPTIDE_DONT_SHOW_EXEC_WARNING=1 && \ + $(RIPTIDE_BIN) start -s $(RIPTIDE_SERVICE) -c keep_running && \ + $(RIPTIDE_BIN) exec --command "rm -rf $(RIPTIDE_SOURCE)/${APP_NAME}/.git" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "bash -c 'for i in \$$(ls -d {"$(RIPTIDE_SOURCE)/${APP_NAME}/"*,"$(RIPTIDE_SOURCE)/${APP_NAME}/".*} | tail -n +3); do rm -rf $(RIPTIDE_SOURCE)/\$${i#$(RIPTIDE_SOURCE)/${APP_NAME}/}; mv \$$i $(RIPTIDE_SOURCE)/; done;'" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "rm -rf \"$(RIPTIDE_SOURCE)/${APP_NAME}\"" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) stop -s $(RIPTIDE_SERVICE) +endef + +create-php: ## newly create app from php template + @$(RIPTIDE_BIN) cmd yarn create @shopify/app --template php --name=${APP_NAME} + $(move-from-subdir-cmd) + +install-php: init-directories ## install dev environment for php + @$(RIPTIDE_BIN) cmd yarn install + @export RIPTIDE_DONT_SHOW_EXEC_WARNING=1 && \ + $(RIPTIDE_BIN) start -s $(RIPTIDE_SERVICE) -c keep_running && \ + $(RIPTIDE_BIN) exec --command "cp $(RIPTIDE_SOURCE)/web/.env.example $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "sed -i \"s/APP_NAME=.*/APP_NAME=${APP_NAME}/\" $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "sed -i 's/DB_DATABASE=.*/DB_DATABASE=\\$(RIPTIDE_SOURCE)\/web\/storage\/db.sqlite/' $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "touch $(RIPTIDE_SOURCE)/web/storage/db.sqlite" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) stop -s $(RIPTIDE_SERVICE) + @$(RIPTIDE_BIN) cmd composer install + @$(RIPTIDE_BIN) cmd artisan key:generate + @$(RIPTIDE_BIN) cmd artisan migrate + +create-nodejs: ## newly create app from nodejs template + @$(RIPTIDE_BIN) cmd yarn create @shopify/app --template node --name=${APP_NAME} + $(move-from-subdir-cmd) + +install-nodejs: ## install dev environment for nodejs + @echo Install root dependencies... + @$(RIPTIDE_BIN) cmd yarn install + @echo Install backend dependencies... + @cd web && $(RIPTIDE_BIN) cmd yarn install + @echo Install frontend dependencies... + @cd web/frontend && $(RIPTIDE_BIN) cmd yarn install + +define dev-container-run-cmd + @docker run --rm -it \ + -u $(DOCKER_USER) \ + --network=host \ + -v ~/.config/composer:/home/$(DOCKER_USER)/.config/composer \ + -v ~/.cache/composer:/home/$(DOCKER_USER)/.cache/composer \ + -v ~/.config/shopify:/home/$(DOCKER_USER)/.config/shopify \ + -v ~/.config/shopify-cli-kit-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-kit-nodejs \ + -v ~/.config/shopify-cli-app-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-app-nodejs \ + -v ~/.config/shopify-cli-host-theme-conf-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-host-theme-conf-nodejs \ + -v ~/.cache/shopify-cli-nodejs:/home/$(DOCKER_USER)/.cache/shopify-cli-nodejs \ + -v ~/.cache/@shopify:/home/$(DOCKER_USER)/.cache/@shopify \ + -v ~/.cache/shopify:/home/$(DOCKER_USER)/.cache/shopify \ + -v ~/.cache/shopify-gems-nodejs:/home/$(DOCKER_USER)/.cache/shopify-gems-nodejs \ + -v ~/.config/ngrok:/home/$(DOCKER_USER)/.config/ngrok \ + -v ~/.cache/yarn:/home/$(DOCKER_USER)/.cache/yarn \ + -v ~/.npm:/home/$(DOCKER_USER)/.npm \ + -v $(shell pwd):$(RIPTIDE_SOURCE) \ + -w $(RIPTIDE_SOURCE) \ + --env-file $(shell pwd)/.env \ + $(DOCKER_IMAGE) +endef + +app-dev: init-directories ## start dev app + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app dev" ||: + +init-app: init-directories ## initialize app + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app dev --reset" ||: + +init-deploy: init-directories ## initialize deploy + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app deploy --reset" ||: + +run-in-container: init-directories ## run command in Shopify container, pass argument command + $(dev-container-run-cmd) $(command) + +## default target +## --------------------------------------------------------------------------------------------------------------------- +.DEFAULT_GOAL:= help diff --git a/shopify/n18.19.0/p8.2/entrypoint.sh b/shopify/n18.19.0/p8.2/entrypoint.sh new file mode 100755 index 0000000..de0bb63 --- /dev/null +++ b/shopify/n18.19.0/p8.2/entrypoint.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +if [ "${XDEBUG#-off}" = "on" ]; then + echo "Setting xdebug.mode 'debug'..." + sed -i 's/xdebug.mode=.*/xdebug.mode=debug/' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +if [ "${XDEBUG_CLIENT_HOST#-host.docker.internal}" != "host.docker.internal" ]; then + echo "Setting xdebug client host '${XDEBUG_CLIENT_HOST}'..." + sed -i "s/xdebug.client_host=.*/xdebug.client_host=${XDEBUG_CLIENT_HOST}/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +set -e + +# Run command with node if the first argument contains a "-" or is not a system command. The last +# part inside the "{}" is a workaround for the following bug in ash/dash: +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264 +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then + echo Prefix with node... + set -- node "$@" +fi + +RIPTIDE_SRC="/src/" +if [ -d "$RIPTIDE_SRC" ]; then + # Keep Makefile and documentation up to date + cp /assets/base.makefile "$RIPTIDE_SRC" + if [ ! -f "$RIPTIDE_SRC""Makefile" ]; then + cp /assets/Makefile "$RIPTIDE_SRC" + fi + if [ ! -f "$RIPTIDE_SRC"".env" ]; then + touch "$RIPTIDE_SRC"".env" + fi + cp /assets/shopify-app.md "$RIPTIDE_SRC" + + # Create app configuration if missing + if [ ! -f "$RIPTIDE_SRC""shopify.app.toml" ] && [ -f "$RIPTIDE_SRC""template.shopify.app.toml" ]; then + cp "$RIPTIDE_SRC""template.shopify.app.toml" "$RIPTIDE_SRC""shopify.app.toml" + fi +fi + +exec "$@" diff --git a/shopify/n18.19.0/p8.2/shopify-app.md b/shopify/n18.19.0/p8.2/shopify-app.md new file mode 100644 index 0000000..ee79e02 --- /dev/null +++ b/shopify/n18.19.0/p8.2/shopify-app.md @@ -0,0 +1,100 @@ +# Shopify App + + +## Setup development environment + +### Setup Riptide project + +```shell +riptide setup +``` + +### Update images + +```shell +riptide update +``` + +Note: Make sure riptide is in your PATH (not just an alias to your bin), so it could be found with `which`. + + +## Create new app + +You can jump to the next step, if you have existing app code. + +### Create new app framework + +For Node.js +```shell +make create-nodejs +``` + +For PHP +```shell +make create-php +``` + + +## Setup existing app + +### Install dependencies + +For Node.js +```shell +make install-nodejs +``` + +For PHP +```shell +make install-php +``` + +### Connect app with Shopify + +```shell +make init-app +``` + +### Connect app extensions with Shopify + +```shell +make init-deploy +``` + + +## Run app + +If you have not installed the Riptide shell extensions, prepend `riptide cmd`. + +```shell +shopify app dev +``` + +If this quits silently after "Dependencies installed", run `shopify auth logout`, `make init-app` and try again. + + +## Deploy extensions + +If you have not installed the Riptide shell extensions, prepend `riptide cmd`. + +```shell +shopify app deploy +``` + + +## Node.js Debugging + +To enable debugging add this to the script section in `web/package.json` (replace with your desired port): + +```json +"debug": "cross-env NODE_ENV=development nodemon --inspect=127.0.0.1: index.js --ignore ./frontend", +``` + +Update the `web/shopify.web.toml` to contain this: + +```toml +[commands] +dev = "npm run debug" +``` + +If you now run `shopify app dev` you could connect your debugging client to the specified port. diff --git a/shopify/n18.19.0/p8.3/Dockerfile b/shopify/n18.19.0/p8.3/Dockerfile new file mode 100644 index 0000000..c8ffbc9 --- /dev/null +++ b/shopify/n18.19.0/p8.3/Dockerfile @@ -0,0 +1,168 @@ +FROM php:8.3-cli-alpine3.20 + +ARG XDEBUG_CLIENT_HOST=host.docker.internal +ENV XDEBUG_CLIENT_HOST $XDEBUG_CLIENT_HOST + +ARG DOCKER_USER=docker + +# add run dependencies +RUN apk add --no-cache \ + openrc \ + bash \ + postgresql-libs \ + ruby ruby-dev ruby-ffi libzip-dev \ + alpine-sdk \ + gcompat \ + icu \ + linux-headers \ + freetype libjpeg-turbo libpng libwebp + +# add build dependencies +RUN apk add --no-cache -t .build-deps \ + postgresql-dev \ + libxml2-dev \ + icu-dev \ + freetype-dev libpng-dev libjpeg-turbo-dev libwebp-dev \ + autoconf g++ make && \ +# install bundler for extension deployment + gem install bundler && \ +# configure xdebug + pecl install xdebug-3.3.1 && docker-php-ext-enable xdebug && \ + echo 'xdebug.mode=off' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo "xdebug.client_host=${XDEBUG_CLIENT_HOST}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo 'xdebug.cli_color=1' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo 'xdebug.start_with_request=yes' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ +# further php configuration and permissions + docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql && \ + docker-php-ext-configure simplexml && docker-php-ext-install simplexml && \ + docker-php-ext-configure pgsql && docker-php-ext-install pdo_pgsql && \ + docker-php-ext-configure zip && docker-php-ext-install zip && \ + docker-php-ext-configure intl && docker-php-ext-install intl && \ + docker-php-ext-configure gd --with-jpeg --with-webp --with-freetype && docker-php-ext-install gd && \ + chgrp 1000 /usr/local/etc/php/conf.d/ -R && \ + chmod g+w /usr/local/etc/php/conf.d/ -R && \ +# remove build dependencies + apk del --purge .build-deps + +# install composer +COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer + +# use the default production configuration for PHP +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" + +# Node and YARN installation steps taken from https://github.com/nodejs/docker-node/blob/ab5769dc69feb4007d9aafb03316ea0e3edb4227/18/alpine3.19/Dockerfile + +ENV NODE_VERSION 18.19.0 + +RUN addgroup -g 1000 ${DOCKER_USER} \ + && adduser -u 1000 -G ${DOCKER_USER} -s /bin/sh -D ${DOCKER_USER} \ + && apk add --no-cache \ + libstdc++ \ + && apk add --no-cache --virtual .build-deps \ + curl \ + && ARCH= OPENSSL_ARCH='linux*' && alpineArch="$(apk --print-arch)" \ + && case "${alpineArch##*-}" in \ + x86_64) ARCH='x64' CHECKSUM="10b7b23b6b867a25f060a433b83f5c3ecb3bcf7cdba1c0ce46443065a832fd41" OPENSSL_ARCH=linux-x86_64;; \ + x86) OPENSSL_ARCH=linux-elf;; \ + aarch64) OPENSSL_ARCH=linux-aarch64;; \ + arm*) OPENSSL_ARCH=linux-armv4;; \ + ppc64le) OPENSSL_ARCH=linux-ppc64le;; \ + s390x) OPENSSL_ARCH=linux-s390x;; \ + *) ;; \ + esac \ + && if [ -n "${CHECKSUM}" ]; then \ + set -eu; \ + curl -fsSLO --compressed "https://unofficial-builds.nodejs.org/download/release/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz"; \ + echo "$CHECKSUM node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" | sha256sum -c - \ + && tar -xJf "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \ + && ln -s /usr/local/bin/node /usr/local/bin/nodejs; \ + else \ + echo "Building from source" \ + # backup build + && apk add --no-cache --virtual .build-deps-full \ + binutils-gold \ + g++ \ + gcc \ + gnupg \ + libgcc \ + linux-headers \ + make \ + python3 \ + # use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150 + && export GNUPGHOME="$(mktemp -d)" \ + # gpg keys listed at https://github.com/nodejs/node#release-keys + && for key in \ + 4ED778F539E3634C779C87C6D7062848A1AB005C \ + 141F07595B7B3FFE74309A937405533BE57C7D57 \ + 74F12602B6F1C4E913FAA37AD3A89613643B6201 \ + DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7 \ + 61FC681DFB92A079F1685E77973F295594EC4689 \ + 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \ + C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ + 890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4 \ + C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \ + 108F52B48DB57BB0CC439B2997B01419BD92F80A \ + A363A499291CBBC940DD62E41F10027AF002F8B0 \ + ; do \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \ + done \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ + && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ + && gpgconf --kill all \ + && rm -rf "$GNUPGHOME" \ + && grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ + && tar -xf "node-v$NODE_VERSION.tar.xz" \ + && cd "node-v$NODE_VERSION" \ + && ./configure \ + && make -j$(getconf _NPROCESSORS_ONLN) V= \ + && make install \ + && apk del .build-deps-full \ + && cd .. \ + && rm -Rf "node-v$NODE_VERSION" \ + && rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt; \ + fi \ + && rm -f "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" \ + # Remove unused OpenSSL headers to save ~34MB. See this NodeJS issue: https://github.com/nodejs/node/issues/46451 + && find /usr/local/include/node/openssl/archs -mindepth 1 -maxdepth 1 ! -name "$OPENSSL_ARCH" -exec rm -rf {} \; \ + && apk del .build-deps \ + # smoke tests + && node --version \ + && npm --version + +ENV YARN_VERSION 1.22.19 + +RUN apk add --no-cache --virtual .build-deps-yarn curl gnupg tar \ + # use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150 + && export GNUPGHOME="$(mktemp -d)" \ + && for key in \ + 6A010C5166006599AA17F08146C2130DFD2497F5 \ + ; do \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \ + done \ + && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ + && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \ + && gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && gpgconf --kill all \ + && rm -rf "$GNUPGHOME" \ + && mkdir -p /opt \ + && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ + && rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && apk del .build-deps-yarn \ + # smoke test + && yarn --version + +RUN apk --no-cache add gettext git htop tree linux-headers libc-dev + +# Install Rust +RUN apk --no-cache add rust rust-wasm cargo +RUN cargo install cargo-wasi --root=/usr/local +RUN chmod 777 /usr/local/bin + +COPY base.makefile Makefile shopify-app.md /assets/ +COPY entrypoint.sh /usr/local/bin/ +ENTRYPOINT ["entrypoint.sh"] \ No newline at end of file diff --git a/shopify/n18.19.0/p8.3/Makefile b/shopify/n18.19.0/p8.3/Makefile new file mode 100644 index 0000000..ef7fbc2 --- /dev/null +++ b/shopify/n18.19.0/p8.3/Makefile @@ -0,0 +1,15 @@ +include base.makefile + +# Add additional targets here or extend(::)/override(:) some, e.g.: + +# New target +#install-my-project: ## description for install-my-project +# @echo project installation steps + +# Extend: Further init directories +#init-directories:: +# @[ -d ~/dir ] || mkdir ~/dir + +# Override: New Node.js installation steps +#install-nodejs: +# @echo install it some other way diff --git a/shopify/n18.19.0/p8.3/base.makefile b/shopify/n18.19.0/p8.3/base.makefile new file mode 100644 index 0000000..3f1b1f4 --- /dev/null +++ b/shopify/n18.19.0/p8.3/base.makefile @@ -0,0 +1,127 @@ +# DON'T MODIFY THIS FILE, IT WILL BE OVERWRITTEN +# use Makefile instead to extend this file + +PROJECT_PATH=$(shell pwd) +RIPTIDE_BIN=$(shell which riptide) +RIPTIDE_SERVICE=shopify +RIPTIDE_SOURCE=/src +APP_NAME=$(shell basename $(CURDIR)) +DOCKER_IMAGE=riptidepy/shopify:latest +DOCKER_USER=docker + +## Make all targets .PHONY +.PHONY: + +## Self documentation +## @see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +## --------------------------------------------------------------------------------------------------------------------- +help:: # Show list of targets with short description (default) + @echo " " + @echo "Passing arguments:" + @echo " " + @echo "make target key1=value1 key2=value2" + @echo " " + @echo List of targets: + @echo " " + @grep -E -ho '[a-zA-Z_-]+::?.*?## ?.*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = "::?.*?##\\s?"}; {}; {printf "\033[36m%-40s\033[0m %s\n", $$1, $$2}' + +## check if variable is set +## use this as pre recipe for targets with arguments +arg-guard-%:: + @#echo "${$*}" + @if [ -z '${${*}}' ]; then $(MAKE); echo; echo 'Variable $* not set'; echo; exit 1; fi + +init-directories:: ## initialize directories + @[ -d ~/.config/shopify ] || mkdir ~/.config/shopify + @[ -d ~/.config/shopify-cli-kit-nodejs ] || mkdir ~/.config/shopify-cli-kit-nodejs + @[ -d ~/.config/shopify-cli-app-nodejs ] || mkdir ~/.config/shopify-cli-app-nodejs + @[ -d ~/.config/shopify-cli-host-theme-conf-nodejs ] || mkdir ~/.config/shopify-cli-host-theme-conf-nodejs + @[ -d ~/.cache/shopify-cli-nodejs ] || mkdir ~/.cache/shopify-cli-nodejs + @[ -d ~/.cache/shopify ] || mkdir ~/.cache/shopify + @[ -d ~/.cache/@shopify ] || mkdir ~/.cache/@shopify + @[ -d ~/.cache/shopify-gems-nodejs ] || mkdir ~/.cache/shopify-gems-nodejs + @[ -d ~/.config/composer ] || mkdir ~/.config/composer + @[ -d ~/.cache/composer ] || mkdir ~/.cache/composer + @[ -d ~/.config/ngrok ] || mkdir ~/.config/ngrok + @[ -d ~/.cache/yarn ] || mkdir ~/.cache/yarn + @[ -d ~/.npm ] || mkdir ~/.npm + +define move-from-subdir-cmd + @export RIPTIDE_DONT_SHOW_EXEC_WARNING=1 && \ + $(RIPTIDE_BIN) start -s $(RIPTIDE_SERVICE) -c keep_running && \ + $(RIPTIDE_BIN) exec --command "rm -rf $(RIPTIDE_SOURCE)/${APP_NAME}/.git" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "bash -c 'for i in \$$(ls -d {"$(RIPTIDE_SOURCE)/${APP_NAME}/"*,"$(RIPTIDE_SOURCE)/${APP_NAME}/".*} | tail -n +3); do rm -rf $(RIPTIDE_SOURCE)/\$${i#$(RIPTIDE_SOURCE)/${APP_NAME}/}; mv \$$i $(RIPTIDE_SOURCE)/; done;'" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "rm -rf \"$(RIPTIDE_SOURCE)/${APP_NAME}\"" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) stop -s $(RIPTIDE_SERVICE) +endef + +create-php: ## newly create app from php template + @$(RIPTIDE_BIN) cmd yarn create @shopify/app --template php --name=${APP_NAME} + $(move-from-subdir-cmd) + +install-php: init-directories ## install dev environment for php + @$(RIPTIDE_BIN) cmd yarn install + @export RIPTIDE_DONT_SHOW_EXEC_WARNING=1 && \ + $(RIPTIDE_BIN) start -s $(RIPTIDE_SERVICE) -c keep_running && \ + $(RIPTIDE_BIN) exec --command "cp $(RIPTIDE_SOURCE)/web/.env.example $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "sed -i \"s/APP_NAME=.*/APP_NAME=${APP_NAME}/\" $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "sed -i 's/DB_DATABASE=.*/DB_DATABASE=\\$(RIPTIDE_SOURCE)\/web\/storage\/db.sqlite/' $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "touch $(RIPTIDE_SOURCE)/web/storage/db.sqlite" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) stop -s $(RIPTIDE_SERVICE) + @$(RIPTIDE_BIN) cmd composer install + @$(RIPTIDE_BIN) cmd artisan key:generate + @$(RIPTIDE_BIN) cmd artisan migrate + +create-nodejs: ## newly create app from nodejs template + @$(RIPTIDE_BIN) cmd yarn create @shopify/app --template node --name=${APP_NAME} + $(move-from-subdir-cmd) + +install-nodejs: ## install dev environment for nodejs + @echo Install root dependencies... + @$(RIPTIDE_BIN) cmd yarn install + @echo Install backend dependencies... + @cd web && $(RIPTIDE_BIN) cmd yarn install + @echo Install frontend dependencies... + @cd web/frontend && $(RIPTIDE_BIN) cmd yarn install + +define dev-container-run-cmd + @docker run --rm -it \ + -u $(DOCKER_USER) \ + --network=host \ + -v ~/.config/composer:/home/$(DOCKER_USER)/.config/composer \ + -v ~/.cache/composer:/home/$(DOCKER_USER)/.cache/composer \ + -v ~/.config/shopify:/home/$(DOCKER_USER)/.config/shopify \ + -v ~/.config/shopify-cli-kit-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-kit-nodejs \ + -v ~/.config/shopify-cli-app-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-app-nodejs \ + -v ~/.config/shopify-cli-host-theme-conf-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-host-theme-conf-nodejs \ + -v ~/.cache/shopify-cli-nodejs:/home/$(DOCKER_USER)/.cache/shopify-cli-nodejs \ + -v ~/.cache/@shopify:/home/$(DOCKER_USER)/.cache/@shopify \ + -v ~/.cache/shopify:/home/$(DOCKER_USER)/.cache/shopify \ + -v ~/.cache/shopify-gems-nodejs:/home/$(DOCKER_USER)/.cache/shopify-gems-nodejs \ + -v ~/.config/ngrok:/home/$(DOCKER_USER)/.config/ngrok \ + -v ~/.cache/yarn:/home/$(DOCKER_USER)/.cache/yarn \ + -v ~/.npm:/home/$(DOCKER_USER)/.npm \ + -v $(shell pwd):$(RIPTIDE_SOURCE) \ + -w $(RIPTIDE_SOURCE) \ + --env-file $(shell pwd)/.env \ + $(DOCKER_IMAGE) +endef + +app-dev: init-directories ## start dev app + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app dev" ||: + +init-app: init-directories ## initialize app + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app dev --reset" ||: + +init-deploy: init-directories ## initialize deploy + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app deploy --reset" ||: + +run-in-container: init-directories ## run command in Shopify container, pass argument command + $(dev-container-run-cmd) $(command) + +## default target +## --------------------------------------------------------------------------------------------------------------------- +.DEFAULT_GOAL:= help diff --git a/shopify/n18.19.0/p8.3/entrypoint.sh b/shopify/n18.19.0/p8.3/entrypoint.sh new file mode 100755 index 0000000..de0bb63 --- /dev/null +++ b/shopify/n18.19.0/p8.3/entrypoint.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +if [ "${XDEBUG#-off}" = "on" ]; then + echo "Setting xdebug.mode 'debug'..." + sed -i 's/xdebug.mode=.*/xdebug.mode=debug/' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +if [ "${XDEBUG_CLIENT_HOST#-host.docker.internal}" != "host.docker.internal" ]; then + echo "Setting xdebug client host '${XDEBUG_CLIENT_HOST}'..." + sed -i "s/xdebug.client_host=.*/xdebug.client_host=${XDEBUG_CLIENT_HOST}/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +set -e + +# Run command with node if the first argument contains a "-" or is not a system command. The last +# part inside the "{}" is a workaround for the following bug in ash/dash: +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264 +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then + echo Prefix with node... + set -- node "$@" +fi + +RIPTIDE_SRC="/src/" +if [ -d "$RIPTIDE_SRC" ]; then + # Keep Makefile and documentation up to date + cp /assets/base.makefile "$RIPTIDE_SRC" + if [ ! -f "$RIPTIDE_SRC""Makefile" ]; then + cp /assets/Makefile "$RIPTIDE_SRC" + fi + if [ ! -f "$RIPTIDE_SRC"".env" ]; then + touch "$RIPTIDE_SRC"".env" + fi + cp /assets/shopify-app.md "$RIPTIDE_SRC" + + # Create app configuration if missing + if [ ! -f "$RIPTIDE_SRC""shopify.app.toml" ] && [ -f "$RIPTIDE_SRC""template.shopify.app.toml" ]; then + cp "$RIPTIDE_SRC""template.shopify.app.toml" "$RIPTIDE_SRC""shopify.app.toml" + fi +fi + +exec "$@" diff --git a/shopify/n18.19.0/p8.3/shopify-app.md b/shopify/n18.19.0/p8.3/shopify-app.md new file mode 100644 index 0000000..ee79e02 --- /dev/null +++ b/shopify/n18.19.0/p8.3/shopify-app.md @@ -0,0 +1,100 @@ +# Shopify App + + +## Setup development environment + +### Setup Riptide project + +```shell +riptide setup +``` + +### Update images + +```shell +riptide update +``` + +Note: Make sure riptide is in your PATH (not just an alias to your bin), so it could be found with `which`. + + +## Create new app + +You can jump to the next step, if you have existing app code. + +### Create new app framework + +For Node.js +```shell +make create-nodejs +``` + +For PHP +```shell +make create-php +``` + + +## Setup existing app + +### Install dependencies + +For Node.js +```shell +make install-nodejs +``` + +For PHP +```shell +make install-php +``` + +### Connect app with Shopify + +```shell +make init-app +``` + +### Connect app extensions with Shopify + +```shell +make init-deploy +``` + + +## Run app + +If you have not installed the Riptide shell extensions, prepend `riptide cmd`. + +```shell +shopify app dev +``` + +If this quits silently after "Dependencies installed", run `shopify auth logout`, `make init-app` and try again. + + +## Deploy extensions + +If you have not installed the Riptide shell extensions, prepend `riptide cmd`. + +```shell +shopify app deploy +``` + + +## Node.js Debugging + +To enable debugging add this to the script section in `web/package.json` (replace with your desired port): + +```json +"debug": "cross-env NODE_ENV=development nodemon --inspect=127.0.0.1: index.js --ignore ./frontend", +``` + +Update the `web/shopify.web.toml` to contain this: + +```toml +[commands] +dev = "npm run debug" +``` + +If you now run `shopify app dev` you could connect your debugging client to the specified port. diff --git a/shopify/n20.11.0/p8.1/Dockerfile b/shopify/n20.11.0/p8.1/Dockerfile new file mode 100644 index 0000000..aa0b6cc --- /dev/null +++ b/shopify/n20.11.0/p8.1/Dockerfile @@ -0,0 +1,168 @@ +FROM php:8.1-cli-alpine3.20 + +ARG XDEBUG_CLIENT_HOST=host.docker.internal +ENV XDEBUG_CLIENT_HOST $XDEBUG_CLIENT_HOST + +ARG DOCKER_USER=docker + +# add run dependencies +RUN apk add --no-cache \ + openrc \ + bash \ + postgresql-libs \ + ruby ruby-dev ruby-ffi libzip-dev \ + alpine-sdk \ + gcompat \ + icu \ + linux-headers \ + freetype libjpeg-turbo libpng libwebp + +# add build dependencies +RUN apk add --no-cache -t .build-deps \ + postgresql-dev \ + libxml2-dev \ + icu-dev \ + freetype-dev libpng-dev libjpeg-turbo-dev libwebp-dev \ + autoconf g++ make && \ +# install bundler for extension deployment + gem install bundler && \ +# configure xdebug + pecl install xdebug-3.3.1 && docker-php-ext-enable xdebug && \ + echo 'xdebug.mode=off' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo "xdebug.client_host=${XDEBUG_CLIENT_HOST}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo 'xdebug.cli_color=1' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo 'xdebug.start_with_request=yes' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ +# further php configuration and permissions + docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql && \ + docker-php-ext-configure simplexml && docker-php-ext-install simplexml && \ + docker-php-ext-configure pgsql && docker-php-ext-install pdo_pgsql && \ + docker-php-ext-configure zip && docker-php-ext-install zip && \ + docker-php-ext-configure intl && docker-php-ext-install intl && \ + docker-php-ext-configure gd --with-jpeg --with-webp --with-freetype && docker-php-ext-install gd && \ + chgrp 1000 /usr/local/etc/php/conf.d/ -R && \ + chmod g+w /usr/local/etc/php/conf.d/ -R && \ +# remove build dependencies + apk del --purge .build-deps + +# install composer +COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer + +# use the default production configuration for PHP +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" + +# Node and YARN installation steps taken from https://github.com/nodejs/docker-node/blob/ab5769dc69feb4007d9aafb03316ea0e3edb4227/18/alpine3.19/Dockerfile + +ENV NODE_VERSION 20.11.0 + +RUN addgroup -g 1000 ${DOCKER_USER} \ + && adduser -u 1000 -G ${DOCKER_USER} -s /bin/sh -D ${DOCKER_USER} \ + && apk add --no-cache \ + libstdc++ \ + && apk add --no-cache --virtual .build-deps \ + curl \ + && ARCH= OPENSSL_ARCH='linux*' && alpineArch="$(apk --print-arch)" \ + && case "${alpineArch##*-}" in \ + x86_64) ARCH='x64' CHECKSUM="a8bec39586538896715be7a2ca7ef08727a58ad94d25876c5db11cafacff4c37" OPENSSL_ARCH=linux-x86_64;; \ + x86) OPENSSL_ARCH=linux-elf;; \ + aarch64) OPENSSL_ARCH=linux-aarch64;; \ + arm*) OPENSSL_ARCH=linux-armv4;; \ + ppc64le) OPENSSL_ARCH=linux-ppc64le;; \ + s390x) OPENSSL_ARCH=linux-s390x;; \ + *) ;; \ + esac \ + && if [ -n "${CHECKSUM}" ]; then \ + set -eu; \ + curl -fsSLO --compressed "https://unofficial-builds.nodejs.org/download/release/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz"; \ + echo "$CHECKSUM node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" | sha256sum -c - \ + && tar -xJf "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \ + && ln -s /usr/local/bin/node /usr/local/bin/nodejs; \ + else \ + echo "Building from source" \ + # backup build + && apk add --no-cache --virtual .build-deps-full \ + binutils-gold \ + g++ \ + gcc \ + gnupg \ + libgcc \ + linux-headers \ + make \ + python3 \ + # use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150 + && export GNUPGHOME="$(mktemp -d)" \ + # gpg keys listed at https://github.com/nodejs/node#release-keys + && for key in \ + 4ED778F539E3634C779C87C6D7062848A1AB005C \ + 141F07595B7B3FFE74309A937405533BE57C7D57 \ + 74F12602B6F1C4E913FAA37AD3A89613643B6201 \ + DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7 \ + 61FC681DFB92A079F1685E77973F295594EC4689 \ + 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \ + C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ + 890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4 \ + C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \ + 108F52B48DB57BB0CC439B2997B01419BD92F80A \ + A363A499291CBBC940DD62E41F10027AF002F8B0 \ + ; do \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \ + done \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ + && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ + && gpgconf --kill all \ + && rm -rf "$GNUPGHOME" \ + && grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ + && tar -xf "node-v$NODE_VERSION.tar.xz" \ + && cd "node-v$NODE_VERSION" \ + && ./configure \ + && make -j$(getconf _NPROCESSORS_ONLN) V= \ + && make install \ + && apk del .build-deps-full \ + && cd .. \ + && rm -Rf "node-v$NODE_VERSION" \ + && rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt; \ + fi \ + && rm -f "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" \ + # Remove unused OpenSSL headers to save ~34MB. See this NodeJS issue: https://github.com/nodejs/node/issues/46451 + && find /usr/local/include/node/openssl/archs -mindepth 1 -maxdepth 1 ! -name "$OPENSSL_ARCH" -exec rm -rf {} \; \ + && apk del .build-deps \ + # smoke tests + && node --version \ + && npm --version + +ENV YARN_VERSION 1.22.19 + +RUN apk add --no-cache --virtual .build-deps-yarn curl gnupg tar \ + # use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150 + && export GNUPGHOME="$(mktemp -d)" \ + && for key in \ + 6A010C5166006599AA17F08146C2130DFD2497F5 \ + ; do \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \ + done \ + && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ + && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \ + && gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && gpgconf --kill all \ + && rm -rf "$GNUPGHOME" \ + && mkdir -p /opt \ + && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ + && rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && apk del .build-deps-yarn \ + # smoke test + && yarn --version + +RUN apk --no-cache add gettext git htop tree linux-headers libc-dev + +# Install Rust +RUN apk --no-cache add rust rust-wasm cargo +RUN cargo install cargo-wasi --root=/usr/local +RUN chmod 777 /usr/local/bin + +COPY base.makefile Makefile shopify-app.md /assets/ +COPY entrypoint.sh /usr/local/bin/ +ENTRYPOINT ["entrypoint.sh"] \ No newline at end of file diff --git a/shopify/n20.11.0/p8.1/Makefile b/shopify/n20.11.0/p8.1/Makefile new file mode 100644 index 0000000..ef7fbc2 --- /dev/null +++ b/shopify/n20.11.0/p8.1/Makefile @@ -0,0 +1,15 @@ +include base.makefile + +# Add additional targets here or extend(::)/override(:) some, e.g.: + +# New target +#install-my-project: ## description for install-my-project +# @echo project installation steps + +# Extend: Further init directories +#init-directories:: +# @[ -d ~/dir ] || mkdir ~/dir + +# Override: New Node.js installation steps +#install-nodejs: +# @echo install it some other way diff --git a/shopify/n20.11.0/p8.1/base.makefile b/shopify/n20.11.0/p8.1/base.makefile new file mode 100644 index 0000000..3f1b1f4 --- /dev/null +++ b/shopify/n20.11.0/p8.1/base.makefile @@ -0,0 +1,127 @@ +# DON'T MODIFY THIS FILE, IT WILL BE OVERWRITTEN +# use Makefile instead to extend this file + +PROJECT_PATH=$(shell pwd) +RIPTIDE_BIN=$(shell which riptide) +RIPTIDE_SERVICE=shopify +RIPTIDE_SOURCE=/src +APP_NAME=$(shell basename $(CURDIR)) +DOCKER_IMAGE=riptidepy/shopify:latest +DOCKER_USER=docker + +## Make all targets .PHONY +.PHONY: + +## Self documentation +## @see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +## --------------------------------------------------------------------------------------------------------------------- +help:: # Show list of targets with short description (default) + @echo " " + @echo "Passing arguments:" + @echo " " + @echo "make target key1=value1 key2=value2" + @echo " " + @echo List of targets: + @echo " " + @grep -E -ho '[a-zA-Z_-]+::?.*?## ?.*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = "::?.*?##\\s?"}; {}; {printf "\033[36m%-40s\033[0m %s\n", $$1, $$2}' + +## check if variable is set +## use this as pre recipe for targets with arguments +arg-guard-%:: + @#echo "${$*}" + @if [ -z '${${*}}' ]; then $(MAKE); echo; echo 'Variable $* not set'; echo; exit 1; fi + +init-directories:: ## initialize directories + @[ -d ~/.config/shopify ] || mkdir ~/.config/shopify + @[ -d ~/.config/shopify-cli-kit-nodejs ] || mkdir ~/.config/shopify-cli-kit-nodejs + @[ -d ~/.config/shopify-cli-app-nodejs ] || mkdir ~/.config/shopify-cli-app-nodejs + @[ -d ~/.config/shopify-cli-host-theme-conf-nodejs ] || mkdir ~/.config/shopify-cli-host-theme-conf-nodejs + @[ -d ~/.cache/shopify-cli-nodejs ] || mkdir ~/.cache/shopify-cli-nodejs + @[ -d ~/.cache/shopify ] || mkdir ~/.cache/shopify + @[ -d ~/.cache/@shopify ] || mkdir ~/.cache/@shopify + @[ -d ~/.cache/shopify-gems-nodejs ] || mkdir ~/.cache/shopify-gems-nodejs + @[ -d ~/.config/composer ] || mkdir ~/.config/composer + @[ -d ~/.cache/composer ] || mkdir ~/.cache/composer + @[ -d ~/.config/ngrok ] || mkdir ~/.config/ngrok + @[ -d ~/.cache/yarn ] || mkdir ~/.cache/yarn + @[ -d ~/.npm ] || mkdir ~/.npm + +define move-from-subdir-cmd + @export RIPTIDE_DONT_SHOW_EXEC_WARNING=1 && \ + $(RIPTIDE_BIN) start -s $(RIPTIDE_SERVICE) -c keep_running && \ + $(RIPTIDE_BIN) exec --command "rm -rf $(RIPTIDE_SOURCE)/${APP_NAME}/.git" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "bash -c 'for i in \$$(ls -d {"$(RIPTIDE_SOURCE)/${APP_NAME}/"*,"$(RIPTIDE_SOURCE)/${APP_NAME}/".*} | tail -n +3); do rm -rf $(RIPTIDE_SOURCE)/\$${i#$(RIPTIDE_SOURCE)/${APP_NAME}/}; mv \$$i $(RIPTIDE_SOURCE)/; done;'" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "rm -rf \"$(RIPTIDE_SOURCE)/${APP_NAME}\"" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) stop -s $(RIPTIDE_SERVICE) +endef + +create-php: ## newly create app from php template + @$(RIPTIDE_BIN) cmd yarn create @shopify/app --template php --name=${APP_NAME} + $(move-from-subdir-cmd) + +install-php: init-directories ## install dev environment for php + @$(RIPTIDE_BIN) cmd yarn install + @export RIPTIDE_DONT_SHOW_EXEC_WARNING=1 && \ + $(RIPTIDE_BIN) start -s $(RIPTIDE_SERVICE) -c keep_running && \ + $(RIPTIDE_BIN) exec --command "cp $(RIPTIDE_SOURCE)/web/.env.example $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "sed -i \"s/APP_NAME=.*/APP_NAME=${APP_NAME}/\" $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "sed -i 's/DB_DATABASE=.*/DB_DATABASE=\\$(RIPTIDE_SOURCE)\/web\/storage\/db.sqlite/' $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "touch $(RIPTIDE_SOURCE)/web/storage/db.sqlite" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) stop -s $(RIPTIDE_SERVICE) + @$(RIPTIDE_BIN) cmd composer install + @$(RIPTIDE_BIN) cmd artisan key:generate + @$(RIPTIDE_BIN) cmd artisan migrate + +create-nodejs: ## newly create app from nodejs template + @$(RIPTIDE_BIN) cmd yarn create @shopify/app --template node --name=${APP_NAME} + $(move-from-subdir-cmd) + +install-nodejs: ## install dev environment for nodejs + @echo Install root dependencies... + @$(RIPTIDE_BIN) cmd yarn install + @echo Install backend dependencies... + @cd web && $(RIPTIDE_BIN) cmd yarn install + @echo Install frontend dependencies... + @cd web/frontend && $(RIPTIDE_BIN) cmd yarn install + +define dev-container-run-cmd + @docker run --rm -it \ + -u $(DOCKER_USER) \ + --network=host \ + -v ~/.config/composer:/home/$(DOCKER_USER)/.config/composer \ + -v ~/.cache/composer:/home/$(DOCKER_USER)/.cache/composer \ + -v ~/.config/shopify:/home/$(DOCKER_USER)/.config/shopify \ + -v ~/.config/shopify-cli-kit-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-kit-nodejs \ + -v ~/.config/shopify-cli-app-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-app-nodejs \ + -v ~/.config/shopify-cli-host-theme-conf-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-host-theme-conf-nodejs \ + -v ~/.cache/shopify-cli-nodejs:/home/$(DOCKER_USER)/.cache/shopify-cli-nodejs \ + -v ~/.cache/@shopify:/home/$(DOCKER_USER)/.cache/@shopify \ + -v ~/.cache/shopify:/home/$(DOCKER_USER)/.cache/shopify \ + -v ~/.cache/shopify-gems-nodejs:/home/$(DOCKER_USER)/.cache/shopify-gems-nodejs \ + -v ~/.config/ngrok:/home/$(DOCKER_USER)/.config/ngrok \ + -v ~/.cache/yarn:/home/$(DOCKER_USER)/.cache/yarn \ + -v ~/.npm:/home/$(DOCKER_USER)/.npm \ + -v $(shell pwd):$(RIPTIDE_SOURCE) \ + -w $(RIPTIDE_SOURCE) \ + --env-file $(shell pwd)/.env \ + $(DOCKER_IMAGE) +endef + +app-dev: init-directories ## start dev app + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app dev" ||: + +init-app: init-directories ## initialize app + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app dev --reset" ||: + +init-deploy: init-directories ## initialize deploy + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app deploy --reset" ||: + +run-in-container: init-directories ## run command in Shopify container, pass argument command + $(dev-container-run-cmd) $(command) + +## default target +## --------------------------------------------------------------------------------------------------------------------- +.DEFAULT_GOAL:= help diff --git a/shopify/n20.11.0/p8.1/entrypoint.sh b/shopify/n20.11.0/p8.1/entrypoint.sh new file mode 100755 index 0000000..de0bb63 --- /dev/null +++ b/shopify/n20.11.0/p8.1/entrypoint.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +if [ "${XDEBUG#-off}" = "on" ]; then + echo "Setting xdebug.mode 'debug'..." + sed -i 's/xdebug.mode=.*/xdebug.mode=debug/' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +if [ "${XDEBUG_CLIENT_HOST#-host.docker.internal}" != "host.docker.internal" ]; then + echo "Setting xdebug client host '${XDEBUG_CLIENT_HOST}'..." + sed -i "s/xdebug.client_host=.*/xdebug.client_host=${XDEBUG_CLIENT_HOST}/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +set -e + +# Run command with node if the first argument contains a "-" or is not a system command. The last +# part inside the "{}" is a workaround for the following bug in ash/dash: +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264 +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then + echo Prefix with node... + set -- node "$@" +fi + +RIPTIDE_SRC="/src/" +if [ -d "$RIPTIDE_SRC" ]; then + # Keep Makefile and documentation up to date + cp /assets/base.makefile "$RIPTIDE_SRC" + if [ ! -f "$RIPTIDE_SRC""Makefile" ]; then + cp /assets/Makefile "$RIPTIDE_SRC" + fi + if [ ! -f "$RIPTIDE_SRC"".env" ]; then + touch "$RIPTIDE_SRC"".env" + fi + cp /assets/shopify-app.md "$RIPTIDE_SRC" + + # Create app configuration if missing + if [ ! -f "$RIPTIDE_SRC""shopify.app.toml" ] && [ -f "$RIPTIDE_SRC""template.shopify.app.toml" ]; then + cp "$RIPTIDE_SRC""template.shopify.app.toml" "$RIPTIDE_SRC""shopify.app.toml" + fi +fi + +exec "$@" diff --git a/shopify/n20.11.0/p8.1/shopify-app.md b/shopify/n20.11.0/p8.1/shopify-app.md new file mode 100644 index 0000000..ee79e02 --- /dev/null +++ b/shopify/n20.11.0/p8.1/shopify-app.md @@ -0,0 +1,100 @@ +# Shopify App + + +## Setup development environment + +### Setup Riptide project + +```shell +riptide setup +``` + +### Update images + +```shell +riptide update +``` + +Note: Make sure riptide is in your PATH (not just an alias to your bin), so it could be found with `which`. + + +## Create new app + +You can jump to the next step, if you have existing app code. + +### Create new app framework + +For Node.js +```shell +make create-nodejs +``` + +For PHP +```shell +make create-php +``` + + +## Setup existing app + +### Install dependencies + +For Node.js +```shell +make install-nodejs +``` + +For PHP +```shell +make install-php +``` + +### Connect app with Shopify + +```shell +make init-app +``` + +### Connect app extensions with Shopify + +```shell +make init-deploy +``` + + +## Run app + +If you have not installed the Riptide shell extensions, prepend `riptide cmd`. + +```shell +shopify app dev +``` + +If this quits silently after "Dependencies installed", run `shopify auth logout`, `make init-app` and try again. + + +## Deploy extensions + +If you have not installed the Riptide shell extensions, prepend `riptide cmd`. + +```shell +shopify app deploy +``` + + +## Node.js Debugging + +To enable debugging add this to the script section in `web/package.json` (replace with your desired port): + +```json +"debug": "cross-env NODE_ENV=development nodemon --inspect=127.0.0.1: index.js --ignore ./frontend", +``` + +Update the `web/shopify.web.toml` to contain this: + +```toml +[commands] +dev = "npm run debug" +``` + +If you now run `shopify app dev` you could connect your debugging client to the specified port. diff --git a/shopify/n20.11.0/p8.2/Dockerfile b/shopify/n20.11.0/p8.2/Dockerfile new file mode 100644 index 0000000..3d80764 --- /dev/null +++ b/shopify/n20.11.0/p8.2/Dockerfile @@ -0,0 +1,168 @@ +FROM php:8.2-cli-alpine3.20 + +ARG XDEBUG_CLIENT_HOST=host.docker.internal +ENV XDEBUG_CLIENT_HOST $XDEBUG_CLIENT_HOST + +ARG DOCKER_USER=docker + +# add run dependencies +RUN apk add --no-cache \ + openrc \ + bash \ + postgresql-libs \ + ruby ruby-dev ruby-ffi libzip-dev \ + alpine-sdk \ + gcompat \ + icu \ + linux-headers \ + freetype libjpeg-turbo libpng libwebp + +# add build dependencies +RUN apk add --no-cache -t .build-deps \ + postgresql-dev \ + libxml2-dev \ + icu-dev \ + freetype-dev libpng-dev libjpeg-turbo-dev libwebp-dev \ + autoconf g++ make && \ +# install bundler for extension deployment + gem install bundler && \ +# configure xdebug + pecl install xdebug-3.3.1 && docker-php-ext-enable xdebug && \ + echo 'xdebug.mode=off' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo "xdebug.client_host=${XDEBUG_CLIENT_HOST}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo 'xdebug.cli_color=1' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo 'xdebug.start_with_request=yes' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ +# further php configuration and permissions + docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql && \ + docker-php-ext-configure simplexml && docker-php-ext-install simplexml && \ + docker-php-ext-configure pgsql && docker-php-ext-install pdo_pgsql && \ + docker-php-ext-configure zip && docker-php-ext-install zip && \ + docker-php-ext-configure intl && docker-php-ext-install intl && \ + docker-php-ext-configure gd --with-jpeg --with-webp --with-freetype && docker-php-ext-install gd && \ + chgrp 1000 /usr/local/etc/php/conf.d/ -R && \ + chmod g+w /usr/local/etc/php/conf.d/ -R && \ +# remove build dependencies + apk del --purge .build-deps + +# install composer +COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer + +# use the default production configuration for PHP +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" + +# Node and YARN installation steps taken from https://github.com/nodejs/docker-node/blob/ab5769dc69feb4007d9aafb03316ea0e3edb4227/18/alpine3.19/Dockerfile + +ENV NODE_VERSION 20.11.0 + +RUN addgroup -g 1000 ${DOCKER_USER} \ + && adduser -u 1000 -G ${DOCKER_USER} -s /bin/sh -D ${DOCKER_USER} \ + && apk add --no-cache \ + libstdc++ \ + && apk add --no-cache --virtual .build-deps \ + curl \ + && ARCH= OPENSSL_ARCH='linux*' && alpineArch="$(apk --print-arch)" \ + && case "${alpineArch##*-}" in \ + x86_64) ARCH='x64' CHECKSUM="a8bec39586538896715be7a2ca7ef08727a58ad94d25876c5db11cafacff4c37" OPENSSL_ARCH=linux-x86_64;; \ + x86) OPENSSL_ARCH=linux-elf;; \ + aarch64) OPENSSL_ARCH=linux-aarch64;; \ + arm*) OPENSSL_ARCH=linux-armv4;; \ + ppc64le) OPENSSL_ARCH=linux-ppc64le;; \ + s390x) OPENSSL_ARCH=linux-s390x;; \ + *) ;; \ + esac \ + && if [ -n "${CHECKSUM}" ]; then \ + set -eu; \ + curl -fsSLO --compressed "https://unofficial-builds.nodejs.org/download/release/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz"; \ + echo "$CHECKSUM node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" | sha256sum -c - \ + && tar -xJf "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \ + && ln -s /usr/local/bin/node /usr/local/bin/nodejs; \ + else \ + echo "Building from source" \ + # backup build + && apk add --no-cache --virtual .build-deps-full \ + binutils-gold \ + g++ \ + gcc \ + gnupg \ + libgcc \ + linux-headers \ + make \ + python3 \ + # use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150 + && export GNUPGHOME="$(mktemp -d)" \ + # gpg keys listed at https://github.com/nodejs/node#release-keys + && for key in \ + 4ED778F539E3634C779C87C6D7062848A1AB005C \ + 141F07595B7B3FFE74309A937405533BE57C7D57 \ + 74F12602B6F1C4E913FAA37AD3A89613643B6201 \ + DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7 \ + 61FC681DFB92A079F1685E77973F295594EC4689 \ + 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \ + C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ + 890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4 \ + C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \ + 108F52B48DB57BB0CC439B2997B01419BD92F80A \ + A363A499291CBBC940DD62E41F10027AF002F8B0 \ + ; do \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \ + done \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ + && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ + && gpgconf --kill all \ + && rm -rf "$GNUPGHOME" \ + && grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ + && tar -xf "node-v$NODE_VERSION.tar.xz" \ + && cd "node-v$NODE_VERSION" \ + && ./configure \ + && make -j$(getconf _NPROCESSORS_ONLN) V= \ + && make install \ + && apk del .build-deps-full \ + && cd .. \ + && rm -Rf "node-v$NODE_VERSION" \ + && rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt; \ + fi \ + && rm -f "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" \ + # Remove unused OpenSSL headers to save ~34MB. See this NodeJS issue: https://github.com/nodejs/node/issues/46451 + && find /usr/local/include/node/openssl/archs -mindepth 1 -maxdepth 1 ! -name "$OPENSSL_ARCH" -exec rm -rf {} \; \ + && apk del .build-deps \ + # smoke tests + && node --version \ + && npm --version + +ENV YARN_VERSION 1.22.19 + +RUN apk add --no-cache --virtual .build-deps-yarn curl gnupg tar \ + # use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150 + && export GNUPGHOME="$(mktemp -d)" \ + && for key in \ + 6A010C5166006599AA17F08146C2130DFD2497F5 \ + ; do \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \ + done \ + && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ + && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \ + && gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && gpgconf --kill all \ + && rm -rf "$GNUPGHOME" \ + && mkdir -p /opt \ + && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ + && rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && apk del .build-deps-yarn \ + # smoke test + && yarn --version + +RUN apk --no-cache add gettext git htop tree linux-headers libc-dev + +# Install Rust +RUN apk --no-cache add rust rust-wasm cargo +RUN cargo install cargo-wasi --root=/usr/local +RUN chmod 777 /usr/local/bin + +COPY base.makefile Makefile shopify-app.md /assets/ +COPY entrypoint.sh /usr/local/bin/ +ENTRYPOINT ["entrypoint.sh"] \ No newline at end of file diff --git a/shopify/n20.11.0/p8.2/Makefile b/shopify/n20.11.0/p8.2/Makefile new file mode 100644 index 0000000..ef7fbc2 --- /dev/null +++ b/shopify/n20.11.0/p8.2/Makefile @@ -0,0 +1,15 @@ +include base.makefile + +# Add additional targets here or extend(::)/override(:) some, e.g.: + +# New target +#install-my-project: ## description for install-my-project +# @echo project installation steps + +# Extend: Further init directories +#init-directories:: +# @[ -d ~/dir ] || mkdir ~/dir + +# Override: New Node.js installation steps +#install-nodejs: +# @echo install it some other way diff --git a/shopify/n20.11.0/p8.2/base.makefile b/shopify/n20.11.0/p8.2/base.makefile new file mode 100644 index 0000000..3f1b1f4 --- /dev/null +++ b/shopify/n20.11.0/p8.2/base.makefile @@ -0,0 +1,127 @@ +# DON'T MODIFY THIS FILE, IT WILL BE OVERWRITTEN +# use Makefile instead to extend this file + +PROJECT_PATH=$(shell pwd) +RIPTIDE_BIN=$(shell which riptide) +RIPTIDE_SERVICE=shopify +RIPTIDE_SOURCE=/src +APP_NAME=$(shell basename $(CURDIR)) +DOCKER_IMAGE=riptidepy/shopify:latest +DOCKER_USER=docker + +## Make all targets .PHONY +.PHONY: + +## Self documentation +## @see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +## --------------------------------------------------------------------------------------------------------------------- +help:: # Show list of targets with short description (default) + @echo " " + @echo "Passing arguments:" + @echo " " + @echo "make target key1=value1 key2=value2" + @echo " " + @echo List of targets: + @echo " " + @grep -E -ho '[a-zA-Z_-]+::?.*?## ?.*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = "::?.*?##\\s?"}; {}; {printf "\033[36m%-40s\033[0m %s\n", $$1, $$2}' + +## check if variable is set +## use this as pre recipe for targets with arguments +arg-guard-%:: + @#echo "${$*}" + @if [ -z '${${*}}' ]; then $(MAKE); echo; echo 'Variable $* not set'; echo; exit 1; fi + +init-directories:: ## initialize directories + @[ -d ~/.config/shopify ] || mkdir ~/.config/shopify + @[ -d ~/.config/shopify-cli-kit-nodejs ] || mkdir ~/.config/shopify-cli-kit-nodejs + @[ -d ~/.config/shopify-cli-app-nodejs ] || mkdir ~/.config/shopify-cli-app-nodejs + @[ -d ~/.config/shopify-cli-host-theme-conf-nodejs ] || mkdir ~/.config/shopify-cli-host-theme-conf-nodejs + @[ -d ~/.cache/shopify-cli-nodejs ] || mkdir ~/.cache/shopify-cli-nodejs + @[ -d ~/.cache/shopify ] || mkdir ~/.cache/shopify + @[ -d ~/.cache/@shopify ] || mkdir ~/.cache/@shopify + @[ -d ~/.cache/shopify-gems-nodejs ] || mkdir ~/.cache/shopify-gems-nodejs + @[ -d ~/.config/composer ] || mkdir ~/.config/composer + @[ -d ~/.cache/composer ] || mkdir ~/.cache/composer + @[ -d ~/.config/ngrok ] || mkdir ~/.config/ngrok + @[ -d ~/.cache/yarn ] || mkdir ~/.cache/yarn + @[ -d ~/.npm ] || mkdir ~/.npm + +define move-from-subdir-cmd + @export RIPTIDE_DONT_SHOW_EXEC_WARNING=1 && \ + $(RIPTIDE_BIN) start -s $(RIPTIDE_SERVICE) -c keep_running && \ + $(RIPTIDE_BIN) exec --command "rm -rf $(RIPTIDE_SOURCE)/${APP_NAME}/.git" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "bash -c 'for i in \$$(ls -d {"$(RIPTIDE_SOURCE)/${APP_NAME}/"*,"$(RIPTIDE_SOURCE)/${APP_NAME}/".*} | tail -n +3); do rm -rf $(RIPTIDE_SOURCE)/\$${i#$(RIPTIDE_SOURCE)/${APP_NAME}/}; mv \$$i $(RIPTIDE_SOURCE)/; done;'" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "rm -rf \"$(RIPTIDE_SOURCE)/${APP_NAME}\"" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) stop -s $(RIPTIDE_SERVICE) +endef + +create-php: ## newly create app from php template + @$(RIPTIDE_BIN) cmd yarn create @shopify/app --template php --name=${APP_NAME} + $(move-from-subdir-cmd) + +install-php: init-directories ## install dev environment for php + @$(RIPTIDE_BIN) cmd yarn install + @export RIPTIDE_DONT_SHOW_EXEC_WARNING=1 && \ + $(RIPTIDE_BIN) start -s $(RIPTIDE_SERVICE) -c keep_running && \ + $(RIPTIDE_BIN) exec --command "cp $(RIPTIDE_SOURCE)/web/.env.example $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "sed -i \"s/APP_NAME=.*/APP_NAME=${APP_NAME}/\" $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "sed -i 's/DB_DATABASE=.*/DB_DATABASE=\\$(RIPTIDE_SOURCE)\/web\/storage\/db.sqlite/' $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "touch $(RIPTIDE_SOURCE)/web/storage/db.sqlite" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) stop -s $(RIPTIDE_SERVICE) + @$(RIPTIDE_BIN) cmd composer install + @$(RIPTIDE_BIN) cmd artisan key:generate + @$(RIPTIDE_BIN) cmd artisan migrate + +create-nodejs: ## newly create app from nodejs template + @$(RIPTIDE_BIN) cmd yarn create @shopify/app --template node --name=${APP_NAME} + $(move-from-subdir-cmd) + +install-nodejs: ## install dev environment for nodejs + @echo Install root dependencies... + @$(RIPTIDE_BIN) cmd yarn install + @echo Install backend dependencies... + @cd web && $(RIPTIDE_BIN) cmd yarn install + @echo Install frontend dependencies... + @cd web/frontend && $(RIPTIDE_BIN) cmd yarn install + +define dev-container-run-cmd + @docker run --rm -it \ + -u $(DOCKER_USER) \ + --network=host \ + -v ~/.config/composer:/home/$(DOCKER_USER)/.config/composer \ + -v ~/.cache/composer:/home/$(DOCKER_USER)/.cache/composer \ + -v ~/.config/shopify:/home/$(DOCKER_USER)/.config/shopify \ + -v ~/.config/shopify-cli-kit-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-kit-nodejs \ + -v ~/.config/shopify-cli-app-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-app-nodejs \ + -v ~/.config/shopify-cli-host-theme-conf-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-host-theme-conf-nodejs \ + -v ~/.cache/shopify-cli-nodejs:/home/$(DOCKER_USER)/.cache/shopify-cli-nodejs \ + -v ~/.cache/@shopify:/home/$(DOCKER_USER)/.cache/@shopify \ + -v ~/.cache/shopify:/home/$(DOCKER_USER)/.cache/shopify \ + -v ~/.cache/shopify-gems-nodejs:/home/$(DOCKER_USER)/.cache/shopify-gems-nodejs \ + -v ~/.config/ngrok:/home/$(DOCKER_USER)/.config/ngrok \ + -v ~/.cache/yarn:/home/$(DOCKER_USER)/.cache/yarn \ + -v ~/.npm:/home/$(DOCKER_USER)/.npm \ + -v $(shell pwd):$(RIPTIDE_SOURCE) \ + -w $(RIPTIDE_SOURCE) \ + --env-file $(shell pwd)/.env \ + $(DOCKER_IMAGE) +endef + +app-dev: init-directories ## start dev app + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app dev" ||: + +init-app: init-directories ## initialize app + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app dev --reset" ||: + +init-deploy: init-directories ## initialize deploy + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app deploy --reset" ||: + +run-in-container: init-directories ## run command in Shopify container, pass argument command + $(dev-container-run-cmd) $(command) + +## default target +## --------------------------------------------------------------------------------------------------------------------- +.DEFAULT_GOAL:= help diff --git a/shopify/n20.11.0/p8.2/entrypoint.sh b/shopify/n20.11.0/p8.2/entrypoint.sh new file mode 100755 index 0000000..de0bb63 --- /dev/null +++ b/shopify/n20.11.0/p8.2/entrypoint.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +if [ "${XDEBUG#-off}" = "on" ]; then + echo "Setting xdebug.mode 'debug'..." + sed -i 's/xdebug.mode=.*/xdebug.mode=debug/' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +if [ "${XDEBUG_CLIENT_HOST#-host.docker.internal}" != "host.docker.internal" ]; then + echo "Setting xdebug client host '${XDEBUG_CLIENT_HOST}'..." + sed -i "s/xdebug.client_host=.*/xdebug.client_host=${XDEBUG_CLIENT_HOST}/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +set -e + +# Run command with node if the first argument contains a "-" or is not a system command. The last +# part inside the "{}" is a workaround for the following bug in ash/dash: +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264 +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then + echo Prefix with node... + set -- node "$@" +fi + +RIPTIDE_SRC="/src/" +if [ -d "$RIPTIDE_SRC" ]; then + # Keep Makefile and documentation up to date + cp /assets/base.makefile "$RIPTIDE_SRC" + if [ ! -f "$RIPTIDE_SRC""Makefile" ]; then + cp /assets/Makefile "$RIPTIDE_SRC" + fi + if [ ! -f "$RIPTIDE_SRC"".env" ]; then + touch "$RIPTIDE_SRC"".env" + fi + cp /assets/shopify-app.md "$RIPTIDE_SRC" + + # Create app configuration if missing + if [ ! -f "$RIPTIDE_SRC""shopify.app.toml" ] && [ -f "$RIPTIDE_SRC""template.shopify.app.toml" ]; then + cp "$RIPTIDE_SRC""template.shopify.app.toml" "$RIPTIDE_SRC""shopify.app.toml" + fi +fi + +exec "$@" diff --git a/shopify/n20.11.0/p8.2/shopify-app.md b/shopify/n20.11.0/p8.2/shopify-app.md new file mode 100644 index 0000000..ee79e02 --- /dev/null +++ b/shopify/n20.11.0/p8.2/shopify-app.md @@ -0,0 +1,100 @@ +# Shopify App + + +## Setup development environment + +### Setup Riptide project + +```shell +riptide setup +``` + +### Update images + +```shell +riptide update +``` + +Note: Make sure riptide is in your PATH (not just an alias to your bin), so it could be found with `which`. + + +## Create new app + +You can jump to the next step, if you have existing app code. + +### Create new app framework + +For Node.js +```shell +make create-nodejs +``` + +For PHP +```shell +make create-php +``` + + +## Setup existing app + +### Install dependencies + +For Node.js +```shell +make install-nodejs +``` + +For PHP +```shell +make install-php +``` + +### Connect app with Shopify + +```shell +make init-app +``` + +### Connect app extensions with Shopify + +```shell +make init-deploy +``` + + +## Run app + +If you have not installed the Riptide shell extensions, prepend `riptide cmd`. + +```shell +shopify app dev +``` + +If this quits silently after "Dependencies installed", run `shopify auth logout`, `make init-app` and try again. + + +## Deploy extensions + +If you have not installed the Riptide shell extensions, prepend `riptide cmd`. + +```shell +shopify app deploy +``` + + +## Node.js Debugging + +To enable debugging add this to the script section in `web/package.json` (replace with your desired port): + +```json +"debug": "cross-env NODE_ENV=development nodemon --inspect=127.0.0.1: index.js --ignore ./frontend", +``` + +Update the `web/shopify.web.toml` to contain this: + +```toml +[commands] +dev = "npm run debug" +``` + +If you now run `shopify app dev` you could connect your debugging client to the specified port. diff --git a/shopify/n20.11.0/p8.3/Dockerfile b/shopify/n20.11.0/p8.3/Dockerfile new file mode 100644 index 0000000..24bcfc1 --- /dev/null +++ b/shopify/n20.11.0/p8.3/Dockerfile @@ -0,0 +1,168 @@ +FROM php:8.3-cli-alpine3.20 + +ARG XDEBUG_CLIENT_HOST=host.docker.internal +ENV XDEBUG_CLIENT_HOST $XDEBUG_CLIENT_HOST + +ARG DOCKER_USER=docker + +# add run dependencies +RUN apk add --no-cache \ + openrc \ + bash \ + postgresql-libs \ + ruby ruby-dev ruby-ffi libzip-dev \ + alpine-sdk \ + gcompat \ + icu \ + linux-headers \ + freetype libjpeg-turbo libpng libwebp + +# add build dependencies +RUN apk add --no-cache -t .build-deps \ + postgresql-dev \ + libxml2-dev \ + icu-dev \ + freetype-dev libpng-dev libjpeg-turbo-dev libwebp-dev \ + autoconf g++ make && \ +# install bundler for extension deployment + gem install bundler && \ +# configure xdebug + pecl install xdebug-3.3.1 && docker-php-ext-enable xdebug && \ + echo 'xdebug.mode=off' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo "xdebug.client_host=${XDEBUG_CLIENT_HOST}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo 'xdebug.cli_color=1' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo 'xdebug.start_with_request=yes' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ +# further php configuration and permissions + docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql && \ + docker-php-ext-configure simplexml && docker-php-ext-install simplexml && \ + docker-php-ext-configure pgsql && docker-php-ext-install pdo_pgsql && \ + docker-php-ext-configure zip && docker-php-ext-install zip && \ + docker-php-ext-configure intl && docker-php-ext-install intl && \ + docker-php-ext-configure gd --with-jpeg --with-webp --with-freetype && docker-php-ext-install gd && \ + chgrp 1000 /usr/local/etc/php/conf.d/ -R && \ + chmod g+w /usr/local/etc/php/conf.d/ -R && \ +# remove build dependencies + apk del --purge .build-deps + +# install composer +COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer + +# use the default production configuration for PHP +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" + +# Node and YARN installation steps taken from https://github.com/nodejs/docker-node/blob/ab5769dc69feb4007d9aafb03316ea0e3edb4227/18/alpine3.19/Dockerfile + +ENV NODE_VERSION 20.11.0 + +RUN addgroup -g 1000 ${DOCKER_USER} \ + && adduser -u 1000 -G ${DOCKER_USER} -s /bin/sh -D ${DOCKER_USER} \ + && apk add --no-cache \ + libstdc++ \ + && apk add --no-cache --virtual .build-deps \ + curl \ + && ARCH= OPENSSL_ARCH='linux*' && alpineArch="$(apk --print-arch)" \ + && case "${alpineArch##*-}" in \ + x86_64) ARCH='x64' CHECKSUM="a8bec39586538896715be7a2ca7ef08727a58ad94d25876c5db11cafacff4c37" OPENSSL_ARCH=linux-x86_64;; \ + x86) OPENSSL_ARCH=linux-elf;; \ + aarch64) OPENSSL_ARCH=linux-aarch64;; \ + arm*) OPENSSL_ARCH=linux-armv4;; \ + ppc64le) OPENSSL_ARCH=linux-ppc64le;; \ + s390x) OPENSSL_ARCH=linux-s390x;; \ + *) ;; \ + esac \ + && if [ -n "${CHECKSUM}" ]; then \ + set -eu; \ + curl -fsSLO --compressed "https://unofficial-builds.nodejs.org/download/release/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz"; \ + echo "$CHECKSUM node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" | sha256sum -c - \ + && tar -xJf "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \ + && ln -s /usr/local/bin/node /usr/local/bin/nodejs; \ + else \ + echo "Building from source" \ + # backup build + && apk add --no-cache --virtual .build-deps-full \ + binutils-gold \ + g++ \ + gcc \ + gnupg \ + libgcc \ + linux-headers \ + make \ + python3 \ + # use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150 + && export GNUPGHOME="$(mktemp -d)" \ + # gpg keys listed at https://github.com/nodejs/node#release-keys + && for key in \ + 4ED778F539E3634C779C87C6D7062848A1AB005C \ + 141F07595B7B3FFE74309A937405533BE57C7D57 \ + 74F12602B6F1C4E913FAA37AD3A89613643B6201 \ + DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7 \ + 61FC681DFB92A079F1685E77973F295594EC4689 \ + 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \ + C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ + 890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4 \ + C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \ + 108F52B48DB57BB0CC439B2997B01419BD92F80A \ + A363A499291CBBC940DD62E41F10027AF002F8B0 \ + ; do \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \ + done \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ + && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ + && gpgconf --kill all \ + && rm -rf "$GNUPGHOME" \ + && grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ + && tar -xf "node-v$NODE_VERSION.tar.xz" \ + && cd "node-v$NODE_VERSION" \ + && ./configure \ + && make -j$(getconf _NPROCESSORS_ONLN) V= \ + && make install \ + && apk del .build-deps-full \ + && cd .. \ + && rm -Rf "node-v$NODE_VERSION" \ + && rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt; \ + fi \ + && rm -f "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" \ + # Remove unused OpenSSL headers to save ~34MB. See this NodeJS issue: https://github.com/nodejs/node/issues/46451 + && find /usr/local/include/node/openssl/archs -mindepth 1 -maxdepth 1 ! -name "$OPENSSL_ARCH" -exec rm -rf {} \; \ + && apk del .build-deps \ + # smoke tests + && node --version \ + && npm --version + +ENV YARN_VERSION 1.22.19 + +RUN apk add --no-cache --virtual .build-deps-yarn curl gnupg tar \ + # use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150 + && export GNUPGHOME="$(mktemp -d)" \ + && for key in \ + 6A010C5166006599AA17F08146C2130DFD2497F5 \ + ; do \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \ + done \ + && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ + && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \ + && gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && gpgconf --kill all \ + && rm -rf "$GNUPGHOME" \ + && mkdir -p /opt \ + && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ + && rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && apk del .build-deps-yarn \ + # smoke test + && yarn --version + +RUN apk --no-cache add gettext git htop tree linux-headers libc-dev + +# Install Rust +RUN apk --no-cache add rust rust-wasm cargo +RUN cargo install cargo-wasi --root=/usr/local +RUN chmod 777 /usr/local/bin + +COPY base.makefile Makefile shopify-app.md /assets/ +COPY entrypoint.sh /usr/local/bin/ +ENTRYPOINT ["entrypoint.sh"] \ No newline at end of file diff --git a/shopify/n20.11.0/p8.3/Makefile b/shopify/n20.11.0/p8.3/Makefile new file mode 100644 index 0000000..ef7fbc2 --- /dev/null +++ b/shopify/n20.11.0/p8.3/Makefile @@ -0,0 +1,15 @@ +include base.makefile + +# Add additional targets here or extend(::)/override(:) some, e.g.: + +# New target +#install-my-project: ## description for install-my-project +# @echo project installation steps + +# Extend: Further init directories +#init-directories:: +# @[ -d ~/dir ] || mkdir ~/dir + +# Override: New Node.js installation steps +#install-nodejs: +# @echo install it some other way diff --git a/shopify/n20.11.0/p8.3/base.makefile b/shopify/n20.11.0/p8.3/base.makefile new file mode 100644 index 0000000..3f1b1f4 --- /dev/null +++ b/shopify/n20.11.0/p8.3/base.makefile @@ -0,0 +1,127 @@ +# DON'T MODIFY THIS FILE, IT WILL BE OVERWRITTEN +# use Makefile instead to extend this file + +PROJECT_PATH=$(shell pwd) +RIPTIDE_BIN=$(shell which riptide) +RIPTIDE_SERVICE=shopify +RIPTIDE_SOURCE=/src +APP_NAME=$(shell basename $(CURDIR)) +DOCKER_IMAGE=riptidepy/shopify:latest +DOCKER_USER=docker + +## Make all targets .PHONY +.PHONY: + +## Self documentation +## @see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +## --------------------------------------------------------------------------------------------------------------------- +help:: # Show list of targets with short description (default) + @echo " " + @echo "Passing arguments:" + @echo " " + @echo "make target key1=value1 key2=value2" + @echo " " + @echo List of targets: + @echo " " + @grep -E -ho '[a-zA-Z_-]+::?.*?## ?.*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = "::?.*?##\\s?"}; {}; {printf "\033[36m%-40s\033[0m %s\n", $$1, $$2}' + +## check if variable is set +## use this as pre recipe for targets with arguments +arg-guard-%:: + @#echo "${$*}" + @if [ -z '${${*}}' ]; then $(MAKE); echo; echo 'Variable $* not set'; echo; exit 1; fi + +init-directories:: ## initialize directories + @[ -d ~/.config/shopify ] || mkdir ~/.config/shopify + @[ -d ~/.config/shopify-cli-kit-nodejs ] || mkdir ~/.config/shopify-cli-kit-nodejs + @[ -d ~/.config/shopify-cli-app-nodejs ] || mkdir ~/.config/shopify-cli-app-nodejs + @[ -d ~/.config/shopify-cli-host-theme-conf-nodejs ] || mkdir ~/.config/shopify-cli-host-theme-conf-nodejs + @[ -d ~/.cache/shopify-cli-nodejs ] || mkdir ~/.cache/shopify-cli-nodejs + @[ -d ~/.cache/shopify ] || mkdir ~/.cache/shopify + @[ -d ~/.cache/@shopify ] || mkdir ~/.cache/@shopify + @[ -d ~/.cache/shopify-gems-nodejs ] || mkdir ~/.cache/shopify-gems-nodejs + @[ -d ~/.config/composer ] || mkdir ~/.config/composer + @[ -d ~/.cache/composer ] || mkdir ~/.cache/composer + @[ -d ~/.config/ngrok ] || mkdir ~/.config/ngrok + @[ -d ~/.cache/yarn ] || mkdir ~/.cache/yarn + @[ -d ~/.npm ] || mkdir ~/.npm + +define move-from-subdir-cmd + @export RIPTIDE_DONT_SHOW_EXEC_WARNING=1 && \ + $(RIPTIDE_BIN) start -s $(RIPTIDE_SERVICE) -c keep_running && \ + $(RIPTIDE_BIN) exec --command "rm -rf $(RIPTIDE_SOURCE)/${APP_NAME}/.git" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "bash -c 'for i in \$$(ls -d {"$(RIPTIDE_SOURCE)/${APP_NAME}/"*,"$(RIPTIDE_SOURCE)/${APP_NAME}/".*} | tail -n +3); do rm -rf $(RIPTIDE_SOURCE)/\$${i#$(RIPTIDE_SOURCE)/${APP_NAME}/}; mv \$$i $(RIPTIDE_SOURCE)/; done;'" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "rm -rf \"$(RIPTIDE_SOURCE)/${APP_NAME}\"" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) stop -s $(RIPTIDE_SERVICE) +endef + +create-php: ## newly create app from php template + @$(RIPTIDE_BIN) cmd yarn create @shopify/app --template php --name=${APP_NAME} + $(move-from-subdir-cmd) + +install-php: init-directories ## install dev environment for php + @$(RIPTIDE_BIN) cmd yarn install + @export RIPTIDE_DONT_SHOW_EXEC_WARNING=1 && \ + $(RIPTIDE_BIN) start -s $(RIPTIDE_SERVICE) -c keep_running && \ + $(RIPTIDE_BIN) exec --command "cp $(RIPTIDE_SOURCE)/web/.env.example $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "sed -i \"s/APP_NAME=.*/APP_NAME=${APP_NAME}/\" $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "sed -i 's/DB_DATABASE=.*/DB_DATABASE=\\$(RIPTIDE_SOURCE)\/web\/storage\/db.sqlite/' $(RIPTIDE_SOURCE)/web/.env" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) exec --command "touch $(RIPTIDE_SOURCE)/web/storage/db.sqlite" $(RIPTIDE_SERVICE) && \ + $(RIPTIDE_BIN) stop -s $(RIPTIDE_SERVICE) + @$(RIPTIDE_BIN) cmd composer install + @$(RIPTIDE_BIN) cmd artisan key:generate + @$(RIPTIDE_BIN) cmd artisan migrate + +create-nodejs: ## newly create app from nodejs template + @$(RIPTIDE_BIN) cmd yarn create @shopify/app --template node --name=${APP_NAME} + $(move-from-subdir-cmd) + +install-nodejs: ## install dev environment for nodejs + @echo Install root dependencies... + @$(RIPTIDE_BIN) cmd yarn install + @echo Install backend dependencies... + @cd web && $(RIPTIDE_BIN) cmd yarn install + @echo Install frontend dependencies... + @cd web/frontend && $(RIPTIDE_BIN) cmd yarn install + +define dev-container-run-cmd + @docker run --rm -it \ + -u $(DOCKER_USER) \ + --network=host \ + -v ~/.config/composer:/home/$(DOCKER_USER)/.config/composer \ + -v ~/.cache/composer:/home/$(DOCKER_USER)/.cache/composer \ + -v ~/.config/shopify:/home/$(DOCKER_USER)/.config/shopify \ + -v ~/.config/shopify-cli-kit-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-kit-nodejs \ + -v ~/.config/shopify-cli-app-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-app-nodejs \ + -v ~/.config/shopify-cli-host-theme-conf-nodejs:/home/$(DOCKER_USER)/.config/shopify-cli-host-theme-conf-nodejs \ + -v ~/.cache/shopify-cli-nodejs:/home/$(DOCKER_USER)/.cache/shopify-cli-nodejs \ + -v ~/.cache/@shopify:/home/$(DOCKER_USER)/.cache/@shopify \ + -v ~/.cache/shopify:/home/$(DOCKER_USER)/.cache/shopify \ + -v ~/.cache/shopify-gems-nodejs:/home/$(DOCKER_USER)/.cache/shopify-gems-nodejs \ + -v ~/.config/ngrok:/home/$(DOCKER_USER)/.config/ngrok \ + -v ~/.cache/yarn:/home/$(DOCKER_USER)/.cache/yarn \ + -v ~/.npm:/home/$(DOCKER_USER)/.npm \ + -v $(shell pwd):$(RIPTIDE_SOURCE) \ + -w $(RIPTIDE_SOURCE) \ + --env-file $(shell pwd)/.env \ + $(DOCKER_IMAGE) +endef + +app-dev: init-directories ## start dev app + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app dev" ||: + +init-app: init-directories ## initialize app + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app dev --reset" ||: + +init-deploy: init-directories ## initialize deploy + $(dev-container-run-cmd) \ + bash -c "./node_modules/.bin/shopify app deploy --reset" ||: + +run-in-container: init-directories ## run command in Shopify container, pass argument command + $(dev-container-run-cmd) $(command) + +## default target +## --------------------------------------------------------------------------------------------------------------------- +.DEFAULT_GOAL:= help diff --git a/shopify/n20.11.0/p8.3/entrypoint.sh b/shopify/n20.11.0/p8.3/entrypoint.sh new file mode 100755 index 0000000..de0bb63 --- /dev/null +++ b/shopify/n20.11.0/p8.3/entrypoint.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +if [ "${XDEBUG#-off}" = "on" ]; then + echo "Setting xdebug.mode 'debug'..." + sed -i 's/xdebug.mode=.*/xdebug.mode=debug/' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +if [ "${XDEBUG_CLIENT_HOST#-host.docker.internal}" != "host.docker.internal" ]; then + echo "Setting xdebug client host '${XDEBUG_CLIENT_HOST}'..." + sed -i "s/xdebug.client_host=.*/xdebug.client_host=${XDEBUG_CLIENT_HOST}/" /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +set -e + +# Run command with node if the first argument contains a "-" or is not a system command. The last +# part inside the "{}" is a workaround for the following bug in ash/dash: +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264 +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then + echo Prefix with node... + set -- node "$@" +fi + +RIPTIDE_SRC="/src/" +if [ -d "$RIPTIDE_SRC" ]; then + # Keep Makefile and documentation up to date + cp /assets/base.makefile "$RIPTIDE_SRC" + if [ ! -f "$RIPTIDE_SRC""Makefile" ]; then + cp /assets/Makefile "$RIPTIDE_SRC" + fi + if [ ! -f "$RIPTIDE_SRC"".env" ]; then + touch "$RIPTIDE_SRC"".env" + fi + cp /assets/shopify-app.md "$RIPTIDE_SRC" + + # Create app configuration if missing + if [ ! -f "$RIPTIDE_SRC""shopify.app.toml" ] && [ -f "$RIPTIDE_SRC""template.shopify.app.toml" ]; then + cp "$RIPTIDE_SRC""template.shopify.app.toml" "$RIPTIDE_SRC""shopify.app.toml" + fi +fi + +exec "$@" diff --git a/shopify/n20.11.0/p8.3/shopify-app.md b/shopify/n20.11.0/p8.3/shopify-app.md new file mode 100644 index 0000000..ee79e02 --- /dev/null +++ b/shopify/n20.11.0/p8.3/shopify-app.md @@ -0,0 +1,100 @@ +# Shopify App + + +## Setup development environment + +### Setup Riptide project + +```shell +riptide setup +``` + +### Update images + +```shell +riptide update +``` + +Note: Make sure riptide is in your PATH (not just an alias to your bin), so it could be found with `which`. + + +## Create new app + +You can jump to the next step, if you have existing app code. + +### Create new app framework + +For Node.js +```shell +make create-nodejs +``` + +For PHP +```shell +make create-php +``` + + +## Setup existing app + +### Install dependencies + +For Node.js +```shell +make install-nodejs +``` + +For PHP +```shell +make install-php +``` + +### Connect app with Shopify + +```shell +make init-app +``` + +### Connect app extensions with Shopify + +```shell +make init-deploy +``` + + +## Run app + +If you have not installed the Riptide shell extensions, prepend `riptide cmd`. + +```shell +shopify app dev +``` + +If this quits silently after "Dependencies installed", run `shopify auth logout`, `make init-app` and try again. + + +## Deploy extensions + +If you have not installed the Riptide shell extensions, prepend `riptide cmd`. + +```shell +shopify app deploy +``` + + +## Node.js Debugging + +To enable debugging add this to the script section in `web/package.json` (replace with your desired port): + +```json +"debug": "cross-env NODE_ENV=development nodemon --inspect=127.0.0.1: index.js --ignore ./frontend", +``` + +Update the `web/shopify.web.toml` to contain this: + +```toml +[commands] +dev = "npm run debug" +``` + +If you now run `shopify app dev` you could connect your debugging client to the specified port.