Code Monkey home page Code Monkey logo

tomcat-buildpack's Introduction


A buildpack for hosting static HTML websites on Cloud Foundry using apache

Using this buildpack as-is

##Detect phase : Ensure that your app's root folder has an index.html or index.htm or Default.htm file (which will be served as the default page).

##Compile phase :

a) compile build dir and compile cache dir are the two arguments for compile script.
		compile_build_dir: /tmp/staged/app
		compile_cache_dir: /tmp/cache
b) build pack scripts will be downloded to below folder.
		compile_buildpack_bin: /tmp/buildpacks/{build-pack-repository-name}/bin
		compile_buildpack_dir: /tmp/buildpacks/{build-pack-repository-name}
c) current working directory
		pwd: /tmp/staged

d) httpd-2.2.29.tar.gz has been downloaded and will be available in vendor folder in build-pack

e) creating public directory under cache directory (tmb/cache/public)

f)moving all the files from cache directory to public

g) creating .Procfile under public folder . refered few scripts are following this standard will review it later for the need basis) 
		PROC file systme acts as an interface to kernal, so user can treat it as a normal file to access,
but it only exists in memory, does not exist in the physical disk.

h) extract the httpd tar.

i)configure apache 
		from build diirectory  /tmp/staged/app/apache2
		--enable [mods-shared=all,http,deflate ,expires ,slotmem-shm, headers, rewrite, proxy, proxy-balancer, proxy-http, proxy-fcgi 
			,mime-magic,log-debug,with-mpm=event,with-included-apr]
		make and make install
j) change mode of installed apache directory (chmod -R uog+rx $compile_build_dir/apache2)
 
k) httpd.conf file will be available in build-pack config path
		a) here we have made Listen port as dynamic (<% = ENV["PORT] %>) this PORT will be generated by Droplet by the time of deployment.
l) this config file we are moving to apache2 directory
m) also boot.sh which need for release phase will be copied into current build directory.
		because of this folder structure we observed that during release phase all folders available in cache are available / copied 
		into APP_ROOT directory (/home/vcap/app) need to understand whether this is the inbuild behaviour of CF
n) for testing purpose we are copying our project index.html into htdocs of apache folder.

##Release phase :

	a) release phase will invoke the boot.sh	
	b) from boot.sh we are doing following things.
		1)will take the httpd.conf file from either apache2/conf or public/conf folder	
		2) we are using Ruby erb command for merging dynamic values and copied over to actuall httpd conf file.
			Ex : this time Listen <% = ENV["PORT] %>  ----> Listern 65343 (which has given from Droplet)
	c) now we need to invoke httpd using httpd.conf to start the apache.

##Risks / Issues : 1)need to fix the error while loading shared libraries: libaprutil-1.so.0 issue during start of apache 2)need to make ServerRoot , Document Root and Directory values of httpd.conf to APP_ROOT 3)need to create a log files under apache2/logs to make simple logs are happening. 4) need to listen whether apache running already then need to do the graceful start 5) instead of httpd invoke we can use apachectl 6) need to verify cache directory apache has beed used for further deployment of same application . it should not do the configure, make and make install every time.

##Run:

cf push simple-apache -b https://github.com/hmlingesh/apache-web-build-pack.git

build pack folder and files :

a) bin ( boot.sh , compile.sh, detect.sh and release.sh)
b) conf ( httpd.conf)
c) logs ( will be planning to copy some logs from buildpack to apache2  logs folder)
d) support( we are having heroku build pack for apache incase we are using heroku for buildpack {heroku-apache-buildpack})
	1) it has download , build , setup , cleanup functions for heroku)
		case "$1" in
		cleanup) buildpack_cleanup;;
		setup) buildpack_setup;;
		build) buildpack_build;;
		download) buildpack_download;;
		run) buildpack_cleanup && buildpack_download && buildpack_build && buildpack_setup;;
		esac
e) test - this folder contain sample static project which has index.html		
f) vendor ( httpd-2.2.29.tar.gz rather download we can use this )
g)Gemfile - has been used for heroku , rake and vulcan for heroku build pack setup will not be used now)
h) RakeFile - has the tasks for invoking heroku setup  -- will not used for cloudfoundry now)
	task :cleanup { sh "support/heroku-apache-buildpack cleanup" }
	task :build { sh "support/heroku-apache-buildpack build" }
	task :setup { sh "support/heroku-apache-buildpack setup" }
	task :download { sh "support/heroku-apache-buildpack download"}

Custom configuration files

You can customise the configuration by adding a httpd.conf to your root folder.

If the buildpack detects this file it will be used in place of the built-in httpd.conf, and run through the same erb processor. An example of the most basic httpd.conf (this is the one included in the build pack's conf directory):

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.