Access Data Directory in Openshift with URL

2019-02-16 01:43发布

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.

2条回答
唯我独甜
2楼-- · 2019-02-16 02:15

Here are the steps which I followed:

  1. cd <openshift deploy dir in my local system>
  2. touch .openshift/action_hooks/deploy
  3. vi .openshift/action_hooks/deploy
  4. 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.
  5. chmod +x .openshift/action_hooks/deploy
  6. git add .openshift/action_hooks/deploy
  7. git commit -a -m "added deploy"
  8. git push origin

I was able to access the images folder here: https://app-url/images

Hope this helps

查看更多
祖国的老花朵
3楼-- · 2019-02-16 02:24

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.

查看更多
登录 后发表回答