Hide menu

TDDD27 Advanced Web Programming (6 ECTS)

Vt2

Since spring 2015 IDA has an OpenShift server running at openshift.ida.liu.se. You can access that and create web servers using the Gear containers. To do this you can work at IDA where rhc is already installed or download and use the OpenShift RHC tool. OpenShift at IDA doesn't have a web interface. It's command-line-only via RHC using your student liu-id.

Look into the basic overview to get into what OpenShift is. You need the terminology to use the RHC client program well.

Once you have rhc, you need to run rhc setup to hook into OpenShift at IDA. Use rhc setup --help to figure out how to end up at openshift.ida.liu.se.

rhc --help . --help you can attach to any rhc command to get the documentation. Also, use rhc --tail to watch what happens with apps you are running.

On OpenShift applications are run on gears. Read about gears for applications that OpenShift can then start and stop when you push new code to OpenShift. This can be cone manually or using start projects on GitHub such as for flask. Read first, do later ...

Once you've created that application it will be cloned to the location in your local computer you are using so make sure you are in the terminal at the right location on your computer. Of course, you can also clone from OpenShift using the Git URL your repo has. You find that using rhc apps.

Once you have your local git repo from your OpenShift origin, you also need to add a second remote URL for your gitlab repo. Create a new project on gitlab.ida.liu.se and add a second remote to be able to push both to OpenShift and to gitlab when developing. The idea is that you should push working things to OpenShift and things under development to gitlab.ida.liu.se.

OpenShift, like all containers and webservers, have ideas about how things should be done that is different and more secure and efficient than localhost. Folders to store persistent data, how to communicate with databases, how to install systems you depend on and so forth. In 2015 a lot of students had problems connecting to databses becasue they didn't understand that Opeshift has internal ports and external prots. This means connecting to a database on the Openshift server worsk fine, but connecting to the same machine in the same way from localhost is not possible. This means you should run different databases locally and on OpenShift, which is good practice anyway. You can test for the availability of environmental variables that are set on OpenShift like in this pythoncode for flask like this.

 
	
if 'OPENSHIFT_POSTGRESQL_DB_URL' in os.environ:
    app.config['SQLALCHEMY_DATABASE_URI'] =os.environ['OPENSHIFT_POSTGRESQL_DB_URL']
else:
    app.config['SQLALCHEMY_DATABASE_URI'] ="sqlite:///tmp/testdb.db"

Read more on hooking the database here.


Finally, a reminder that you have more options to work wit if you like than openshift.ida.liu.se. What I want is, however, also that you not just get it to work but learn about what it is, what it provides for development.


Page responsible: Erik Berglund
Last updated: 2016-04-07