Skip to content

Commit

Permalink
fix: check if a local template is already included and in that case d…
Browse files Browse the repository at this point in the history
…on't append static ones with the same name

docs: add github social card to the repo
chore: better support for wordpress media
  • Loading branch information
Janos Miko committed Feb 1, 2021
1 parent a5aff30 commit 1bec247
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 22 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/docker-image-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.
<!-- include_open_stop -->

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)
Expand Down Expand Up @@ -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.
<!-- include_open_stop -->

* [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.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.1-beta
0.1.2-beta
Binary file added docs/imgs/reward-github-card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions images/php-fpm/wordpress/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions images/php-fpm/wordpress/context/debug/etc/php-cli.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[php]
xdebug.remote_autostart=on
xdebug.remote_host=${XDEBUG_REMOTE_HOST}
14 changes: 14 additions & 0 deletions images/php-fpm/wordpress/context/debug/etc/php.d/15-xdebug.ini
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions images/php-fpm/wordpress/debug/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
13 changes: 6 additions & 7 deletions images/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -165,7 +165,7 @@ function build_image () {

[[ $PUSH_FLAG ]] && "${DOCKER}" push "${IMAGE_TAG}"

return
return 0
}

## Login to docker hub as needed
Expand All @@ -191,15 +191,14 @@ 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

build_image
done
fi



exit 0
2 changes: 1 addition & 1 deletion internal/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
43 changes: 35 additions & 8 deletions internal/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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())
}
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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())
}
}
Expand Down
4 changes: 1 addition & 3 deletions templates/environments/wordpress/wordpress.mutagen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ sync:
- ".idea"

# Magento files
- "/wp-content/media"
- "/pub/static/**"
- "!/pub/static/.htaccess"
- "/wp-content/uploads"

permissions:
defaultFileMode: "0644"
Expand Down

0 comments on commit 1bec247

Please sign in to comment.