I want to access a data directory in OpenShift.
I created a folder called uploads
and I also created the symlink using putty,
still I cant access the file and it shows a 404 page.
Can anybody tell me the process in detail (step by step),
as I recently started working with OpenShift.
Also, whenever I update the repository using a git client it deletes the symlink.
I'm working on a maven project.
Here are the steps which I followed:
cd <openshift deploy dir in my local system>
touch .openshift/action_hooks/deploy
vi .openshift/action_hooks/deploy
- Pasted the following code
ln -sf ${OPENSHIFT_DATA_DIR}images /var/lib/openshift/<app-id>/jbossews/webapps
in the file. Note: images dir is already present in the data dir on the openshift server.
chmod +x .openshift/action_hooks/deploy
git add .openshift/action_hooks/deploy
git commit -a -m "added deploy"
git push origin
I was able to access the images folder here: https://app-url/images
Hope this helps
Create the symlink in a deploy action hook to prevent the symlink from being overwritten.
In .openshift/action_hooks/deploy
:
#!/bin/bash
# This deploy hook gets executed after dependencies are resolved and the
# build hook has been run but before the application has been started back
# up again.
# create the uploads directory if it doesn't exist
if [ ! -d ${OPENSHIFT_DATA_DIR}uploads ]; then
mkdir ${OPENSHIFT_DATA_DIR}uploads
fi
# create symlink to uploads directory
ln -sf ${OPENSHIFT_DATA_DIR}uploads ${OPENSHIFT_REPO_DIR}webapps/
See line 67 of the WordPress QuickStart as an example.