Permalink
Browse files

add nginx

  • Loading branch information...
friism committed Aug 4, 2013
1 parent f9dc3e4 commit 196f711852b40ad862010a4680c7aba6f1b5d83a
Showing with 182 additions and 21 deletions.
  1. +40 −19 bin/compile
  2. +1 −2 bin/release
  3. +29 −0 nginx/fastcgi_params
  4. +75 −0 nginx/mime.types
  5. +28 −0 nginx/nginx.conf.erb
  6. +9 −0 nginx/start
View
@@ -9,6 +9,7 @@ DEPENDENCY_S3_BUCKET_PATH="http://s3.amazonaws.com/mono-dependencies"
# config
MONO_VERSION="3.2.0"
XSP_VERSION="3.0.11"
NGINX_VERSION="1.5.2"
# s3 packages
MONO_PACKAGE_URL="${DEPENDENCY_S3_BUCKET_PATH}/mono-${MONO_VERSION}.tar.gz"
@@ -66,37 +67,57 @@ cp -r "${XSP_CACHE_LOCATION}/xsp" .
# find a solution file
SLN=$(find . -maxdepth 1 -iname "*.sln")
if [ $( echo "${SLN}" | wc -l ) -gt 1 ]; then
echo "-----> Too many *.sln files"
echo "-----> Too many *.sln files"
exit 1
fi
if [ "${SLN}" == "" ]; then
echo "-----> No *.sln file found"
exit 1
fi
# compile an uploaded application
if [ "${SLN}" != "" ]; then
echo "-----> Compiling Mono application"
echo "-----> Compiling Mono application"
export PATH="/app/mono/bin:${PATH}"
export LD_LIBRARY_PATH="/app/mono/lib:${LD_LIBRARY_PATH}"
# Add certs to trust store
cp -r ${LP_DIR}/.config ~/.
cp -r ${LP_DIR}/.config ${BUILD_DIR}/.
export PATH="/app/mono/bin:${PATH}"
export LD_LIBRARY_PATH="/app/mono/lib:${LD_LIBRARY_PATH}"
# Find all NuGet target files and overwrite with know good version
find `pwd` -name "NuGet.targets" -exec cp -f ${CACHE_DIR}/NuGet.targets {} \;
# Add certs to trust store
cp -r ${LP_DIR}/.config ~/.
cp -r ${LP_DIR}/.config ${BUILD_DIR}/.
# Add symbolic link to deal with NuGet casing breakage
find `pwd` -name "NuGet.targets" -exec dirname {} \; | xargs -I {} ln -s {}/NuGet.targets {}/nuget.targets
# Find all NuGet target files and overwrite with know good version
find `pwd` -name "NuGet.targets" -exec cp -f ${CACHE_DIR}/NuGet.targets {} \;
BUILD_CACHE_LOCATION=${CACHE_DIR}/build/
mkdir -p ${BUILD_CACHE_LOCATION}
# Add symbolic link to deal with NuGet casing breakage
find `pwd` -name "NuGet.targets" -exec dirname {} \; | xargs -I {} ln -s {}/NuGet.targets {}/nuget.targets
# Build
EnableNuGetPackageRestore=true xbuild /property:Configuration=Release /property:OutDir=${BUILD_CACHE_LOCATION} ${SLN}
BUILD_CACHE_LOCATION=${CACHE_DIR}/build/
mkdir -p ${BUILD_CACHE_LOCATION}
cp -r ${BUILD_CACHE_LOCATION}* ${BUILD_DIR}
# Build
EnableNuGetPackageRestore=true xbuild /property:Configuration=Release /property:OutDir=${BUILD_CACHE_LOCATION} ${SLN}
mkdir -p ${BUILD_DIR}/.profile.d
cp -n ${LP_DIR}/.profile.d/* ${BUILD_DIR}/.profile.d/
cp -r ${BUILD_CACHE_LOCATION}* ${BUILD_DIR}
if [ -d "$BUILD_DIR/_PublishedWebsites/" ]; then
echo "Website detected"
NGINX_PACKAGE_URL="${DEPENDENCY_S3_BUCKET_PATH}/nginx-${NGINX_VERSION}.tar.gz"
NGINX_CACHE_LOCATION=${CACHE_DIR}/nginx-{NGINX_VERSION}
if [ ! -d "${NGINX_CACHE_LOCATION}" ]; then
echo "Fetching ${NGINX_VERSION} @ ${NGINX_PACKAGE_URL}"
mkdir -p ${NGINX_CACHE_LOCATION}
cd ${NGINX_CACHE_LOCATION}
curl ${NGINX_PACKAGE_URL} -s | tar xz
cd ${BUILD_DIR}
fi
mkdir -p ${BUILD_DIR}/.profile.d
cp -n ${LP_DIR}/.profile.d/* ${BUILD_DIR}/.profile.d/
mkdir -p ${BUILD_DIR}/nginx
cp ${NGINX_CACHE_LOCATION}/nginx ${BUILD_DIR}/nginx/.
cp ${LP_DIR}/nginx/* ${BUILD_DIR}/nginx/.
fi
echo "-----> Build SUCCESS"
View
@@ -9,9 +9,8 @@ cat <<EOF
EOF
if [ -d "$BUILD_DIR/_PublishedWebsites/" ]; then
# use first dir in _PublishedWebsites
cat <<EOF
default_process_types:
web: /app/xsp/bin/xsp4 --nonstop --port \$PORT --root "/app/_PublishedWebsites/`ls $BUILD_DIR/_PublishedWebsites/ | head -1`"
web: /app/nginx/start
EOF
fi
View
@@ -0,0 +1,29 @@
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
# fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
#fastcgi_param HTTPS $https;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
# Added by friism
fastcgi_param PATH_INFO "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
View
@@ -0,0 +1,75 @@
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/x-javascript js;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/svg+xml svg;
application/java-archive jar war ear;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.ms-excel xls;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/zip zip;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream eot;
application/octet-stream iso img;
application/octet-stream msi msp msm;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mpeg mpeg mpg;
video/quicktime mov;
video/x-flv flv;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}
View
@@ -0,0 +1,28 @@
worker_processes 4;
daemon off;
events {
worker_connections 1024;
}
http {
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
error_log /app/nginx/logs/error.log notice;
access_log /app/nginx/logs/access.log;
include mime.types;
server {
listen <%= ENV['PORT'] %>;
location / {
fastcgi_pass unix:/tmp/nginx.socket;
include fastcgi_params;
}
}
}
View
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
erb /app/nginx/nginx.conf.erb > /app/nginx/nginx.conf
mkdir -p /app/nginx/logs
touch /app/nginx/logs/access.log /app/nginx/logs/error.log
(tail -f -n 0 /app/nginx/logs/*.log &)
/app/xsp/bin/fastcgi-mono-server4 /applications=/:/app/_PublishedWebsites/`ls /app/_PublishedWebsites/ | head -1` /socket=unix:/tmp/nginx.socket &
/app/nginx/nginx -p /app/nginx -c /app/nginx/nginx.conf

0 comments on commit 196f711

Please sign in to comment.