Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run git add and commit on Openshift Server

Tags:

git

openshift

I'm working with a platform that creates a configuration.php file as part of the instillation process. Right now, the installation process is run as part of the build hook on the server. The problem is that because its being created on the server, after every push, it has to rerun the instillation process. This overwrites a lot of the changes.

Is there a way to run git add and git commit on the server? If I can add the configuration.php file to the repo and git pull it down, then the instillation process won't continue to run. If so, what directory should I run the commands in?

I've tried SSHing onto the server and running the git commands, but only receive the error fatal: Not a git repository (or any parent up to mount point /var/lib/openshift) no matter what directory I try.

like image 832
NicholasJohn16 Avatar asked Dec 29 '13 17:12

NicholasJohn16


1 Answers

If I understand correctly, your problem is that once you push your commits to the OpenShift repo, the OpenShift server automatically starts a fresh installation and you loose all your configurations and data?

This is OpenShift's way of enforcing a correct deployment process. You shouldn't try to bypass it; rather, you should adapt your installation to it. If your deployment process can work well with OpenShift, you can easily deploy multiple environments and keep them up-to-date, which can be a life-saver once you hit production.

I also faced this problem, and this is what I did:

The key is the app-root/data folder. This folder does not get deleted when you push, so you can use it to store data files that shouldn't change when you deploy. I also used it to store my configuration files. I put the configuration files in the .gitignore, so they don't get checked out into the OpenShift repo. Then, I used the build hook (though maybe I should have used pre_build...) to copy those files from the data folder to their true location, before I started building.

What you need to remember is that every file needed for the build should be either versioned by git, copied from data, downloaded from the internet (by a dependency manager or by wget \ curl) or created during the build process. You can't have files that just stay there (like you have in the local working copy on your development machine), so if you have a file that isn't versioned and isn't created during the build process - make sure you set a hook to download it or copy it from data.

If you need a reference, you can take a peek at my project. The relevant parts are the action hooks and this instructions document.

like image 171
Idan Arye Avatar answered Oct 06 '22 21:10

Idan Arye