Skip to content

[WIP] Migration to OpenShift v3 hosting #7468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ dev_guide/builds/images/chained-build.png
dev_guide/builds/images/chained-build.png.cache
.DS_Store
.venv
.gem
bin
commercial_package
65 changes: 65 additions & 0 deletions .s2i/bin/assemble
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash -e
# The assemble script builds the application artifacts from source and
# places them into appropriate directories inside the image.

# `gem install` is required because `bundle install` does not properly place `asciibinder` into $PATH
echo "---> Installing AsciiBinder ..."
gem install ascii_binder

# Move git repository to local working directory
shopt -s dotglob
echo "---> Installing application source ..."
mv /tmp/src/* ./

# Fetch and locally add all remote branches to ensure AsciiBinder is able to build the necessary branches
echo "---> Fetching remote branches"
# Because the s2i builder only makes the remote branch applicable to the specified branch,
# it's necessary to enforce a * ref so that all branches are referenced
sed -i 's%fetch = +refs.*%fetch = +refs/heads/*:refs/remotes/origin/*%' .git/config
git fetch --all --quiet
for remote in $(git branch -r | egrep -v "(>|$(git rev-parse --abbrev-ref HEAD))|master"); do git checkout --track $remote; done
git checkout master

# Fixes incompatible character encodings: US-ASCII and UTF-8 error
export LANG="en_US.UTF-8"

echo "---> AsciiBinder packaging commercial content ..."
# AsciiBinder uses git to some extent and requires `user.email` to be properly set
git config user.email "[email protected]"
# Properly package assets
asciibinder package --site=commercial
mkdir commercial_package
mv _package/commercial commercial_package
git checkout master
mkdir commercial_package/commercial/httpd-cfg
mv .s2i/httpd-cfg/01-commercial.conf commercial_package/commercial/httpd-cfg
mv 404-commercial.html commercial_package/commercial/404.html

echo "---> Installing Minishift content ..."
mkdir minishift
cd minishift
if wget http://artifacts.ci.centos.org/minishift/minishift/docs/latest/minishift-adoc.tar ; then
tar -xvf minishift-adoc.tar --strip 1
cat _topic_map.yml >> ../_topic_map.yml
rm minishift-adoc.tar
cd ..
git add .
git commit -am "Minishift build-time commit"
else
echo "WARNING: Could not retrieve minishift-adoc.tar"
cd ..
rmdir minishift
fi

echo "---> AsciiBinder packaging community content ..."
asciibinder package --site=community
mkdir community_package
mv _package/community community_package
git checkout master
mkdir community_package/community/httpd-cfg
mv .s2i/httpd-cfg/01-community.conf community_package/community/httpd-cfg
mv 404-community.html community_package/community/404.html

# Fix source directory permissions
echo "---> Fixing permissions ..."
fix-permissions ./
270 changes: 270 additions & 0 deletions .s2i/httpd-cfg/01-commercial.conf

Large diffs are not rendered by default.

215 changes: 215 additions & 0 deletions .s2i/httpd-cfg/01-community.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
# ----------------------------------------------------------------------
# Better website experience for IE users
# ----------------------------------------------------------------------

# Force the latest IE version, in various cases when it may fall back to IE7 mode
# github.com/rails/rails/commit/123eb25#commitcomment-118920
# Use ChromeFrame if it's installed for a better experience for the poor IE folk

<IfModule mod_headers.c>
Header set X-UA-Compatible "IE=Edge,chrome=1"
# mod_headers can't match by content-type, but we don't want to send this header on *everything*...
<FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|woff2|ico|webp|appcache|manifest|htc|crx|oex|xpi|safariextz|vcf)$" >
Header unset X-UA-Compatible
</FilesMatch>
</IfModule>

# ----------------------------------------------------------------------
# Proper MIME type for all files
# ----------------------------------------------------------------------

# JavaScript
# Normalize to standard type (it's sniffed in IE anyways)
# tools.ietf.org/html/rfc4329#section-7.2
AddType application/javascript js jsonp
AddType application/json json

# Audio
AddType audio/ogg oga ogg
AddType audio/mp4 m4a f4a f4b

# Video
AddType video/ogg ogv
AddType video/mp4 mp4 m4v f4v f4p
AddType video/webm webm
AddType video/x-flv flv

# SVG
# Required for svg webfonts on iPad
# twitter.com/FontSquirrel/status/14855840545
AddType image/svg+xml svg svgz
AddEncoding gzip svgz

# Webfonts
AddType application/vnd.ms-fontobject eot
AddType application/x-font-ttf ttf ttc
AddType font/opentype otf
AddType application/x-font-woff woff
AddType application/font-woff2 woff2

# Assorted types
AddType image/x-icon ico
AddType image/webp webp
AddType text/cache-manifest appcache manifest
AddType text/x-component htc
AddType application/xml rss atom xml rdf
AddType application/x-chrome-extension crx
AddType application/x-opera-extension oex
AddType application/x-xpinstall xpi
AddType application/octet-stream safariextz
AddType application/x-web-app-manifest+json webapp
AddType text/x-vcard vcf
AddType application/x-shockwave-flash swf
AddType text/vtt vtt


# ----------------------------------------------------------------------
# Gzip compression
# ----------------------------------------------------------------------

<IfModule mod_deflate.c>
# Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>

# Compress all output labeled with one of the following MIME-types
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
application/json \
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
application/xhtml+xml \
application/xml \
font/opentype \
image/svg+xml \
image/x-icon \
text/css \
text/html \
text/plain \
text/x-component \
text/xml
</IfModule>
</IfModule>

# ----------------------------------------------------------------------
# Start rewrite engine
# ----------------------------------------------------------------------

# Turning on the rewrite engine is necessary for the following rules and
# features. FollowSymLinks must be enabled for this to work.

# Some cloud hosting services require RewriteBase to be set: goo.gl/HOcPN
# If using the h5bp in a subdirectory, use `RewriteBase /foo` instead where
# 'foo' is your directory.

# If your web host doesn't allow the FollowSymlinks option, you may need to
# comment it out and use `Options +SymLinksOfOwnerMatch`, but be aware of the
# performance impact: http://goo.gl/Mluzd

<IfModule mod_rewrite.c>
<Directory "${HOME}">

Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from All

RewriteEngine On
RewriteBase /

# Redirects for "latest" version
RewriteRule ^origin-m4/?$ /latest/ [R=301]

# Welcome page redirects
RewriteRule ^(latest|[0-9.]+)/?$ /$1/welcome/index.html [L,R=301]

# Overview page has moved to Index page
RewriteRule ^(.*)/overview\.html(.*)$ /$1/index.html$2 [L,R=301]

# Developers console redirect
RewriteRule ^(latest|[0-9.]+)/getting_started/developers/developers_console\.html(.*)$ /$1/getting_started/developers_console.html$2 [L,R=301]

# Deployments redirect
RewriteRule ^(latest|[0-9.]+)/dev_guide/deployments\.html(.*)$ /$1/dev_guide/deployments/how_deployments_work.html$2 [L,R=301]

# Builds redirect
RewriteRule ^(latest|[0-9.]+)/dev_guide/builds\.html(.*)$ /$1/dev_guide/builds/index.html$2 [L,R=301]

# Other specific redirects
RewriteRule ^latest/admin_guide/build_defaults_overrides\.html(.*)$ /latest/install_config/build_defaults_overrides.html$1 [L,R=301]
RewriteRule ^latest/admin_guide/install/(advanced_install|deploy_router|docker_registry|first_steps|overview|prerequisites|quick_install|upgrades)\.html(.*)$ /latest/install_config/install/$1.html$2 [R=301]
RewriteRule ^(latest|[0-9.]+)/admin_guide/upgrades\.html(.*) /$1/install_config/upgrades.html$2 [R=301]
RewriteRule ^(latest|[0-9.]+)/admin_guide/(aggregate_logging|cluster_metrics|configuring_authentication|configuring_aws|configuring_gce|configuring_openstack|http_proxies|master_node_configuration|native_container_routing|routing_from_edge_lb|syncing_groups_with_ldap|web_console_customization)\.html(.*)$ /$1/install_config/$2.html$3 [R=301]
RewriteRule ^(latest|[0-9.]+)/admin_guide/persistent_storage/(persistent_storage_aws|persistent_storage_cinder|persistent_storage_gce|persistent_storage_glusterfs|persistent_storage_nfs)\.html(.*)$ /$1/install_config/persistent_storage/$2.html$3 [R=301]
RewriteRule ^latest/admin_guide/selfprovisioned_projects\.html(.*)$ /$1/$2/admin_guide/managing_projects.html$3 [R=301]
RewriteRule ^latest/install_config/upgrades\.html(.*)$ /latest/install_config/upgrading/index.html$1 [R=301]

</Directory>
</IfModule>

# ----------------------------------------------------------------------
# Prevent 404 errors for non-existing redirected folders
# ----------------------------------------------------------------------

# without -MultiViews, Apache will give a 404 for a rewrite if a folder of the
# same name does not exist.
# webmasterworld.com/apache/3808792.htm

Options -MultiViews

# ----------------------------------------------------------------------
# Custom 404 page
# ----------------------------------------------------------------------

# You can add custom pages to handle 500 or 403 pretty easily, if you like.
# If you are hosting your site in subdirectory, adjust this accordingly
# e.g. ErrorDocument 404 /subdir/404.html
ErrorDocument 404 /404.html


# ----------------------------------------------------------------------
# UTF-8 encoding
# ----------------------------------------------------------------------

# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset utf-8

# Force UTF-8 for a number of file formats
AddCharset utf-8 .atom .css .js .json .rss .vtt .xml


# ----------------------------------------------------------------------
# A little more security
# ----------------------------------------------------------------------

# "-Indexes" will have Apache block users from browsing folders without a
# default document Usually you should leave this activated, because you
# shouldn't allow everybody to surf through every folder on your server (which
# includes rather private places like CMS system folders).
<IfModule mod_autoindex.c>
Options -Indexes
</IfModule>

# Block access to "hidden" directories or files whose names begin with a
# period. This includes directories used by version control systems such as
# Subversion or Git.
<IfModule mod_rewrite.c>
RewriteCond %{SCRIPT_FILENAME} -d [OR]
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule "(^|/)\." - [F]
</IfModule>

# Block access to backup and source files. These files may be left by some
# text/html editors and pose a great security danger, when anyone can access
# them.
<FilesMatch "(\.(bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
Loading