diff --git a/.github/workflows/docker-image-php.yml b/.github/workflows/docker-image-php.yml index 34840b55..d0716cdf 100644 --- a/.github/workflows/docker-image-php.yml +++ b/.github/workflows/docker-image-php.yml @@ -82,3 +82,19 @@ jobs: PHP_VERSION: ${{ matrix.php_version }} DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + + wordpress: + name: PHP-FPM ${{ matrix.php_version }} (wordpress) + runs-on: ubuntu-latest + needs: php-fpm + strategy: + matrix: + php_version: ["7.0", "7.1", "7.2", "7.3", "7.4", "8.0"] + steps: + - uses: actions/checkout@v1 + - run: ./images/scripts/build.sh --push "${BUILD_GROUP}" + env: + BUILD_GROUP: php-fpm/wordpress + PHP_VERSION: ${{ matrix.php_version }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} diff --git a/README.md b/README.md index 37814018..88780efe 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +![Reward Logo](./docs/imgs/reward-github-card.png) # Reward Reward is a Swiss Army knife CLI utility for orchestrating Docker based development environments. @@ -7,6 +8,8 @@ common services proxying requests to the correct environment's containers. Reward is written in Go and it supports Linux, macOS and Windows. +Reward was inspired by Warden. See the Acknowledgment section for more info. + Reward was created under the aegis of [ITG Commerce](https://itgcommerce.com). * [Documentation](https://rewardenv.readthedocs.io) @@ -66,9 +69,9 @@ This project was started in 2021 by Janos Miko. ## Acknowledgement -Reward was inspired by Warden and most if it's functionality are reused/rewritten so HUGE thanks to David Alger and -all the contributors for creating Warden which is the predecessor of this project. +Reward was inspired by Warden and most of its functionalities are reused/rewritten in Reward, so HUGE thanks to David Alger and all the contributors for creating it. * [David Alger's Github](https://github.com/davidalger) * [Warden's homepage](https://warden.dev) +* All images used for the logo are copyright to their respective owners. diff --git a/VERSION.txt b/VERSION.txt index 7d85ce84..70cca611 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -0.1.1-beta +0.1.2-beta diff --git a/docs/imgs/reward-github-card.png b/docs/imgs/reward-github-card.png new file mode 100644 index 00000000..da7cf13e Binary files /dev/null and b/docs/imgs/reward-github-card.png differ diff --git a/images/php-fpm/wordpress/Dockerfile b/images/php-fpm/wordpress/Dockerfile new file mode 100644 index 00000000..c12ae187 --- /dev/null +++ b/images/php-fpm/wordpress/Dockerfile @@ -0,0 +1,12 @@ +ARG PHP_VERSION +FROM docker.io/rewardenv/php-fpm:${PHP_VERSION} +USER root + +# Resolve permission issues stemming from directories auto-created by docker due to mounts in sub-directories +ENV CHOWN_DIR_LIST "wp-content/uploads" + +RUN set -eux \ + && curl -s https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar > /usr/bin/wp \ + && chmod +x /usr/bin/wp + +USER www-data diff --git a/images/php-fpm/wordpress/context/debug/etc/php-cli.ini b/images/php-fpm/wordpress/context/debug/etc/php-cli.ini new file mode 100644 index 00000000..38125cb6 --- /dev/null +++ b/images/php-fpm/wordpress/context/debug/etc/php-cli.ini @@ -0,0 +1,3 @@ +[php] +xdebug.remote_autostart=on +xdebug.remote_host=${XDEBUG_REMOTE_HOST} diff --git a/images/php-fpm/wordpress/context/debug/etc/php.d/15-xdebug.ini b/images/php-fpm/wordpress/context/debug/etc/php.d/15-xdebug.ini new file mode 100644 index 00000000..db764765 --- /dev/null +++ b/images/php-fpm/wordpress/context/debug/etc/php.d/15-xdebug.ini @@ -0,0 +1,14 @@ +; Enable xdebug extension module +zend_extension=xdebug.so + +xdebug.remote_enable="on" +xdebug.remote_connect_back="on" +xdebug.remote_addr_header="HTTP_X_DEBUG_HOST" +xdebug.idekey=PHPSTORM +xdebug.show_local_vars="on" +xdebug.var_display_max_depth=3 +xdebug.max_nesting_level=250 +xdebug.file_link_format = '"phpstorm://open?file=%f&line=%l"' +xdebug.profiler_enable=0 +xdebug.profiler_output_dir="/tmp" +xdebug.profiler_output_name=cachegrind.out.%s.%t diff --git a/images/php-fpm/wordpress/debug/Dockerfile b/images/php-fpm/wordpress/debug/Dockerfile new file mode 100644 index 00000000..079751a5 --- /dev/null +++ b/images/php-fpm/wordpress/debug/Dockerfile @@ -0,0 +1,13 @@ +ARG PHP_VERSION +FROM docker.io/rewardenv/php-fpm:${PHP_VERSION}-wordpress +USER root + +RUN set -eux \ + && yum install -y php-pecl-xdebug \ + && yum clean all \ + && rm -rf /var/cache/yum + +COPY debug/etc/*.ini /etc/ +COPY debug/etc/php.d/*.ini /etc/php.d/ + +USER www-data diff --git a/images/scripts/build.sh b/images/scripts/build.sh index d4109643..c7567597 100755 --- a/images/scripts/build.sh +++ b/images/scripts/build.sh @@ -121,7 +121,7 @@ function build_image () { done "${DOCKER}" image rm "${IMAGE_NAME}:build" || true - return + return 0 # PHP-FPM images will not have each version in a directory tree; require version be passed # in as env variable for use as a build argument. @@ -165,7 +165,7 @@ function build_image () { [[ $PUSH_FLAG ]] && "${DOCKER}" push "${IMAGE_TAG}" - return + return 0 } ## Login to docker hub as needed @@ -191,9 +191,9 @@ else # For the rest we iterate through the folders to create them by version folder for file in $(find "${SEARCH_PATH}" -type f -name Dockerfile | sort -V); do - # Due to build matrix requirements, magento1 and magento2 specific varients are built in separate invocation - # so we skip this one. - if [[ ${SEARCH_PATH} == "php-fpm" ]] && [[ ${file} =~ php-fpm/magento[1-2] ]]; then + # Due to build matrix requirements, magento1, magento2 and wordpress specific variants are built in + # separate invocation so we skip this one. + if [[ ${SEARCH_PATH} == "php-fpm" ]] && [[ ${file} =~ php-fpm/(magento[1-2]|wordpress) ]]; then continue fi @@ -201,5 +201,4 @@ else done fi - - +exit 0 diff --git a/internal/env.go b/internal/env.go index f69e793b..fd85f011 100644 --- a/internal/env.go +++ b/internal/env.go @@ -385,7 +385,7 @@ func EnvBuildDockerComposeTemplate(t *template.Template, templateList *list.List log.Debugln("ENV_TYPE:", envType) // magento - if CheckRegexInString(`^magento`, envType) { + if CheckRegexInString(`^magento|wordpress`, envType) { log.Debugln("Setting SVC_PHP_VARIANT.") viper.Set(AppName+"_svc_php_variant", "-"+envType) diff --git a/internal/templates.go b/internal/templates.go index 46599ded..be7f25f7 100644 --- a/internal/templates.go +++ b/internal/templates.go @@ -34,8 +34,20 @@ func AppendTemplatesFromPaths(t *template.Template, templateList *list.List, pat if CheckFileExists(templatePath) { log.Traceln("appending template:", templatePath) - child := template.Must(template.New(templatePath).Funcs(sprig.TxtFuncMap()).Funcs(funcs).ParseFiles(templatePath)) - _, _ = t.AddParseTree(child.Name(), child.Tree) + searchT := t.Lookup(templatePath) + if searchT != nil { + log.Traceln("template already defined:", templatePath) + continue + } + + child, err := template.New(templatePath).Funcs(sprig.TxtFuncMap()).Funcs(funcs).ParseFiles(templatePath) + if err != nil { + return err + } + _, err = t.AddParseTree(child.Name(), child.Tree) + if err != nil { + return err + } templateList.PushBack(child.Name()) } else { log.Traceln("template not found:", templatePath) @@ -57,8 +69,14 @@ func AppendTemplatesFromPathsStatic(t *template.Template, templateList *list.Lis log.Traceln(err) } else { log.Traceln("appending template:", v) - child := template.Must(template.New(v).Funcs(sprig.TxtFuncMap()).Funcs(funcs).Parse(string(content))) - _, _ = t.AddParseTree(child.Name(), child.Tree) + child, err := template.New(v).Funcs(sprig.TxtFuncMap()).Funcs(funcs).Parse(string(content)) + if err != nil { + return err + } + _, err = t.AddParseTree(child.Name(), child.Tree) + if err != nil { + return err + } templateList.PushBack(child.Name()) } } @@ -85,15 +103,18 @@ func AppendEnvironmentTemplates(t *template.Template, templateList *list.List, p log.Traceln("template paths:") log.Traceln(staticTemplatePaths, templatePaths) - err := AppendTemplatesFromPathsStatic(t, templateList, staticTemplatePaths) + // First read the templates from the current directory. If they exist we will use them. If the don't + // then we will append them from the static content. + err := AppendTemplatesFromPaths(t, templateList, templatePaths) if err != nil { return err } - err = AppendTemplatesFromPaths(t, templateList, templatePaths) + err = AppendTemplatesFromPathsStatic(t, templateList, staticTemplatePaths) if err != nil { return err } + // for _, v := range staticTemplatePaths { // content, err := Asset(v) // if err != nil { @@ -137,8 +158,14 @@ func AppendMutagenTemplates(t *template.Template, templateList *list.List, parti log.Traceln(err) } else { log.Traceln("appending template:", v) - child := template.Must(template.New(v).Funcs(sprig.TxtFuncMap()).Parse(string(content))) - _, _ = t.AddParseTree(child.Name(), child.Tree) + child, err := template.New(v).Funcs(sprig.TxtFuncMap()).Parse(string(content)) + if err != nil { + return err + } + _, err = t.AddParseTree(child.Name(), child.Tree) + if err != nil { + return err + } templateList.PushBack(child.Name()) } } diff --git a/templates/environments/wordpress/wordpress.mutagen.yml b/templates/environments/wordpress/wordpress.mutagen.yml index daededf4..8d7944f2 100644 --- a/templates/environments/wordpress/wordpress.mutagen.yml +++ b/templates/environments/wordpress/wordpress.mutagen.yml @@ -19,9 +19,7 @@ sync: - ".idea" # Magento files - - "/wp-content/media" - - "/pub/static/**" - - "!/pub/static/.htaccess" + - "/wp-content/uploads" permissions: defaultFileMode: "0644"