Reputation: 534
I create a application with Cartridges,
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
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.
Upvotes: 3
Views: 473
Reputation: 534
After I had few attempt of the build script, I finally found out what is my problem.
To answer my own questions
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.
Upvotes: 2
Reputation: 3526
This file has plenty of examples
https://github.com/openshift/wordpress-example/blob/master/.openshift/action_hooks/deploy
The problem is that with every git push we are going to overwrite that directory.
I think a better idea is with every build rsync contents from your repo over to the data directory where it expects to find the themes (rather than doing the symlink)
Upvotes: 1