Skip to content

Commit

Permalink
add .fcignore and filter unused files
Browse files Browse the repository at this point in the history
  • Loading branch information
lowkeyrd committed Dec 3, 2021
2 parents d835bef + 1a10a71 commit 30e7263
Show file tree
Hide file tree
Showing 20,537 changed files with 2,955,670 additions and 26 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,10 @@ dmypy.json
c
.s
node_modules

web-framework/php/laravel/src/code/root

!web-framework/php/wordpress/src/code/root/*
!web-framework/php/wordpress/src/code/root/usr/*
!web-framework/php/zblog/src/code/root/*
!web-framework/php/zblog/src/code/root/usr/*
28 changes: 15 additions & 13 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Web Framework应用案例

![图片alt](https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1638188430695_20211129122031251935.png)

将一个传统框架部署到阿里云Serverless平台的方法有很多,可以选择Custom、Custom Container以及原生编程语言的运行时。这其中Custom和原生语言运行时方案,除了启动命令/入口函数不同之外,区别并不是很大,可以根据自己需求进行实现,Custom Container方案相对来说更简单,但是镜像的冷启动速度相对Custom和原生语言运行时比较慢。

目前本案例仓库收录以下常见框架的部署案例:
Expand All @@ -18,7 +20,7 @@
<td align="center">1</td>
<td align="center">:fire:<a href="./web-framework/nodejs/express/src">Express [custom]</a></td>
<td align="center">:fire::fire:<a href="./web-framework/python/flask/src">Flask [python3]</a></td>
<td align="center"><a href="./web-framework/php/thinkphp/src">Think PHP</a></td>
<td align="center"><a href="./web-framework/php/thinkphp/src">Think PHP [custom]</a></td>
<td align="center">BeeGo</td>
<td align="center">Tomcat/Jetty</td>
<td align="center">Gatsby</td>
Expand All @@ -27,70 +29,70 @@
<td align="center">2</td>
<td align="center"><a href="./web-framework/nodejs/egg/src">Egg [custom]</a></td>
<td align="center"><a href="./web-framework/python/tornado/src">Tornado [custom]</a></td>
<td align="center"><a href="./web-framework/php/laravel/src">laravel</a></td>
<td align="center"><a href="./web-framework/php/laravel/src">laravel [custom]</a></td>
<td align="center">Gin</td>
<td align="center"><a href="./web-framework/java/springboot">Spring Boot</a></td><td>Hugo</td>
<td align="center"><a href="./web-framework/java/springboot">SpringBoot [custom]</a></td><td>Hugo</td>
</tr>
<tr>
<td align="center">3</td>
<td align="center"><a href="./web-framework/nodejs/next/src">Nextjs [custom]</a></td>
<td align="center"><a href="./web-framework/python/bottle/src">Bottle [python3]</a></td>
<td align="center"><a href="./web-framework/php/discuz/src">Discuz</a></td><td></td><td align="center">Quarkus</td>
<td align="center"><a href="./web-framework/php/discuz/src">Discuz [custom]</a></td><td></td><td align="center">Quarkus</td>
<td align="center"></td>
</tr>
<tr>
<td align="center">4</td>
<td align="center"><a href="./web-framework/nodejs/nuxt/src">Nuxtjs [custom]</a></td>
<td align="center"><a href="./web-framework/python/webpy/src">Web.py [python3]</a></td>
<td align="center"> :fire::fire::fire: <a href="./web-framework/php/wordpress/src" >WordPress</a></td><td></td><td></td>
<td align="center"> :fire::fire::fire: <a href="./web-framework/php/wordpress/src" >WordPress [custom]</a></td><td></td><td></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">5</td>
<td align="center"> :fire::fire::fire: <a href="./web-framework/nodejs/hapi/src" >Hapi [custom]</a></td>
<td align="center"><a href="./web-framework/python/django/src" >Django [python3]</a></td>
<td align="center"> :fire::fire::fire: <a href="./web-framework/php/zblog/src" >Zblog</a></td><td></td><td></td>
<td align="center"> :fire::fire::fire: <a href="./web-framework/php/zblog/src" >Zblog [custom]</a></td><td></td><td></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">6</td>
<td align="center"><a href="./web-framework/nodejs/koa/src">Koa [custom]</a></td>
<td align="center">FastAPI</td>
<td align="center"><a href="./web-framework/php/ecshop/src" >Ecshop</a></td><td></td><td></td><td></td>
<td align="center"><a href="./web-framework/php/ecshop/src" >Ecshop [custom]</a></td><td></td><td></td><td></td>
</tr>
<tr>
<td align="center">7</td>
<td align="center"><a href="./web-framework/nodejs/nest/src">Nest [nodejs12]</a></td>
<td align="center">Web2py</td>
<td align="center"><a href="./web-framework/php/metinfo/src" >Metinfo</a></td>
<td align="center"><a href="./web-framework/php/metinfo/src" >Metinfo [custom]</a></td>
<td></td><td></td><td></td>
</tr>
<tr>
<td align="center">8</td>
<td align="center"><a href="./web-framework/nodejs/connect/src">Connect [nodejs12]</a></td>
<td align="center"><a href="./web-framework/python/pyramid/src" >Pyramid [python3]</a></td>
<td align="center"><a href="./web-framework/php/whatsns/src" >Whatsns</a></td><td></td><td></td><td></td>
<td align="center"><a href="./web-framework/php/whatsns/src" >Whatsns [custom]</a></td><td></td><td></td><td></td>
</tr>
<tr>
<td align="center">9</td>
<td align="center"><a href="./web-framework/nodejs/thinkjs/src">Think.js [nodejs12]</a></td>
<td align="center"></td>
<td align="center"><a href="./web-framework/php/typecho/src" >Typecho</a></td><td></td><td></td><td></td>
<td align="center"><a href="./web-framework/php/typecho/src" >Typecho [custom]</a></td><td></td><td></td><td></td>
</tr>
</table>

> 除了上面的案例之外,还提供了两个简单的实践应用:
> - [基于Express框架的todoList应用](./example/todolist-app/src)`s init todolist-app`
> - [基于Django框架的博客应用](./example/django-blog/src)`s init django-blog`
> 考虑到部分用户在使用 Nuxt 等框架时,有 SSR 或者 SPA 的目的,所以本仓库也提供了类似的案例:
> - [next-ssr](./web-framework/nodejs/next-ssr/src): `s init start-next-ssr`
<!-- > - [next-ssr](./web-framework/nodejs/next-ssr/src): `s init start-next-ssr` -->
> - [nuxt-ssr](./web-framework/nodejs/nuxt-ssr/src): `s init start-nuxt-ssr`
> - [nuxt-spi](./web-framework/nodejs/nuxt-spa/src): `s init start-nuxt-spa`
> - [nuxt-spa](./web-framework/nodejs/nuxt-spa/src): `s init start-nuxt-spa`
> 为了对比Custom运行时和编程语言原生运行时的框架迁移区别,可以参考以下案例进行自行对比:
>
> | 框架名 | Custom运行时 | Node.js 12运行时 |
> | ----- | ----------- | ----------------|
> | Egg.js | [./web-framework/nodejs/egg](./web-framework/nodejs/egg/src) | [./web-framework/nodejs/egg-app](./web-framework/nodejs/egg-app/src) |
> | Express.js | [./web-framework/nodejs/express](./web-framework/nodejs/express/src) | [./web-framework/nodejs/express-app](./web-framework/nodejs/express-app/src) |
> | Koa.js | [./web-framework/nodejs/koa](./web-framework/nodejs/koa/src) | [./web-framework/nodejs/koa-app](./web-framework/nodejs/koa-app/src) |
>
>
4 changes: 0 additions & 4 deletions update.list
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
./web-framework/nodejs/koa-app
./web-framework/nodejs/nest
./web-framework/java/springboot
./example/django-blog
./example/todolist-app
6 changes: 3 additions & 3 deletions web-framework/java/springboot/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ Type: Application
Name: start-springboot
Provider:
- 阿里云
Version: 0.0.1
Version: 0.1.0
Description: 快速部署一个Springboot应用到阿里云函数计算
HomePage: https://github.com/devsapp/start-web-framework
Tags:
- Web框架
- Spring Boot
Category: Web框架
Service:
- Name: 函数计算
函数计算:
Authorities:
- 管理员权限
- 管理员权限
2 changes: 1 addition & 1 deletion web-framework/nodejs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- [Connect [custom]](./connect/src)

> 考虑到部分用户在使用 Nuxt 等框架时,有 SSR 或者 SPA 的目的,所以本仓库也提供了类似的案例:
> - [next-ssr](./next-ssr/src): `s init start-next-ssr`
<!-- > - [next-ssr](./next-ssr/src): `s init start-next-ssr` -->
> - [nuxt-ssr](./nuxt-ssr/src): `s init start-nuxt-ssr`
> - [nuxt-spi](./nuxt-spa/src): `s init start-nuxt-spa`
> 为了对比Custom运行时和编程语言原生运行时的框架迁移区别,可以参考以下案例进行自行对比:
Expand Down
15 changes: 15 additions & 0 deletions web-framework/php/discuz/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Type: Application
Name: start-discuz
Provider:
- 阿里云
Version: 0.1.0
Description: 快速部署一个 Discuz 框架到阿里云函数计算
HomePage: https://github.com/devsapp/start-web-framework
Tags:
- Web框架
- Discuz
Category: Web框架
Service:
函数计算:
Authorities:
- 管理员权限
45 changes: 45 additions & 0 deletions web-framework/php/discuz/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 阿里云 Discuz 框架案例

- [快速体验](#快速体验)
- [相关命令](#相关命令)
- [依赖过大部署方案](#依赖过大部署方案)

## 快速体验

- 初始化项目:`s init start-discuz`
- 进入项目后部署:`s deploy`
- 部署过程中可能需要阿里云密钥的支持,部署完成之后会获得到临时域名可供测试

> 权限与 Yaml 配置可以参考 [FC Yaml 规范文档](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/yaml.md)
## 相关命令

由于该框架直接部署在阿里云函数计算平台,所以可以参考函数计算组件相关的命令:

| 构建&部署 | 可观测性 | 调用&调试 | 发布&配置 | 其他功能 |
| -------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------- |
| [**部署 deploy**](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/deploy.md) | [指标查询 metrics](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/metrics.md) | [**本地调用 local**](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/local.md) | [**版本 version**](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/version.md) | [**硬盘挂载 nas**](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/nas.md) |
| [**构建 build**](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/build.md) | [日志查询 logs](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/logs.md) | [远程调用 invoke](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/invoke.md) | [**别名 alias**](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/alias.md) | [计划变更 plan](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/plan.md) |
| [移除 remove](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/remove.md) | | [**端云联调 proxied**](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/proxied.md) | [预留 provision](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/provision.md) | [查看函数 info](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/info.md) |
| | | [远程调试 remote](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/remote.md) | [按量资源 ondemand](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/ondemand.md) | [**资源同步 sync**](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/sync.md) |
| | | [内存&并发度探测 eval](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/eval.md) | [层 layer](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/layer.md) | [压测 stress](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/stress.md) |
| | | | | [API 调用 api](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/api.md) |
| | | | | [Fun 项目迁移 fun2s](https://github.com/devsapp/fc/blob/jiangyu-docs/docs/zh/command/fun2s.md) |

## 依赖过大部署方案

函数计算的接口本身默认只支持 50M 的代码包,如果想要部署超过 50M 的代码包,可以考虑:

1. (50M, 100M] 范围内的代码包,可以:
- 指定 `s.yml` 中的 `ossBucket` 字段(需要是已存在的 Bucket 并且需要和服务同地域),此时通过工具进行部署时,工具会把代码压缩上传到这个指定的 Bucket,然后通过 OSS 的配置方式部署函数;
- 手动将代码压缩上传到对象存储,然后在 `s.yaml` 中指定 `ossBucket``ossKey` 字段,此时部署函数时,工具会直接通过 OSS 的配置方式部署函数;
2. 大于 100M 的代码包,可以:
-`nasConfig` 配置为 `auto`,然后基于 nas 指令将大文件(可能是训练集/依赖包)传输到 NAS 指定位置,然后配置相应的环境变量到 `s.yml` 中的函数配置中;
- 将非 custom-container 的函数转换成 custom-container,这需要对代码进行一定的改造,并新增 dockerfile,然后创建这个函数(此方式冷启动时间相对其他 runtime 会有一点点的延长);


---

> - Serverless Devs 项目:https://www.github.com/serverless-devs/serverless-devs
> - Serverless Devs 文档:https://www.github.com/serverless-devs/docs
> - Serverless Devs 钉钉交流群:33947367
2 changes: 2 additions & 0 deletions web-framework/php/discuz/src/code/.fcignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.s
discuz
31 changes: 31 additions & 0 deletions web-framework/php/discuz/src/code/bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set +e

mkdir -p /tmp/log/nginx/
mkdir -p /tmp/var/nginx/

chown -R www-data:www-data /mnt/auto/discuz

echo "start php-fpm"
php-fpm7.2 -c /code/root/usr/lib/php/7.2/php.ini-production -y /code/root/etc/php/7.2/fpm/php-fpm.conf

echo "start nginx"
nginx -c /code/root/etc/nginx/nginx.conf

sleep 5

while true
do
echo "check nginx and php-fpm process ...."
nginx_server=`ps aux | grep nginx | grep -v grep`
if [ ! "$nginx_server" ]; then
echo "restart nginx ..."
nginx -c /code/root/etc/nginx/nginx.conf
fi
php_fpm_server=`ps aux | grep php-fpm | grep -v grep`
if [ ! "$php_fpm_server" ]; then
echo "restart php-fpm ..."
php-fpm7.2 -c /code/root/usr/lib/php/7.2/php.ini-production -y /code/root/etc/php/7.2/fpm/php-fpm.conf
fi
sleep 10
done
71 changes: 71 additions & 0 deletions web-framework/php/discuz/src/code/discuz/admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admin.php 34285 2013-12-13 03:39:35Z hypowang $
*/

define('IN_ADMINCP', TRUE);
define('NOROBOT', TRUE);
define('ADMINSCRIPT', basename(__FILE__));
define('CURSCRIPT', 'admin');
define('HOOKTYPE', 'hookscript');
define('APPTYPEID', 0);


require './source/class/class_core.php';
require './source/function/function_misc.php';
require './source/function/function_forum.php';
require './source/function/function_admincp.php';
require './source/function/function_cache.php';

$discuz = C::app();
$discuz->init_cron = false;
$discuz->init();

$admincp = new discuz_admincp();
$admincp->core = & $discuz;
$admincp->init();


$admincp_actions_founder = array('templates', 'db', 'founder', 'postsplit', 'threadsplit', 'cloudaddons', 'optimizer');
$admincp_actions_normal = array('index', 'setting', 'members', 'admingroup', 'usergroups', 'usertag',
'forums', 'threadtypes', 'threads', 'moderate', 'attach', 'smilies', 'recyclebin', 'recyclebinpost', 'prune', 'grid',
'styles', 'addons', 'plugins', 'tasks', 'magics', 'medals', 'announce', 'faq', 'ec',
'tradelog', 'jswizard', 'project', 'counter', 'misc', 'adv', 'logs', 'tools', 'portalperm', 'blogrecyclebin',
'checktools', 'search', 'article', 'block', 'blockstyle', 'blockxml', 'portalcategory', 'blogcategory', 'albumcategory', 'topic', 'credits',
'doing', 'group', 'blog', 'feed', 'album', 'pic', 'comment', 'share', 'click', 'specialuser', 'postsplit', 'threadsplit', 'report',
'district', 'diytemplate', 'verify', 'nav', 'domain', 'postcomment', 'tag', 'connect', 'card', 'portalpermission', 'collection', 'membersplit', 'makehtml');

$action = preg_replace('/[^\[A-Za-z0-9_\]]/', '', getgpc('action'));
$operation = preg_replace('/[^\[A-Za-z0-9_\]]/', '', getgpc('operation'));
$do = preg_replace('/[^\[A-Za-z0-9_\]]/', '', getgpc('do'));
$frames = preg_replace('/[^\[A-Za-z0-9_\]]/', '', getgpc('frames'));
lang('admincp');
$lang = & $_G['lang']['admincp'];
$page = max(1, intval(getgpc('page')));
$isfounder = $admincp->isfounder;

if(empty($action) || $frames != null) {
$admincp->show_admincp_main();
} elseif($action == 'logout') {
$admincp->do_admin_logout();
dheader("Location: ./index.php");
} elseif(in_array($action, $admincp_actions_normal) || ($admincp->isfounder && in_array($action, $admincp_actions_founder))) {
if($admincp->allow($action, $operation, $do) || $action == 'index') {
require $admincp->admincpfile($action);
} else {
cpheader();
cpmsg('action_noaccess', '', 'error');
}
} else {
cpheader();
if($action == 'cloudaddons') {
cpmsg('cloudaddons_noaccess', '', 'error');
} else {
cpmsg('action_noaccess', '', 'error');
}
}
?>
32 changes: 32 additions & 0 deletions web-framework/php/discuz/src/code/discuz/api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: api.php 33591 2013-07-12 06:39:49Z andyzheng $
*/

define('IN_API', true);
define('CURSCRIPT', 'api');

$modarray = array('js' => 'javascript/javascript', 'ad' => 'javascript/advertisement');

$mod = !empty($_GET['mod']) ? $_GET['mod'] : '';
if(empty($mod) || !in_array($mod, array('js', 'ad'))) {
exit('Access Denied');
}

require_once './api/'.$modarray[$mod].'.php';

function loadcore() {
global $_G;
require_once './source/class/class_core.php';

$discuz = C::app();
$discuz->init_cron = false;
$discuz->init_session = false;
$discuz->init();
}

?>
18 changes: 18 additions & 0 deletions web-framework/php/discuz/src/code/discuz/api/addons/channel.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gbk" />
<script type="text/javascript">
var querystring = location.search.substr(1);
if(querystring.indexOf('/') != -1) {
var e = querystring.split('/');
var url = '../../admin.php?frames=yes&action=cloudaddons&operation=download&addonids=' + e[0] + '&md5hash=' + e[1] + '&timestamp=' + e[2];
try {
top.location.href = url;
} catch(e) {}
}
</script>
</head>
<body>
</body>
</html>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

if(phpversion() >= '5.3') {
include 'zendcheck53.php';
} else {
include 'zendcheck52.php';
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php @Zend;
4123;
/*
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php @Zend;
3074;
/*
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading

0 comments on commit 30e7263

Please sign in to comment.