Search code examples
linuxwordpressgitopenshiftpaas

OpenShift WordPress Theme Developer workflow


I create a application with Cartridges,

  • PHP 5.4
  • MySQL 5.5
  • phpMyAdmin 4.0

I commit my WP file, plugin and themes into GIT. In my .gitignore, i added

wp-content/uploads

I did go through the book "Getting Started with OpenShift", as the book chapter 8 said

“The other directory available to you is the OpenShift data directory, which is currently at $OPENSHIFT_HOMEDIR/app-root/data. We use the environment variable OPENSHIFT_DATA_DIR to point to this location. ”

“The data directory is where your application should store its files and put configuration settings, download themes, or generally anything you want to survive restarts and Git pushes.”

Excerpt From: Steven Pousty and Katie J. Miller. “Getting Started With OpenShift.”

I access to SSH. When I upload my media in WordPress, It is store inside

$OPENSHIFT_REPO_DIR/php/wp-content/uploads/2014/05/1.jpg

1.How do I pointed it to?

$OPENSHIFT_DATA_DIR/uploads
  1. If that is the case, in my .openshift/action_hooks/deploy file, I had added this script

    if [ ! -d ${OPENSHIFT_DATA_DIR}uploads ]; then mkdir ${OPENSHIFT_DATA_DIR}uploads fi

    ln -sf ${OPENSHIFT_DATA_DIR}uploads ${OPENSHIFT_REPO_DIR}php/wp-content/

However, the soft link script does not did it job, during my GIT PUSH, it shows the following error.

remote: ln: target `/var/lib/openshift/[ID]/app-root/runtime/repo/php/wp-content/' is not a directory: No such file or directory    

my guess is, the $OPENSHIFT_REPO_DIR/php/wp-content/uploads/2014/05/1.jpg , the uploads folder already removed before the script do it job.

How do I keep the uploads folder content in such a situation. OpenShift expert kindly help in this matter.


Solution

  • After I had few attempt of the build script, I finally found out what is my problem.

    To answer my own questions

    1. How do I point it. Create a symlink. During the GIT push, it will definitely delete your uploads folder ($OPENSHIFT_REPO_DIR/wp-content/uploads/).

    This is the code you should use, just remove the php folder after the repo.

    if [ ! -d ${OPENSHIFT_DATA_DIR}uploads ]; then
        mkdir ${OPENSHIFT_DATA_DIR}uploads
    fi
    
    ln -sf ${OPENSHIFT_DATA_DIR}uploads   ${OPENSHIFT_REPO_DIR}wp-content/
    

    I hope it's help.