At first, I apologize; here it is a bit damp, although it works, and now it works "in flight", but without telephony, the possibilities are limited. The development option was basically described when the main directory $ OPENSHIFT_REPO_DIR (~ / app-root / repo) and you have a copy in your local repository, make edits, OpenShift is your sandbox.
But there is an installation option "for operation". It is mentioned at the end of the above article, but without details. In this case, you use $ OPENSHIFT_DATA_DIR (~ / app-root / data). The difference is that the local repository contains configuration scripts (action_hooks, see below) and data files, patches, etc. But not the application itself.
The mini-tutorial illustrates a number of OpenShift tricks. Working with github.com, git does not understand in detail, it is assumed that the reader already has an idea.
A step-by-step guide based on a real-world example.
Installation on any PaaS hosting (the same Redhat Openshift ) requires compliance with its specifications:
Registration: here
Client installation: here (you are already registered), the documentation is also there, but all English
Do not worry about the OS works almost everywhere the same. Yes, and your application, no matter how cool under RHEL 6.7.
They propose to create a domain (this is a subdomain of the 3rd level, your applications will have the address http://myapp-mydom.rhcloud.com ).
Openshift globally provides you with a user directory with a standard set of subdirectories: here . The feature of the engine is that in the home directory the configs of the installed software belong to root. Your name is such a long hash type (very docker reminds).
All necessary data is stored in the environment variables of the form OPENSHIFT_, reference book .
We have already done
$rhc setup
Notes:
The application SalesPlatform-6.4.0, self-installing LAMP.
CentOS 7.2 system (but the difference is in the details).
My example application, yours - at your discretion. (The name can contain only Latin letters and numbers).
my repository on github.com https://github.com/zirf0/example , look, if that.
Create a stub and clone it into your home directory.$rhc app create example php-5.3 mysql-5.5
$cd example
Openshift service directory
$ tree .openshift /
.openshift /
Actionββ action_hooks
β βββ README.md
Cββ cron
β ...
Markββ markers
β βββ README.md
Pearββ pear.txt
REββ README.md
Strictly speaking, we are interested in action_hooks . This is a set of scripts for various purposes, but for our example we use only build and deploy , in general, the names of the scripts correspond to the action performed. We will solve a simple problem:
Download the source to PaaS hosting.
Deploy them to ~ / app-root / data / current
Make changes (as a rule, it is necessary to replace the database access variables with embedded OpenShift).
Deploy the application.
Let's start
$ vi .openshift/action_hooks/build
And put it there
#!/bin/bash
# ~/app-root/data current
#
current_version_dir=${OPENSHIFT_DATA_DIR}current
# , .
[ -d "${current_version_dir}" ] && exit 0
#
install_version='6.4.0-201512'
# .
install_dir=${OPENSHIFT_BUILD_DEPENDENCIES_DIR}${install_version}
mkdir -p $install_dir
#
pushd ${install_dir} >/dev/null
# ( ).
curl -Ls downloads.sourceforge.net/project/salesplatform/salesplatform-vtigercrm-${install_version}.tar.gz > salesplatform-vtigercrm-${install_version}.tar.gz
#
tar --strip-components=1 -xzf salesplatform-vtigercrm-${install_version}.tar.gz
# , .
rm -rf salesplatform-vtigercrm-${install_version}.tar.gz
#
echo $install_version > ${OPENSHIFT_BUILD_DEPENDENCIES_DIR}.current_version
# .
popd >/dev/null
$ vi .openshift/action_hooks/deploy
In the script, a patch is applied (the same substitution of the environment variables for connecting to the MySQL DBMS) and the installation .htaccess is added. You can have your own, that is, for example, take ready .
#!/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.
dest_dir=${OPENSHIFT_DATA_DIR}current
current_version=$(cat ${OPENSHIFT_BUILD_DEPENDENCIES_DIR}.current_version)
install_dir=${OPENSHIFT_BUILD_DEPENDENCIES_DIR}${current_version}
if [ ! -d "${dest_dir}" ]; then
mkdir -p $dest_dir
cp -rf ${install_dir}/* ${dest_dir}/
fi
# ~/app-root/repo/php ( php) .
if [ -d ${OPENSHIFT_REPO_DIR}php ]; then
rm -rf ${OPENSHIFT_REPO_DIR}php
fi
ln -sf ${dest_dir} ${OPENSHIFT_REPO_DIR}php
# .htaccess .openshift/config
if [ -f ${OPENSHIFT_REPO_DIR}.openshift/config/.htaccess ]; then
cp -f ${OPENSHIFT_REPO_DIR}.openshift/config/.htaccess ${dest_dir}/.htaccess
fi
set -e
# .
patch ${dest_dir}/modules/Install/views/Index.php ${OPENSHIFT_REPO_DIR}.openshift/config/patches/db_conf.patch
Go ahead. Create a repository on github.com.
In our catalog:$git rm index.php
$vi README.md
Naturally, the file needs to be filled, there is nothing worse than the repository, where the donut hole is in the most visible place.git add .
git commit -m "Initialize"
Add github.com to remote repositories (of course the URL will be yours):$git remote add upstream ssh://git@github.com/zirf0/example.git
We already have the ssh key ~ / .ssh / id_rsa.pub. Add it according to the instructions on github.com.
Fill our works on github.com$git push upstream master
Deploy the application to PaaS Openshift:$git push
Which is equivalent to $ git push origin master .
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 339 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Stopping PHP 5.3 cartridge (Apache+mod_php)
remote: Stopping MySQL 5.5 cartridge
remote: Building git ref 'master', commit 38fe1a5
remote: Checking .openshift/pear.txt for PEAR dependency...
remote: Preparing build for deployment
remote: Deployment id is b4269d37
remote: Activating deployment
remote: Starting MySQL 5.5 cartridge
remote: patching file /var/lib/openshift/56c4641789f5cfbebb000031/app-root/data/current/modules/Install/views/Index.php
remote: Hunk #1 succeeded at 98 with fuzz 1.
remote: Starting PHP 5.3 cartridge (Apache+mod_php)
remote: Application directory "php/" selected as DocumentRoot
remote: -------------------------
remote: Git Post-Receive Result: success
remote: Activation status: success
remote: Deployment completed with status: success
To ssh://56c4641789f5cfbebb000031@example-helidon.rhcloud.com/~/git/example.git/
f5b094a..38fe1a5 master -> master
All through the web installation should start.
Wishes, suggestions?
Source: https://habr.com/ru/post/277445/
All Articles