Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Commit

Permalink
Add dev repo builder (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
imkitae authored and namenu committed Apr 14, 2017
1 parent 07d061d commit ab3121c
Show file tree
Hide file tree
Showing 8 changed files with 301 additions and 0 deletions.
136 changes: 136 additions & 0 deletions dev/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

#########################
# ip exception
#########################

#RewriteCond %{HTTP_HOST} !^mail.ridibooks.com [NC]
RewriteCond %{REMOTE_ADDR} !111\.111\.111\.111
RewriteCond %{REMOTE_ADDR} !222\.222\.222\.222

# RidiStory IP for OAuth Testing
RewriteCond %{REMOTE_ADDR} !111\.111\.111\.111
RewriteCond %{REMOTE_ADDR} !222\.222\.222\.222

RewriteRule (.*) http://ridibooks.com [L,R]

#########################
# git route

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteCond %{HTTP_HOST} ^git\.([a-z0-9_]+)\.dev\.ridi\.io [NC]
RewriteRule (.*) dev.php?repo=%1&git=$1%{QUERY_STRING} [L]

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteCond %{HTTP_HOST} ^git\.([a-z0-9_]+)\.([a-z0-9_]+)\.dev\.ridi\.io [NC]
RewriteRule (.*) dev.php?repo=%2/%1&git=$1%{QUERY_STRING} [L]

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteCond %{HTTP_HOST} ^git\.([a-z0-9_]+)\.([a-z0-9_]+)\.([a-z0-9_]+)\.dev\.ridi\.io [NC]
RewriteRule (.*) dev.php?repo=%3/%2/%1&git=$1%{QUERY_STRING} [L]

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteCond %{HTTP_HOST} ^build\.([a-z0-9_]+)\.dev\.ridi\.io [NC]
RewriteCond %{DOCUMENT_ROOT}/repo/%1 !-d
RewriteRule (.*) dev.php?repo=%1&build=true [L]

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteCond %{HTTP_HOST} ^make\.([a-z0-9_]+)\.dev\.ridi\.io [NC]
RewriteRule (.*) dev.php?repo=%1&make=true&make_command=$1%{QUERY_STRING} [L]

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteCond %{HTTP_HOST} ^make\.([a-z0-9_]+).([a-z0-9_]+)\.dev\.ridi\.io [NC]
RewriteRule (.*) dev.php?repo=%2/%1&make=true&make_command=$1%{QUERY_STRING} [L]

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteCond %{HTTP_HOST} ^make\.([a-z0-9_]+).([a-z0-9_]+).([a-z0-9_]+)\.dev\.ridi\.io [NC]
RewriteRule (.*) dev.php?repo=%3/%2/%1&make=true&make_command=$1%{QUERY_STRING} [L]

#########################
# api route

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteCond %{HTTP_HOST} ^api\.([a-z0-9_]+)\.dev\.ridi\.io [NC]
RewriteRule (.*) http://127.0.0.1:8888/$0 [P]

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteCond %{HTTP_HOST} ^([a-z0-9_]+)\.dev\.ridi\.io [NC]
RewriteCond %{REQUEST_URI} ^/noti/(.*) [NC]
RewriteRule ^noti/(.*)$ http://127.0.0.1:8888/$1 [P]

#########################

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteCond %{HTTP_HOST} ^ezwel\.([a-z0-9_]+)\.dev\.ridi\.io [OR]
RewriteCond %{HTTP_HOST} ^([a-z0-9_]+)\.dev\.ridi\.io [NC]
RewriteRule (.*) repo/%1/ridibooks/$0 [L]

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteCond %{HTTP_HOST} ^cp\.([a-z0-9_]+)\.dev\.ridi\.io [NC]
RewriteRule (.*) repo/%1/platform/cp/web/$0 [L]

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteCond %{HTTP_HOST} ^admin\.([a-z0-9_]+)\.dev\.ridi\.io [NC]
RewriteRule ^store-operation/.* repo/%1/admin/$0 [L]

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteCond %{HTTP_HOST} ^admin\.([a-z0-9_]+)\.dev\.ridi\.io [NC]
RewriteRule ^cs/.* repo/%1/admin/$0 [L]

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteCond %{HTTP_HOST} ^admin\.([a-z0-9_]+)\.dev\.ridi\.io [NC]
RewriteRule ^admin/.* repo/%1/platform/$0 [L]

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteCond %{HTTP_HOST} ^admin\.([a-z0-9_]+)\.dev\.ridi\.io [NC]
RewriteRule ^(bi|stat)/.* repo/%1/da/cms/$0 [L]

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteCond %{HTTP_HOST} ^admin\.([a-z0-9_]+)\.dev\.ridi\.io [NC]
RewriteRule (.*) repo/%1/platform/cms/$0 [L]

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteCond %{HTTP_HOST} ^([a-z0-9_]+)\.([a-z0-9_]+)\.dev\.ridi\.io [NC]
RewriteRule (.*) repo/%2/%1/$0 [L]

RewriteCond %{REQUEST_URI} !^/?repo/
RewriteCond %{REQUEST_URI} !^/?dev\.php
RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteRule (.*) http://ridibooks.com [L]
</IfModule>
34 changes: 34 additions & 0 deletions dev/config.local.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
class Config extends ConfigDefault
{
static $DB_HOST = "<DB_HOST>";
static $DB_USER = "<DB_USER>";
static $DB_PASSWD = "<DB_PASSWD>";
static $DB_NAME = "<DB_NAME>";

static $DOMAIN = "TODO.dev.ridi.io";
static $MISC_URL = "http://misc.ridibooks.com";
static $ACTIVE_URL = "http://active.ridibooks.com";

static $SHOP_URL = "shop.dev.ridi.io";

static $ENABLE_SSL = false;

static $MEMCACHE_ENABLE = false;
static $SESSION_USE_MEMCACHE = false;
static $COUCHBASE_ENABLE = false;

static $CMS_RPC_URL = 'http://localhost:8000';

// ridi.io
static $FACEBOOK_ID = '<FACEBOOK_ID>';
static $FACEBOOK_SECRET_ID = '<FACEBOOK_SECRET_ID>';

static $UNDER_DEV = true;
static $ORM_IS_DEV_MODE = true;

static $API_SERVER_URL = "http://api.TODO.dev.ridi.io";
static $API_SERVER_URL_PROXY = "http://TODO.dev.ridi.io/noti";
static $API_SERVER_URL_ADMIN = "http://api.TODO.dev.ridi.io";
}

9 changes: 9 additions & 0 deletions dev/dev-build-cli.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

$repo = 'kk';
chdir(dirname(__FILE__));

passthru("git clone <GIT-REPO> repo/{$repo} 2>&1");
exec("sed 's/TODO/{$repo}/' config.local.php > repo/{$repo}/include/config.local.php");

exec("cp post-checkout repo/{$repo}/.git/hooks");
60 changes: 60 additions & 0 deletions dev/dev.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="ko" xml:lang="ko">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<pre><xmp><?php

ob_implicit_flush(true);
ob_end_flush();

$repo = $_GET['repo'];
$repo = preg_replace("/[^\w_\/]/", "", $repo);

$git = $_GET['git'];
$git = preg_replace("/[^\w \/\\\.\-_\"\[\],]/s", "", $git);
$git = str_replace('\\"', '"', $git);

$make_command = $_GET['make_command'];
$make_command = preg_replace("/[^\w_\-\/]/", "", $make_command);

chdir(__DIR__);

if (strlen($repo)) {
if( $_GET['make']) {
chdir(__DIR__."/repo/{$repo}");
passthru("COMPOSER_HOME='".__DIR__."/repo' make " . $make_command . " 2>&1");
# chdir(__DIR__."/repo/{$repo}");
# chdir("platform/");
# passthru("COMPOSER_HOME='".__DIR__."/repo' make 2>&1");
}
if( $_GET['build']) {
passthru("git clone <GIT-REPO1> repo/{$repo} 2>&1");
passthru("git clone <GIT-REPO2> repo/{$repo} 2>&1");
exec("sed 's/TODO/{$repo}/' config.local.php > repo/{$repo}/include/config.local.php");

exec("cp post-checkout repo/{$repo}/.git/hooks");

chdir("repo/{$repo}");
exec("git submodule init");
exec("git submodule update");
exec("git pull");
}

if (strlen($git)) {
if ($repo == 'shop') {
chdir(__DIR__ . "/../shop");
passthru("hg {$git} 2>&1");
exec("chmod g+w -R .");
} else {
chdir(__DIR__ . "/repo/{$repo}");
passthru("git {$git} 2>&1");
exec("chmod g+w -R .");
}
}
}
?>
</xmp></pre>
</body>
</html>

21 changes: 21 additions & 0 deletions dev/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python

import sys, os, re, subprocess

os.environ["COMPOSER_HOME"] = "/htdocs/dev/repo/.composer"

previous_head = sys.argv[1]
new_head = sys.argv[2]
is_branch_checkout = sys.argv[3]

if is_branch_checkout == "0":
sys.exit(0)

# composer install
if not subprocess.call(['composer', 'install', '--no-dev']):
print "composer install completed!"

# bower install
if not subprocess.call(['bower', 'install', '-p', '--allow-root'], cwd='static/books'):
print "bower install completed!"

2 changes: 2 additions & 0 deletions dev/repo/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# 하위 url 이 접속이 되지 않아 주석처리(blu, 2017/2/3)
# Deny from all
3 changes: 3 additions & 0 deletions dev/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
User-agent: *
Disallow: /

36 changes: 36 additions & 0 deletions dev/ssl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

$repo = 'ssl';//$_GET['repo'];
$repo = preg_replace("/[^\w_]/", "", $repo);

$hg = $_GET['hg'];
$hg = preg_replace("/[^\w \/\\\.\-_\"\[\],]/s", "", $hg);
$hg = str_replace('\\"', '"', $hg);

chdir(dirname(__FILE__));
#var_dump($_GET);
if(strlen($repo))
{
if(true)
{
passthru("hg clone <MERCURIAL-REPO> repo/{$repo}");
chdir(__DIR__ . "/repo/{$repo}");
passthru("hg update");
file_put_contents(".hg/hgrc", "[paths]\ndefault = <MERCURIAL-REPO>");

exec('cp shop/config.sample.php shop/config.php');
exec('cp shop/application/config/config.sample.php shop/application/config/config.php');
exec('cp shop/application/config/ridishop.sample.php shop/application/config/ridishop.php');
exec('cp ridibooks/v2/config.sample.php ridibooks/v2/config.php');
}
if(strlen($hg))
{
chdir(__DIR__ . "/repo/{$repo}");
passthru("hg {$hg} 2>&1");
}
}
?>
</xmp></pre>
</body>
</html>

0 comments on commit ab3121c

Please sign in to comment.