2

I have a symfony 2 project I am trying to launch on OpenShift online. I created the directory as required and running symfony locally works perfect.

However, when I deploy to my OpenShift application the deploy and post_deploy action_hooks do not run. I do not even see the output on git push like they mention in the documentation.

I should also note that I can ssh into the app and create a test.sh that will run the exact same code and work as intended.

Any help would be greatly appreciated, I've placed multiple tickets with the support staff and no luck.

Here is a link to a screenshot of the directory structure:

https://www.dropbox.com/s/oup9fa3rfgw43wy/Screenshot%202014-05-15%2019.03.21.png

Below is my post_deploy hook:

#!/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.  This script gets executed directly, so it could be python, php,
# ruby, etc.

# set the location for composer home to the data dir
export COMPOSER_HOME="$OPENSHIFT_DATA_DIR/.composer"

# check if composer exists in data dir
if [ ! -f "$OPENSHIFT_DATA_DIR/composer.phar" ]; then
    curl -s https://getcomposer.org/installer | /opt/rh/php54/root/usr/bin/php -- --install-dir=$OPENSHIFT_DATA_DIR
else
    /opt/rh/php54/root/usr/bin/php $OPENSHIFT_DATA_DIR/composer.phar self-update
fi

# check and set the symlink for vendor dir
if [ ! -d "$OPENSHIFT_DATA_DIR/vendor" ]; then
    echo !!! vendor directory does NOT exist - creating symlink...
    mkdir $OPENSHIFT_DATA_DIR/vendor
    echo !!! created vendor directory - creating symlink...
    ln -s $OPENSHIFT_DATA_DIR/vendor $OPENSHIFT_REPO_DIR/vendor
    echo !!! created symlink - setting permissions on directory...
    chmod -R 0777 $OPENSHIFT_DATA_DIR/vendor
    echo !!! permissions have been set on vendor directory!
else
    echo !!! vendor directory already exists - skipping symlink...
fi

// shortened for brevity, but the rest is the same.

# use composer install
( unset GIT_DIR ; cd $OPENSHIFT_REPO_DIR ; /opt/rh/php54/root/usr/bin/php $OPENSHIFT_DATA_DIR/composer.phar install )
Jason M.
  • 563
  • 1
  • 5
  • 10

2 Answers2

7

Make sure that you are making your action_hooks executable (chmod +x) and then adding that information to git, and do a git push. On Windows, you'll need to run:

git update-index --chmod=+x .openshift/action_hooks/*
Flimm
  • 136,138
  • 45
  • 251
  • 267
1

(This is not an answer but I do not have enough reputation to make a comment on your post)
To improve your hook you should check on $OPENSHIFT_REPO_DIR/vendor presence. If the $OPENSHIFT_DATA_DIR/vendor dir already exists your symlink won't be created.

# check vendor dir
if [ ! -d "$OPENSHIFT_DATA_DIR/vendor" ]; then
    mkdir $OPENSHIFT_DATA_DIR/vendor
    chmod -R 0777 $OPENSHIFT_DATA_DIR/vendor
fi

# check symlink
if [ ! -d "$OPENSHIFT_REPO_DIR/vendor" ]; then
    ln -s $OPENSHIFT_DATA_DIR/vendor $OPENSHIFT_REPO_DIR/vendor
fi
Timal
  • 31
  • 2