├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .github └── workflows │ ├── ci_node16.yaml │ ├── ci_with_docker_linux.yaml │ └── registry-publish.yaml ├── .gitignore ├── .markdownlint.json ├── .markdownlintignore ├── .prettierignore ├── .prettierrc.js ├── .signore ├── .stylelintignore ├── .stylelintrc.js ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── __tests__ ├── complete-props.yaml ├── e2e │ ├── apt │ │ ├── code │ │ │ ├── .gitignore │ │ │ ├── apt-get.list │ │ │ ├── index.js │ │ │ ├── package-lock.json │ │ │ └── package.json │ │ ├── run │ │ └── s.yaml │ ├── ci-mac-linux.sh │ ├── ci-windows.ps1 │ ├── ci.sh │ ├── ci_trigger.sh │ ├── command-api │ │ ├── code │ │ │ └── event.js │ │ ├── pyyaml-layer.zip │ │ ├── run │ │ ├── run-windows.ps1 │ │ ├── run_cli_mode │ │ └── s.yaml │ ├── custom-container │ │ ├── code │ │ │ ├── Dockerfile │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ └── server.js │ │ ├── run │ │ └── s.yaml │ ├── custom-domain │ │ ├── code │ │ │ └── index.py │ │ ├── s.yaml │ │ └── s2.yaml │ ├── custom.debian10 │ │ ├── go │ │ │ ├── code │ │ │ │ ├── .gitignore │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ └── main.go │ │ │ └── s.yaml │ │ ├── python │ │ │ ├── code │ │ │ │ ├── .gitignore │ │ │ │ ├── gunicorn_conf.py │ │ │ │ ├── requirements.txt │ │ │ │ └── server.py │ │ │ └── s.yaml │ │ └── run │ ├── custom.debian11 │ │ ├── go │ │ │ ├── code │ │ │ │ ├── .gitignore │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ └── main.go │ │ │ └── s.yaml │ │ └── run │ ├── custom │ │ ├── go │ │ │ ├── code │ │ │ │ ├── .gitignore │ │ │ │ ├── go.mod │ │ │ │ └── main.go │ │ │ └── s.yaml │ │ ├── python │ │ │ ├── code │ │ │ │ ├── .gitignore │ │ │ │ ├── gunicorn_conf.py │ │ │ │ ├── requirements.txt │ │ │ │ └── server.py │ │ │ └── s.yaml │ │ ├── run │ │ ├── run-windows.ps1 │ │ └── springboot │ │ │ ├── code │ │ │ ├── .fcignore │ │ │ ├── .gitignore │ │ │ ├── Dockerfile │ │ │ ├── mvnw │ │ │ ├── mvnw.cmd │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── example │ │ │ │ │ │ └── webframework │ │ │ │ │ │ └── WebFrameworkApplication.java │ │ │ │ └── resources │ │ │ │ │ └── application.properties │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── webframework │ │ │ │ └── WebFrameworkApplicationTests.java │ │ │ ├── event │ │ │ └── http.json │ │ │ └── s.yaml │ ├── dotnetcore │ │ ├── HelloFcApp │ │ │ ├── HelloFcApp.csproj │ │ │ └── Program.cs │ │ ├── run │ │ └── s.yaml │ ├── go │ │ ├── code │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── main.go │ │ ├── run │ │ └── s.yaml │ ├── java │ │ ├── .gitignore │ │ ├── pom.xml │ │ ├── run │ │ ├── s.yaml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── example │ │ │ └── App.java │ ├── local │ │ ├── layer │ │ │ ├── nodejs │ │ │ │ ├── code │ │ │ │ │ └── index.js │ │ │ │ └── s.yaml │ │ │ └── python │ │ │ │ ├── code │ │ │ │ └── index.py │ │ │ │ └── s.yaml │ │ ├── nas │ │ │ ├── code │ │ │ │ └── index.py │ │ │ └── s.yaml │ │ └── run │ ├── nodejs │ │ ├── code │ │ │ ├── event.js │ │ │ ├── package-lock.json │ │ │ └── package.json │ │ ├── run │ │ ├── s.yaml │ │ ├── s2.yaml │ │ ├── s_auto.yaml │ │ ├── s_lock_auto.yaml │ │ ├── s_tags.yaml │ │ ├── s_tags2.yaml │ │ ├── s_tags3.yaml │ │ ├── test-auto-code │ │ │ └── index.js │ │ └── test.sh │ ├── php │ │ ├── code │ │ │ ├── .gitignore │ │ │ ├── composer.json │ │ │ ├── composer.lock │ │ │ ├── index.php │ │ │ └── test.sh │ │ ├── run │ │ ├── run-windows.ps1 │ │ └── s.yaml │ ├── python │ │ ├── code │ │ │ ├── .gitignore │ │ │ ├── apt-get.list │ │ │ ├── index.py │ │ │ └── requirements.txt │ │ ├── run │ │ ├── run-windows.ps1 │ │ └── s.yaml │ └── trigger │ │ ├── clear │ │ ├── eb │ │ ├── code │ │ │ └── index.js │ │ └── s.yaml │ │ ├── http │ │ ├── code │ │ │ └── index.js │ │ ├── evt.json │ │ └── s.yaml │ │ ├── jwt │ │ ├── code │ │ │ └── index.js │ │ └── s.yaml │ │ ├── other │ │ ├── code │ │ │ └── index.js │ │ └── s.yaml │ │ ├── run │ │ └── run-windows.ps1 ├── format.sh ├── it │ ├── code │ │ └── index.py │ └── integration_test.ts └── ut │ ├── interface_test.ts │ ├── resources_acr_test.ts │ ├── subCommands_test.ts │ └── utils_test.ts ├── commitlint.config.js ├── docs └── readme.md ├── f2elint.config.js ├── jestconfig.json ├── makefile ├── package-lock.json ├── package.json ├── patches └── ali-oss+6.18.1.patch ├── publish.yaml ├── src ├── base.ts ├── commands-help │ ├── alias.ts │ ├── build.ts │ ├── concurrency.ts │ ├── deploy.ts │ ├── index.ts │ ├── info.ts │ ├── instance.ts │ ├── invoke.ts │ ├── layer.ts │ ├── local.ts │ ├── logs.ts │ ├── plan.ts │ ├── provision.ts │ ├── remove.ts │ ├── s2tos3.ts │ ├── sync.ts │ └── version.ts ├── constant.ts ├── default │ ├── config.ts │ ├── image.ts │ └── resources.ts ├── index.ts ├── interface │ ├── async_invoke_config.ts │ ├── base.ts │ ├── cli-config │ │ ├── alias.ts │ │ ├── concurrency.ts │ │ └── provision.ts │ ├── concurrency_config.ts │ ├── function.ts │ ├── index.ts │ ├── provison_config.ts │ ├── region.ts │ └── trigger.ts ├── logger.ts ├── resources │ ├── acr │ │ ├── index.ts │ │ └── login.ts │ ├── fc │ │ ├── error-code.ts │ │ ├── impl │ │ │ ├── client.ts │ │ │ ├── replace-function-config.ts │ │ │ └── utils.ts │ │ └── index.ts │ ├── ram │ │ └── index.ts │ ├── sls │ │ └── index.ts │ └── vpc-nas │ │ └── index.ts ├── schema.json ├── subCommands │ ├── 2to3 │ │ └── index.ts │ ├── alias │ │ └── index.ts │ ├── build │ │ ├── impl │ │ │ ├── baseBuilder.ts │ │ │ ├── baseImageBuilder.ts │ │ │ ├── defaultBuilder.ts │ │ │ ├── imageBuiltKitBuilder.ts │ │ │ ├── imageDockerBuilder.ts │ │ │ └── imageKanikoBuilder.ts │ │ └── index.ts │ ├── concurrency │ │ └── index.ts │ ├── deploy │ │ ├── impl │ │ │ ├── async_invoke_config.ts │ │ │ ├── base.ts │ │ │ ├── concurrency_config.ts │ │ │ ├── custom_domain.ts │ │ │ ├── function.ts │ │ │ ├── provision_config.ts │ │ │ ├── trigger.ts │ │ │ └── vpc_binding.ts │ │ └── index.ts │ ├── info │ │ └── index.ts │ ├── instance │ │ └── index.ts │ ├── invoke │ │ └── index.ts │ ├── layer │ │ └── index.ts │ ├── local │ │ ├── impl │ │ │ ├── baseLocal.ts │ │ │ ├── invoke │ │ │ │ ├── baseLocalInvoke.ts │ │ │ │ ├── customContainerLocalInvoke.ts │ │ │ │ ├── customLocalInvoke.ts │ │ │ │ ├── dotnetLocalInvoke.ts │ │ │ │ ├── goLocalInvoke.ts │ │ │ │ ├── javaLocalInvoke.ts │ │ │ │ ├── nodejsLocalInvoke.ts │ │ │ │ ├── phpLocalInvoke.ts │ │ │ │ └── pythonLocalInvoke.ts │ │ │ ├── start │ │ │ │ ├── baseLocalStart.ts │ │ │ │ ├── customContainerLocalStart.ts │ │ │ │ ├── customLocalStart.ts │ │ │ │ ├── dotnetLocalStart.ts │ │ │ │ ├── goLocalInvoke.ts │ │ │ │ ├── javaLocalStart.ts │ │ │ │ ├── nodejsLocalStart.ts │ │ │ │ ├── phpLocalStart.ts │ │ │ │ └── pythonLocalStart.ts │ │ │ └── utils.ts │ │ └── index.ts │ ├── logs │ │ ├── constant.ts │ │ └── index.ts │ ├── plan │ │ └── index.ts │ ├── provision │ │ └── index.ts │ ├── remove │ │ └── index.ts │ ├── sync │ │ └── index.ts │ ├── trigger-template │ │ ├── event-template │ │ │ ├── cdn-CachedObjectsRefreshed.json │ │ │ ├── cdn-CdnDomainAdded.json │ │ │ ├── cdn-CdnDomainStarted.json │ │ │ ├── cdn-LogFileCreated.json │ │ │ ├── http.json │ │ │ ├── mns-stream.json │ │ │ ├── mns-with-MessageAttributes.json │ │ │ ├── mns-without-MessageAttributes.json │ │ │ ├── oss.json │ │ │ ├── sls.json │ │ │ └── tablestore.json │ │ └── index.ts │ └── version │ │ └── index.ts └── utils │ ├── index.ts │ ├── run-command.ts │ └── verify.ts ├── tsconfig.json └── version.md /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | quote_type = single 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | build/ 2 | coverage/ 3 | dist/ 4 | es/ 5 | lib/ 6 | node_modules/ 7 | **/*.min.js 8 | **/*-min.js 9 | **/*.bundle.js 10 | docs/ 11 | __tests__/ 12 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['eslint-config-ali/typescript', 'prettier', 'prettier/@typescript-eslint'], 3 | rules: { 4 | 'no-console': 'off', 5 | 'no-require-imports': 'off', 6 | '@typescript-eslint/explicit-member-accessibility': 0, 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /.github/workflows/ci_with_docker_linux.yaml: -------------------------------------------------------------------------------- 1 | name: Linux docker (build and local) ci 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | env: 9 | REGION: cn-hongkong 10 | 11 | jobs: 12 | docker-ci: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v2 16 | - uses: docker/setup-buildx-action@v2 17 | - uses: actions/setup-node@v2 18 | with: 19 | node-version: 16 20 | registry-url: https://registry.npmjs.org/ 21 | - name: Set up Go 22 | uses: actions/setup-go@v2 23 | with: 24 | go-version: 1.18 25 | - name: Set up Java 26 | uses: actions/setup-java@v1 27 | with: 28 | java-version: 8 29 | - name: Install dependencies 30 | run: | 31 | sudo apt-get update 32 | sudo apt-get install -y wget curl 33 | - name: install s 34 | run: | 35 | sudo npm i @serverless-devs/s -g 36 | - name: config s 37 | run: | 38 | sudo s config add --AccountID ${{secrets.ACCOUNTID}} --AccessKeyID ${{secrets.ACCESSKEYID}} --AccessKeySecret ${{secrets.ACCESSKEYSECRET}} -a quanxi -f 39 | - name: Configure NPM 40 | run: | 41 | npm config set registry https://registry.npmjs.org 42 | npm config set '//packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/:_authToken' ${{secrets.NPM_TOKEN}} 43 | - name: NPM install 44 | run: | 45 | npm install 46 | - name: NPM run build 47 | run: | 48 | npm run build 49 | - name: test python 50 | run: | 51 | cd __tests__/e2e/python && sudo ./run && cd - 52 | - name: test nodejs 53 | run: | 54 | cd __tests__/e2e/nodejs && sudo ./run && cd - 55 | - name: test php 56 | run: | 57 | cd __tests__/e2e/php && sudo ./run && cd - 58 | - name: test golang 59 | run: | 60 | cd __tests__/e2e/go && sudo ./run && cd - 61 | - name: test java 62 | run: | 63 | cd __tests__/e2e/java && sudo ./run && cd - 64 | - name: test dotnetcore 65 | run: | 66 | cd __tests__/e2e/dotnetcore && sudo ./run && cd - 67 | - name: test apt 68 | run: | 69 | cd __tests__/e2e/apt && sudo ./run && cd - 70 | - name: test custom.debian10 71 | run: | 72 | cd __tests__/e2e/custom.debian10 && sudo ./run && cd - 73 | - name: test custom 74 | run: | 75 | cd __tests__/e2e/custom && sudo ./run && cd - 76 | - name: test custom container 77 | run: | 78 | cd __tests__/e2e/custom-container && sudo ./run && cd - 79 | - name: test local with nas 80 | run: | 81 | cd __tests__/e2e/local && sudo ./run && cd - 82 | - name: test custom.debian11 83 | run: | 84 | cd __tests__/e2e/custom.debian11 && sudo ./run && cd - 85 | -------------------------------------------------------------------------------- /.github/workflows/registry-publish.yaml: -------------------------------------------------------------------------------- 1 | name: publish package to registry 2 | 3 | on: 4 | release: 5 | types: [created] 6 | 7 | jobs: 8 | deploy: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | - uses: actions/setup-node@v2 13 | with: 14 | node-version: 16 15 | registry-url: https://registry.npmjs.org/ 16 | - name: Install dependencies 17 | run: | 18 | sudo apt-get update 19 | sudo apt-get install -y git make jq curl wget 20 | - name: install s 21 | run: | 22 | npm i @serverless-devs/s@v3 -g 23 | - name: s registry login 24 | run: | 25 | s registry login --token ${{ secrets.alibaba_registry_v3_publish_token }} 26 | - name: Configure NPM 27 | run: | 28 | npm config set registry https://registry.npmjs.org 29 | npm config set '//packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/:_authToken' ${{secrets.NPM_TOKEN}} 30 | - name: release prod 31 | run: | 32 | make release-prod 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # common 2 | 3 | !.*ignore 4 | !.*rc 5 | !.gitattributes 6 | !.aoneci.yml 7 | !.editorconfig 8 | 9 | # Logs 10 | *.log* 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | 24 | # Dependency directories 25 | bower_components 26 | node_modules/ 27 | jspm_packages/ 28 | __pycache__/ 29 | 30 | # Compiled binary addons (https://nodejs.org/api/addons.html) 31 | build/Release 32 | lib 33 | dist 34 | 35 | # TypeScript v1 declaration files 36 | typings/ 37 | 38 | # Output of 'npm pack' 39 | *.tgz 40 | 41 | 42 | .DS_Store 43 | ___** 44 | .s 45 | replace-committers.sh* 46 | __tests__/e2e/python/.vscode 47 | __tests__/e2e/python/code/apt-archives 48 | .vscode 49 | __tests__/e2e/php/code/vendor 50 | __tests__/e2e/go/code/target 51 | __tests__/e2e/custom.debian10/go/code/target 52 | __tests__/e2e/custom/go/code/target 53 | __tests__/e2e/dotnetcore/HelloFcApp/bin/Release/netcoreapp3.1 54 | __tests__/e2e/dotnetcore/HelloFcApp/obj 55 | __tests__/e2e/dotnetcore/HelloFcApp/target 56 | __tests__/e2e/custom.debian10/python/code/python 57 | __tests__/e2e/custom/python/code/python 58 | __tests__/e2e/python/code/python 59 | __tests__/e2e/python/code/apt-archives 60 | 61 | .env_test -------------------------------------------------------------------------------- /.markdownlint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "markdownlint-config-ali" 3 | } 4 | -------------------------------------------------------------------------------- /.markdownlintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | build/ 3 | dist/ 4 | coverage/ 5 | es/ 6 | lib/ 7 | docs/ 8 | 9 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | __test__/complete-props.yaml 3 | dist/ 4 | docs/ 5 | *.json 6 | *.yaml 7 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | printWidth: 100, 3 | tabWidth: 2, 4 | semi: true, 5 | singleQuote: true, 6 | trailingComma: 'all', 7 | bracketSpacing: true, 8 | arrowParens: 'always', 9 | //parser: 'typescript', 10 | }; 11 | -------------------------------------------------------------------------------- /.signore: -------------------------------------------------------------------------------- 1 | __tests__ 2 | .husky 3 | .s 4 | .github 5 | .idea 6 | .vscode 7 | .DS_Store 8 | .git 9 | .env 10 | node_modules 11 | LICENSE 12 | package-lock.json 13 | .prettierrc.js 14 | .prettierignore 15 | .eslintrc.js 16 | .eslintignore 17 | .editorconfig 18 | .gitignore 19 | makefile 20 | README.md 21 | docs 22 | replace-committers.sh 23 | f2elint.config.js 24 | commitlint.config.js 25 | .stylelintrc.js 26 | .stylelintignore 27 | .markdownlint.json 28 | .markdownlintignore 29 | -------------------------------------------------------------------------------- /.stylelintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | build/ 3 | dist/ 4 | coverage/ 5 | es/ 6 | lib/ 7 | **/*.min.css 8 | **/*-min.css 9 | **/*.bundle.css 10 | __tests__/ 11 | docs/ 12 | -------------------------------------------------------------------------------- /.stylelintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: 'stylelint-config-ali', 3 | }; 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Serverless Devs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /__tests__/e2e/apt/code/.gitignore: -------------------------------------------------------------------------------- 1 | apt-archives -------------------------------------------------------------------------------- /__tests__/e2e/apt/code/apt-get.list: -------------------------------------------------------------------------------- 1 | libjq1 2 | libonig4 3 | jq 4 | rsync 5 | -------------------------------------------------------------------------------- /__tests__/e2e/apt/code/index.js: -------------------------------------------------------------------------------- 1 | const { execSync } = require('child_process'); 2 | require('chalk'); 3 | 4 | module.exports.handler = function (event, context, callback) { 5 | // throw new Error('xxx') 6 | console.log(process.env.PATH); 7 | console.log(process.env.LD_LIBRARY_PATH); 8 | console.log(event.toString()); 9 | execSync('jq --help', { 10 | shell: true, 11 | stdio: 'inherit', 12 | }); 13 | 14 | execSync('rsync --version', { 15 | shell: true, 16 | stdio: 'inherit', 17 | }); 18 | callback(null, 'hello world'); 19 | }; 20 | -------------------------------------------------------------------------------- /__tests__/e2e/apt/code/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "code", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "ansi-styles": { 8 | "version": "4.3.0", 9 | "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/ansi-styles/-/ansi-styles-4.3.0.tgz", 10 | "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", 11 | "requires": { 12 | "color-convert": "^2.0.1" 13 | } 14 | }, 15 | "chalk": { 16 | "version": "4.1.2", 17 | "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/chalk/-/chalk-4.1.2.tgz", 18 | "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", 19 | "requires": { 20 | "ansi-styles": "^4.1.0", 21 | "supports-color": "^7.1.0" 22 | } 23 | }, 24 | "color-convert": { 25 | "version": "2.0.1", 26 | "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/color-convert/-/color-convert-2.0.1.tgz", 27 | "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", 28 | "requires": { 29 | "color-name": "~1.1.4" 30 | } 31 | }, 32 | "color-name": { 33 | "version": "1.1.4", 34 | "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/color-name/-/color-name-1.1.4.tgz", 35 | "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" 36 | }, 37 | "has-flag": { 38 | "version": "4.0.0", 39 | "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/has-flag/-/has-flag-4.0.0.tgz", 40 | "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" 41 | }, 42 | "supports-color": { 43 | "version": "7.2.0", 44 | "resolved": "https://packages.aliyun.com/670e108663cd360abfe4be65/npm/npm-registry/supports-color/-/supports-color-7.2.0.tgz", 45 | "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", 46 | "requires": { 47 | "has-flag": "^4.0.0" 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /__tests__/e2e/apt/code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "code", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "event.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "chalk": "^4.1.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /__tests__/e2e/apt/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | echo "test apt-get ..." 6 | rm -rf ./code/apt-archives 7 | rm -rf ./code/node_modules 8 | export fc_component_function_name=nodejs14-$(uname)-$(uname -m) 9 | s build 10 | s local invoke -e '{"hello":"apt-get"}' 11 | s deploy -y 12 | s invoke -e '{"hello":"apt-get"}' 13 | s info 14 | s remove -y 15 | 16 | rm -rf ./code/apt-archives 17 | rm -rf ./code/node_modules 18 | -------------------------------------------------------------------------------- /__tests__/e2e/apt/s.yaml: -------------------------------------------------------------------------------- 1 | edition: 3.0.0 2 | name: framework 3 | access: quanxi 4 | 5 | vars: 6 | region: ${env('REGION', 'cn-hongkong')} 7 | 8 | resources: 9 | fcDemo: 10 | component: ${env('fc_component_version', path('../../../'))} 11 | props: # 组件的属性值 12 | region: ${vars.region} 13 | functionName: fc3-event-apt-get-${env('fc_component_function_name', 'nodejs14')} 14 | runtime: nodejs14 15 | code: ./code 16 | handler: index.handler 17 | memorySize: 128 18 | timeout: 30 19 | environmentVariables: 20 | PATH: /code/apt-archives/usr/bin:/var/fc/runtime/nodejs18/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 21 | LD_LIBRARY_PATH: /code/apt-archives/usr/local/lib:/code/apt-archives/usr/lib:/code/apt-archives/usr/lib/x86_64-linux-gnu:/code/apt-archives/usr/lib64:/code/apt-archives/lib:/code/apt-archives/lib/x86_64-linux-gnu:/code 22 | -------------------------------------------------------------------------------- /__tests__/e2e/ci-windows.ps1: -------------------------------------------------------------------------------- 1 | # github action 使用 2 | 3 | $ErrorActionPreference = "Stop" 4 | 5 | # $env:region="ap-southeast-1" 6 | # $env:OS="WIN" 7 | # $env:PROCESSOR_ARCHITECTURE="NT" 8 | 9 | Write-Host "test go runtime" 10 | cd go 11 | $env:fc_component_function_name = "go1-$($env:OS)-$($env:PROCESSOR_ARCHITECTURE)-$($env:RANDSTR)" 12 | $env:GOOS = "linux" 13 | $env:GOARCH = "amd64" 14 | cd ./code; go mod tidy; go build -o ./target/main; cd ../ 15 | s deploy -y --skip-actions 16 | s invoke -e '{"hello":"fc go1"}' 17 | s info 18 | s remove -y 19 | Remove-Item -Recurse -Force ./code/target -ErrorAction SilentlyContinue 20 | cd .. 21 | 22 | Write-Host "test custom go runtime ..." 23 | cd custom 24 | Remove-Item -Recurse -Force ./go/code/go.sum -ErrorAction SilentlyContinue 25 | $env:fc_component_function_name = "go1-$($env:OS)-$($env:PROCESSOR_ARCHITECTURE)-$($env:RANDSTR)" 26 | $env:GOOS = "linux" 27 | $env:GOARCH = "amd64" 28 | cd ./go/code; go mod tidy; go build -o ./target/main; cd ../../ 29 | s deploy -y -t ./go/s.yaml --skip-actions 30 | s invoke -e '{"hello":"fc custom go"}' -t ./go/s.yaml 31 | s info -y -t ./go/s.yaml 32 | s remove -y -t ./go/s.yaml 33 | Remove-Item -Recurse -Force ./go/code/target -ErrorAction SilentlyContinue 34 | cd .. 35 | 36 | 37 | Write-Host "test java runtime" 38 | cd java 39 | $env:fc_component_function_name = "java-$($env:OS)-$($env:PROCESSOR_ARCHITECTURE)-$($env:RANDSTR)" 40 | s deploy -y 41 | s invoke -e '{"hello":"fc java"}' 42 | s info 43 | s remove -y 44 | Remove-Item -Recurse -Force ./target -ErrorAction SilentlyContinue 45 | cd .. 46 | 47 | # Write-Host "test nodejs runtime with auto ..." 48 | # cd nodejs 49 | # $env:fc_component_function_name = "nodejs18-$($env:OS)-$($env:PROCESSOR_ARCHITECTURE)-$($env:RANDSTR)" 50 | # s deploy -y -t ./s_auto.yaml 51 | # s invoke -e '{"hello":"fc nodejs with auto"}' -t ./s_auto.yaml 52 | # s info -y -t ./s_auto.yaml 53 | # s remove -y -t ./s_auto.yaml 54 | # cd ../ 55 | 56 | Write-Host " ********* command-api *********" 57 | cd command-api; ./run-windows.ps1; cd ../ 58 | 59 | s cli fc3 layer list --prefix Python --region ap-southeast-1 -a quanxi 60 | s cli fc3 layer info --layer-name Python39-Gradio --version-id 1 --region ap-southeast-1 -a quanxi 61 | -------------------------------------------------------------------------------- /__tests__/e2e/ci_trigger.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 不需要使用到 build 和 local 指令的测试集合均可以加到这里 4 | # 需要 build 和 local 指令测试的集合会在 github action 中实现 5 | 6 | set -e 7 | set -v 8 | 9 | cd trigger && ./run cd - -------------------------------------------------------------------------------- /__tests__/e2e/command-api/code/event.js: -------------------------------------------------------------------------------- 1 | module.exports.handler = function (event, context, callback) { 2 | callback(null, 'hello world'); 3 | }; 4 | -------------------------------------------------------------------------------- /__tests__/e2e/command-api/pyyaml-layer.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devsapp/fc3/7a2c54d5c0866b610f450e3aebb06b25aab905a6/__tests__/e2e/command-api/pyyaml-layer.zip -------------------------------------------------------------------------------- /__tests__/e2e/command-api/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -v 5 | 6 | export fc_component_function_name=node16-$(uname)-$(uname -m)-$RANDSTR 7 | 8 | echo "test command instance/version/alias/concurrency/provision ..." 9 | s deploy -y 10 | 11 | instanceId=`s invoke | grep "Invoke instanceId:" | sed "s/.*: //"` 12 | 13 | echo "instanceId: $instanceId" 14 | 15 | # s instance exec --instance-id $instanceId --cmd 'ls -lh' 16 | s instance list 17 | 18 | s version publish --description test 19 | s version list 20 | s version remove --version-id latest -y 21 | s version publish --description test 22 | 23 | s concurrency put --reserved-concurrency 80 24 | s concurrency get 25 | s concurrency remove -y 26 | 27 | s alias list 28 | s alias publish --alias-name test --version-id latest 29 | s alias get --alias-name test 30 | s alias list 31 | s alias list --table 32 | s alias remove --alias-name test -y 33 | s alias publish --alias-name test --version-id latest 34 | 35 | s provision put --qualifier test --ac --target 2 --scheduled-actions '[{"name":"scheduled-actions","startTime":"2023-08-15T02:04:00.000Z","endTime":"2033-08-15T03:04:00.000Z","target":1,"scheduleExpression":"cron(0 0 4 * * *)"}]' --target-tracking-policies '[{"name":"target-tracking-policies","startTime":"2023-08-15T02:05:00.000Z","endTime":"2033-08-15T02:55:00.000Z","metricType":"ProvisionedConcurrencyUtilization","metricTarget":0.6,"minCapacity":1,"maxCapacity":3}]' 36 | s provision get --qualifier test 37 | s provision list 38 | s provision remove --qualifier test -y 39 | s provision list 40 | s provision put --qualifier test --target 2 41 | 42 | s remove -y 43 | 44 | 45 | echo "test layer ..." 46 | export layer_name=pyyaml-layer-$(uname)-$(uname -m)-$RANDSTR 47 | s layer list 48 | s layer list --prefix python 49 | s layer info --layer-name Python39-Scrapy2x --version-id 2 50 | s layer download --layer-name Python39-Scrapy2x --version-id 2 51 | s layer publish --layer-name $layer_name --code ./pyyaml-layer.zip --compatible-runtime "python3.9,python3.10,custom,custom.debian10" 52 | s layer list --prefix $layer_name 53 | s layer list --prefix $layer_name --table 54 | s layer versions --layer-name $layer_name 55 | s layer remove -y --layer-name $layer_name 56 | -------------------------------------------------------------------------------- /__tests__/e2e/command-api/run-windows.ps1: -------------------------------------------------------------------------------- 1 | $ErrorActionPreference = "Stop" 2 | 3 | $env:fc_component_function_name = "node16-$($env:OS)-$($env:PROCESSOR_ARCHITECTURE)-$($env:RANDSTR)" 4 | 5 | Write-Host "test command instance/version/alias/concurrency/provision ..." 6 | s deploy -y 7 | s invoke 8 | 9 | s instance list 10 | 11 | s version publish --description test 12 | s version list 13 | s version remove --version-id latest -y 14 | s version publish --description test 15 | 16 | s concurrency put --reserved-concurrency 80 17 | s concurrency get 18 | s concurrency remove -y 19 | 20 | s alias list 21 | s alias publish --alias-name test --version-id latest 22 | s alias get --alias-name test 23 | s alias list 24 | s alias list --table 25 | s alias remove --alias-name test -y 26 | s alias publish --alias-name test --version-id latest 27 | 28 | s provision put --qualifier test --ac --target 2 --scheduled-actions '[{"name":"scheduled-actions","startTime":"2023-08-15T02:04:00.000Z","endTime":"2033-08-15T02:04:00.000Z","target":1,"scheduleExpression":"cron(0 0 4 * * *)"}]' --target-tracking-policies '[{"name":"target-tracking-policies","startTime":"2023-08-15T02:05:00.000Z","endTime":"2033-08-15T02:05:00.000Z","metricType":"ProvisionedConcurrencyUtilization","metricTarget":0.6,"minCapacity":1,"maxCapacity":3}]' 29 | s provision get --qualifier test 30 | s provision list 31 | s provision remove --qualifier test -y 32 | s provision list 33 | s provision put --qualifier test --target 2 34 | 35 | s remove -y 36 | 37 | 38 | Write-Host "test layer ..." 39 | $layer_name = "pyyaml-layer-$($env:OS)-$($env:PROCESSOR_ARCHITECTURE)-$($env:RANDSTR)" 40 | s layer list 41 | s layer list --prefix python 42 | s layer info --layer-name Python39-Gradio --version-id 1 43 | s layer download --layer-name Python39-Gradio --version-id 1 44 | s layer publish --layer-name $layer_name --code ./pyyaml-layer.zip --compatible-runtime "python3.9,python3.10,custom,custom.debian10" 45 | s layer list --prefix $layer_name 46 | s layer list --prefix $layer_name --table 47 | s layer versions --layer-name $layer_name 48 | s layer remove -y --layer-name $layer_name -------------------------------------------------------------------------------- /__tests__/e2e/command-api/s.yaml: -------------------------------------------------------------------------------- 1 | edition: 3.0.0 2 | name: test-node-app 3 | access: quanxi 4 | 5 | vars: 6 | region: ${env('REGION', 'cn-hongkong')} 7 | 8 | resources: 9 | fcDemo: 10 | component: ${env('fc_component_version', path('../../../'))} 11 | props: # 组件的属性值 12 | region: ${vars.region} 13 | functionName: fc3-command-${env('fc_component_function_name', 'fc3-command')} 14 | runtime: nodejs18 15 | code: ./code 16 | handler: event.handler 17 | memorySize: 128 18 | timeout: 30 19 | logConfig: auto 20 | triggers: 21 | - triggerName: httpTrigger # 触发器名称 22 | triggerType: http # 触发器类型 23 | description: 'xxxx' 24 | qualifier: LATEST # 触发函数的版本 25 | triggerConfig: 26 | authType: anonymous # 鉴权类型,可选值:anonymous、function 27 | disableURLInternet: false # 是否禁用公网访问 URL 28 | methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 29 | - GET 30 | asyncInvokeConfig: 31 | destinationConfig: 32 | onFailure: 33 | destination: acs:mns:${vars.region}::/topics/serverless-devs-fc3-ci-test/messages 34 | onSuccess: 35 | destination: acs:fc:${vars.region}::functions/serverless-devs-ci-async-invoke-config-succ 36 | maxAsyncEventAgeInSeconds: 360 37 | maxAsyncRetryAttempts: 3 -------------------------------------------------------------------------------- /__tests__/e2e/custom-container/code/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:16-slim 2 | 3 | WORKDIR /home/code 4 | COPY . . 5 | 6 | RUN npm install --registry=https://registry.npmmirror.com 7 | 8 | 9 | # ENTRYPOINT ["node", "index.js"] 10 | -------------------------------------------------------------------------------- /__tests__/e2e/custom-container/code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "express": "^4.17.1" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /__tests__/e2e/custom-container/code/server.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // Constants 4 | const PORT = 9001; 5 | const HOST = '0.0.0.0'; 6 | const REQUEST_ID_HEADER = 'x-fc-request-id'; 7 | 8 | const express = require('express'); 9 | const app = express(); 10 | app.use(express.raw()); 11 | 12 | app.post('/initialize', (req, res) => { 13 | // console.log(JSON.stringify(req.headers)); 14 | var rid = req.headers[REQUEST_ID_HEADER]; 15 | console.log(`FC Initialize Start RequestId: ${rid}`); 16 | // do your things 17 | res.send('Hello FunctionCompute, initialize \n'); 18 | console.log(`FC Initialize End RequestId: ${rid}`); 19 | }); 20 | 21 | // invocation 22 | app.post('/invoke', (req, res) => { 23 | // console.log(JSON.stringify(req.headers)); 24 | var rid = req.headers[REQUEST_ID_HEADER]; 25 | console.log(`FC Invoke Start RequestId: ${rid}`); 26 | try { 27 | // get body to do your things 28 | var bodyStr = req.body.toString(); 29 | console.log(bodyStr); 30 | JSON.parse(bodyStr); 31 | } catch (e) { 32 | console.error(e.stack || e); 33 | return res.status(404).send(e.stack || e); 34 | } 35 | 36 | res.send('OK\n'); 37 | console.log(`FC Invoke End RequestId: ${rid}`); 38 | }); 39 | 40 | var server = app.listen(PORT, HOST); 41 | console.log(`Running on http://${HOST}:${PORT}`); 42 | 43 | server.timeout = 0; // never timeout 44 | server.keepAliveTimeout = 0; // keepalive, never timeout 45 | -------------------------------------------------------------------------------- /__tests__/e2e/custom-container/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | echo "test custom-container runtime ..." 6 | export fc_component_function_name=custom_container-$(uname)-$(uname -m) 7 | s build --dockerfile ./code/Dockerfile 8 | s local invoke -e '{"hello":"fc custom-container"}' 9 | s deploy -y 10 | s invoke -e '{"hello":"fc custom-container"}' 11 | s info 12 | s remove -y 13 | -------------------------------------------------------------------------------- /__tests__/e2e/custom-container/s.yaml: -------------------------------------------------------------------------------- 1 | edition: 3.0.0 2 | name: framework 3 | access: quanxi 4 | 5 | vars: 6 | region: ${env('REGION', 'cn-hangzhou')} 7 | 8 | resources: 9 | fcDemo: # 业务名称/模块名称 10 | component: ${env('fc_component_version', path('../../../'))} 11 | props: 12 | region: ${vars.region} 13 | functionName: fc3-event-${env('fc_component_function_name', 'custom_container')} 14 | runtime: custom-container 15 | handler: index.handler 16 | timeout: 30 17 | memorySize: 1024 18 | code: ./code 19 | instanceConcurrency: 4 20 | customContainerConfig: 21 | image: 'registry.${vars.region}.aliyuncs.com/fc-demo2/test-xiliu:ciExpressV1' 22 | entrypoint: 23 | - node 24 | command: 25 | - /home/code/server.js 26 | port: 9001 27 | -------------------------------------------------------------------------------- /__tests__/e2e/custom-domain/code/index.py: -------------------------------------------------------------------------------- 1 | def handler(event, context): 2 | return "hello wolrd!\n" 3 | -------------------------------------------------------------------------------- /__tests__/e2e/custom-domain/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "quanxi" 9 | 10 | vars: 11 | region: 'cn-hongkong' 12 | 13 | resources: 14 | hello_world_1: 15 | #component: fc3@dev 16 | component: ${env('fc_component_version', path('../../../'))} 17 | props: 18 | region: ${vars.region} 19 | functionName: "test-cd" 20 | description: 'hello world by serverless devs' 21 | runtime: "python3.10" 22 | code: ./code 23 | handler: index.handler 24 | memorySize: 128 25 | timeout: 45 26 | triggers: 27 | - triggerName: httpTrigger 28 | triggerType: http 29 | triggerConfig: 30 | methods: 31 | - GET 32 | - POST 33 | authType: anonymous 34 | disableURLInternet: false 35 | customDomain: 36 | #domainName: auto 37 | domainName: "xiliu-test.devsapp.net" 38 | protocol: HTTP 39 | route: 40 | # methods: 41 | # - GET 42 | path: /* 43 | qualifier: LATEST 44 | 45 | hello_world_2: 46 | #component: fc3@dev 47 | component: ${env('fc_component_version', path('../../../'))} 48 | props: 49 | region: ${vars.region} 50 | functionName: "test-cd2" 51 | description: 'hello world by serverless devs' 52 | runtime: "python3.10" 53 | code: ./code 54 | handler: index.handler 55 | memorySize: 128 56 | timeout: 45 57 | triggers: 58 | - triggerName: httpTrigger 59 | triggerType: http 60 | triggerConfig: 61 | methods: 62 | - GET 63 | - POST 64 | authType: anonymous 65 | disableURLInternet: false 66 | customDomain: 67 | domainName: "xiliu-test.devsapp.net" 68 | protocol: HTTP 69 | route: 70 | methods: 71 | - GET 72 | path: /a 73 | qualifier: LATEST 74 | -------------------------------------------------------------------------------- /__tests__/e2e/custom-domain/s2.yaml: -------------------------------------------------------------------------------- 1 | edition: 3.0.0 2 | name: hello-world-app 3 | access: "quanxi" 4 | 5 | vars: 6 | region: 'cn-hongkong' 7 | 8 | resources: 9 | hello_world_1: 10 | #component: fc3@dev 11 | component: ${env('fc_component_version', path('../../../'))} 12 | props: 13 | region: ${vars.region} 14 | functionName: "test-cd3" 15 | description: 'hello world by serverless devs' 16 | runtime: "python3.10" 17 | code: ./code 18 | handler: index.handler 19 | memorySize: 128 20 | timeout: 45 21 | triggers: 22 | - triggerName: httpTrigger 23 | triggerType: http 24 | triggerConfig: 25 | methods: 26 | - GET 27 | - POST 28 | authType: anonymous 29 | disableURLInternet: false 30 | customDomain: 31 | domainName: auto 32 | protocol: HTTP 33 | route: 34 | # methods: 35 | # - GET 36 | path: /* 37 | qualifier: LATEST -------------------------------------------------------------------------------- /__tests__/e2e/custom.debian10/go/code/.gitignore: -------------------------------------------------------------------------------- 1 | python 2 | __pycache__ 3 | -------------------------------------------------------------------------------- /__tests__/e2e/custom.debian10/go/code/go.mod: -------------------------------------------------------------------------------- 1 | module example.com/m 2 | 3 | go 1.17 4 | 5 | require github.com/awesome-fc/golang-runtime v0.0.0-20230119040721-3f65ab4b97d3 6 | 7 | require ( 8 | github.com/sirupsen/logrus v1.9.0 // indirect 9 | github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 // indirect 10 | golang.org/x/sys v0.4.0 // indirect 11 | ) 12 | -------------------------------------------------------------------------------- /__tests__/e2e/custom.debian10/go/code/go.sum: -------------------------------------------------------------------------------- 1 | github.com/awesome-fc/golang-runtime v0.0.0-20230119040721-3f65ab4b97d3 h1:d0/nCeQMEqCokk7qCx4kssYtdck2R5Pe6xQzptuKfO8= 2 | github.com/awesome-fc/golang-runtime v0.0.0-20230119040721-3f65ab4b97d3/go.mod h1:W4bhz/v/p6E48AW5CH9j3kI1Xmp/fH/g6NNJXRvCtL4= 3 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 4 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 5 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 6 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 7 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 8 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 9 | github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= 10 | github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= 11 | github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= 12 | github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= 13 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 14 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 15 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 16 | github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= 17 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 18 | github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 h1:J6v8awz+me+xeb/cUTotKgceAYouhIB3pjzgRd6IlGk= 19 | github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA= 20 | golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 21 | golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 22 | golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 23 | golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= 24 | golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 25 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 26 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= 27 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 28 | -------------------------------------------------------------------------------- /__tests__/e2e/custom.debian10/go/code/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | gr "github.com/awesome-fc/golang-runtime" 7 | ) 8 | 9 | func initialize(ctx *gr.FCContext) error { 10 | ctx.GetLogger().Infoln("init golang!") 11 | return nil 12 | } 13 | 14 | func handler(ctx *gr.FCContext, event []byte) ([]byte, error) { 15 | fcLogger := ctx.GetLogger() 16 | _, err := json.Marshal(ctx) 17 | if err != nil { 18 | fcLogger.Error("error:", err) 19 | } 20 | fcLogger.Infof("hello golang!") 21 | fcLogger.Infof("hello golang2!") 22 | return event, nil 23 | } 24 | 25 | func main() { 26 | gr.Start(handler, initialize) 27 | } 28 | -------------------------------------------------------------------------------- /__tests__/e2e/custom.debian10/go/s.yaml: -------------------------------------------------------------------------------- 1 | edition: 3.0.0 2 | name: test-custom-debian10-go 3 | access: quanxi 4 | 5 | vars: 6 | region: ${env('REGION', 'cn-hongkong')} 7 | 8 | resources: 9 | fcDemo: 10 | component: ${env('fc_component_version', path('../../../../'))} 11 | actions: 12 | pre-deploy: 13 | - run: go mod tidy 14 | path: ./code 15 | - run: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o target/main main.go 16 | path: ./code 17 | props: 18 | region: ${vars.region} 19 | functionName: fc3-event-debian10-${env('fc_component_function_name', 'go1')} 20 | description: 'hello world by serverless devs' 21 | timeout: 30 22 | memorySize: 512 23 | cpu: 0.5 24 | diskSize: 512 25 | runtime: custom.debian10 26 | code: ./code/target 27 | customRuntimeConfig: 28 | command: 29 | - '/code/main' 30 | -------------------------------------------------------------------------------- /__tests__/e2e/custom.debian10/python/code/.gitignore: -------------------------------------------------------------------------------- 1 | python 2 | __pycache__ 3 | -------------------------------------------------------------------------------- /__tests__/e2e/custom.debian10/python/code/gunicorn_conf.py: -------------------------------------------------------------------------------- 1 | bind = "0.0.0.0:9000" 2 | workers = 1 3 | threads = 2 4 | keepalive = 900 5 | accesslog = "-" 6 | errorlog = "-" 7 | -------------------------------------------------------------------------------- /__tests__/e2e/custom.debian10/python/code/requirements.txt: -------------------------------------------------------------------------------- 1 | gunicorn 2 | flask -------------------------------------------------------------------------------- /__tests__/e2e/custom.debian10/python/code/server.py: -------------------------------------------------------------------------------- 1 | from flask.logging import default_handler 2 | import time 3 | from flask import Flask 4 | from flask import request 5 | import json 6 | import sys 7 | import traceback 8 | import logging 9 | 10 | 11 | log = logging.getLogger("werkzeug") 12 | log.setLevel(logging.ERROR) 13 | 14 | 15 | app = Flask(__name__) 16 | 17 | 18 | REQUEST_ID_HEADER = "x-fc-request-id" 19 | 20 | 21 | @app.route("/invoke", methods=["POST"]) 22 | def event_invoke(): 23 | rid = request.headers.get(REQUEST_ID_HEADER) 24 | print("FC Invoke Start RequestId: " + rid) 25 | 26 | data = request.stream.read() 27 | print(data) 28 | 29 | try: 30 | # do your things, for example: 31 | evt = json.loads(data) 32 | print(evt) 33 | except Exception as e: 34 | exc_info = sys.exc_info() 35 | trace = traceback.format_tb(exc_info[2]) 36 | errRet = {"message": str(e), "stack": trace} 37 | print(errRet) 38 | print("FC Invoke End RequestId: " + rid) 39 | return errRet, 404, [("x-fc-status", "404")] 40 | 41 | print("FC Invoke End RequestId: " + rid) 42 | 43 | return data 44 | 45 | 46 | @app.route("/", methods=["GET"]) 47 | def home(): 48 | return "hello world\n" 49 | 50 | 51 | if __name__ == "__main__": 52 | app.run(host="0.0.0.0", port=9000) 53 | -------------------------------------------------------------------------------- /__tests__/e2e/custom.debian10/python/s.yaml: -------------------------------------------------------------------------------- 1 | edition: 3.0.0 2 | name: test-custom-debian10-python 3 | access: "quanxi" 4 | 5 | vars: 6 | region: ${env('REGION', 'cn-hongkong')} 7 | 8 | resources: 9 | helloworld: 10 | component: ${env('fc_component_version', path('../../../../'))} 11 | props: 12 | region: ${vars.region} 13 | functionName: fc3-event-debian10-${env('fc_component_function_name', 'python310')} 14 | handler: index.handler 15 | timeout: 60 16 | memorySize: 1536 17 | cpu: 1 18 | diskSize: 512 19 | runtime: custom.debian10 20 | code: ./code 21 | instanceConcurrency: 10 22 | environmentVariables: 23 | PYTHONPATH: /code/python 24 | PATH: /code/python/bin:/usr/local/bin/apache-maven/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/ruby/bin 25 | customRuntimeConfig: 26 | command: 27 | - gunicorn 28 | args: 29 | - '-c' 30 | - 'gunicorn_conf.py' 31 | - 'server:app' 32 | -------------------------------------------------------------------------------- /__tests__/e2e/custom.debian10/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | echo "test custom.debian10 go runtime ..." 6 | rm -rf ./go/code/go.sum 7 | export fc_component_function_name=go1-$(uname)-$(uname -m) 8 | s deploy -y -t ./go/s.yaml 9 | s invoke -e '{"hello":"fc custom.debian10 go"}' -t ./go/s.yaml 10 | s local invoke -e '{"hello":"fc custom.debian10 go"}' -t ./go/s.yaml 11 | s info -t ./go/s.yaml 12 | s remove -y -t ./go/s.yaml 13 | rm -rf ./go/code/target 14 | 15 | echo "test custom.debian10 python runtime ..." 16 | rm -rf ./python/code/python 17 | rm -rf ./python/code/__pycache__ 18 | export fc_component_function_name=python310-$(uname)-$(uname -m) 19 | s build -t ./python/s.yaml 20 | s local invoke -e '{"hello":"fc custom.debian10 python"}' -t ./python/s.yaml 21 | s deploy -y -t ./python/s.yaml 22 | s invoke -e '{"hello":"fc custom.debian10 python"}' -t ./python/s.yaml 23 | s info -t ./python/s.yaml 24 | s remove -y -t ./python/s.yaml 25 | 26 | rm -rf ./go/code/target 27 | rm -rf ./python/code/python 28 | rm -rf ./python/code/__pycache__ 29 | -------------------------------------------------------------------------------- /__tests__/e2e/custom.debian11/go/code/.gitignore: -------------------------------------------------------------------------------- 1 | python 2 | __pycache__ 3 | -------------------------------------------------------------------------------- /__tests__/e2e/custom.debian11/go/code/go.mod: -------------------------------------------------------------------------------- 1 | module example.com/m 2 | 3 | go 1.17 4 | 5 | require github.com/awesome-fc/golang-runtime v0.0.0-20230119040721-3f65ab4b97d3 6 | 7 | require ( 8 | github.com/sirupsen/logrus v1.9.0 // indirect 9 | github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 // indirect 10 | golang.org/x/sys v0.4.0 // indirect 11 | ) 12 | -------------------------------------------------------------------------------- /__tests__/e2e/custom.debian11/go/code/go.sum: -------------------------------------------------------------------------------- 1 | github.com/awesome-fc/golang-runtime v0.0.0-20230119040721-3f65ab4b97d3 h1:d0/nCeQMEqCokk7qCx4kssYtdck2R5Pe6xQzptuKfO8= 2 | github.com/awesome-fc/golang-runtime v0.0.0-20230119040721-3f65ab4b97d3/go.mod h1:W4bhz/v/p6E48AW5CH9j3kI1Xmp/fH/g6NNJXRvCtL4= 3 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 4 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 5 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 6 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 7 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 8 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 9 | github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= 10 | github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= 11 | github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= 12 | github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= 13 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 14 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 15 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 16 | github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= 17 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 18 | github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 h1:J6v8awz+me+xeb/cUTotKgceAYouhIB3pjzgRd6IlGk= 19 | github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA= 20 | golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 21 | golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 22 | golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 23 | golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= 24 | golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 25 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 26 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= 27 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 28 | -------------------------------------------------------------------------------- /__tests__/e2e/custom.debian11/go/code/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | gr "github.com/awesome-fc/golang-runtime" 7 | ) 8 | 9 | func initialize(ctx *gr.FCContext) error { 10 | ctx.GetLogger().Infoln("init golang!") 11 | return nil 12 | } 13 | 14 | func handler(ctx *gr.FCContext, event []byte) ([]byte, error) { 15 | fcLogger := ctx.GetLogger() 16 | _, err := json.Marshal(ctx) 17 | if err != nil { 18 | fcLogger.Error("error:", err) 19 | } 20 | fcLogger.Infof("hello golang!") 21 | fcLogger.Infof("hello golang2!") 22 | return event, nil 23 | } 24 | 25 | func main() { 26 | gr.Start(handler, initialize) 27 | } 28 | -------------------------------------------------------------------------------- /__tests__/e2e/custom.debian11/go/s.yaml: -------------------------------------------------------------------------------- 1 | edition: 3.0.0 2 | name: test-custom-debian11-go 3 | access: quanxi 4 | 5 | vars: 6 | region: ${env('REGION', 'cn-hongkong')} 7 | 8 | resources: 9 | fcDemo: 10 | component: ${env('fc_component_version', path('../../../../'))} 11 | actions: 12 | pre-deploy: 13 | - run: go mod tidy 14 | path: ./code 15 | - run: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o target/main main.go 16 | path: ./code 17 | props: 18 | region: ${vars.region} 19 | functionName: fc3-event-debian11-${env('fc_component_function_name', 'go1')} 20 | description: 'hello world by serverless devs' 21 | timeout: 30 22 | memorySize: 512 23 | cpu: 0.5 24 | diskSize: 512 25 | runtime: custom.debian11 26 | code: ./code/target 27 | customRuntimeConfig: 28 | command: 29 | - '/code/main' 30 | -------------------------------------------------------------------------------- /__tests__/e2e/custom.debian11/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | echo "test custom.debian11 go runtime ..." 6 | rm -rf ./go/code/go.sum 7 | export fc_component_function_name=go1-$(uname)-$(uname -m) 8 | s deploy -y -t ./go/s.yaml 9 | s invoke -e '{"hello":"fc custom.debian11 go"}' -t ./go/s.yaml 10 | s local invoke -e '{"hello":"fc custom.debian11 go"}' -t ./go/s.yaml 11 | s info -t ./go/s.yaml 12 | s remove -y -t ./go/s.yaml 13 | rm -rf ./go/code/target 14 | 15 | -------------------------------------------------------------------------------- /__tests__/e2e/custom/go/code/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | go.sum -------------------------------------------------------------------------------- /__tests__/e2e/custom/go/code/go.mod: -------------------------------------------------------------------------------- 1 | module example.com/m 2 | 3 | go 1.17 4 | 5 | require github.com/awesome-fc/golang-runtime v0.0.0-20230119040721-3f65ab4b97d3 6 | 7 | require ( 8 | github.com/sirupsen/logrus v1.9.0 // indirect 9 | github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 // indirect 10 | golang.org/x/sys v0.4.0 // indirect 11 | ) 12 | -------------------------------------------------------------------------------- /__tests__/e2e/custom/go/code/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | gr "github.com/awesome-fc/golang-runtime" 7 | ) 8 | 9 | func initialize(ctx *gr.FCContext) error { 10 | ctx.GetLogger().Infoln("init golang!") 11 | return nil 12 | } 13 | 14 | func handler(ctx *gr.FCContext, event []byte) ([]byte, error) { 15 | fcLogger := ctx.GetLogger() 16 | _, err := json.Marshal(ctx) 17 | if err != nil { 18 | fcLogger.Error("error:", err) 19 | } 20 | fcLogger.Infof("hello golang!") 21 | fcLogger.Infof("hello golang2!") 22 | return event, nil 23 | } 24 | 25 | func main() { 26 | gr.Start(handler, initialize) 27 | } 28 | -------------------------------------------------------------------------------- /__tests__/e2e/custom/go/s.yaml: -------------------------------------------------------------------------------- 1 | edition: 3.0.0 2 | name: test-custom-go 3 | access: quanxi 4 | 5 | vars: 6 | region: ${env('REGION', 'cn-hongkong')} 7 | 8 | resources: 9 | fcDemo: 10 | component: ${env('fc_component_version', path('../../../../'))} 11 | actions: 12 | pre-deploy: 13 | - run: go mod tidy 14 | path: ./code 15 | - run: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o target/main main.go 16 | path: ./code 17 | props: 18 | region: ${vars.region} 19 | functionName: fc3-event-custom-${env('fc_component_function_name', 'go1')} 20 | description: 'hello world by serverless devs' 21 | timeout: 30 22 | memorySize: 512 23 | cpu: 0.5 24 | diskSize: 512 25 | runtime: custom 26 | code: ./code/target 27 | customRuntimeConfig: 28 | command: 29 | - '/code/main' 30 | port: 9000 31 | -------------------------------------------------------------------------------- /__tests__/e2e/custom/python/code/.gitignore: -------------------------------------------------------------------------------- 1 | python 2 | __pycache__ 3 | -------------------------------------------------------------------------------- /__tests__/e2e/custom/python/code/gunicorn_conf.py: -------------------------------------------------------------------------------- 1 | bind = "0.0.0.0:8099" 2 | workers = 1 3 | threads = 2 4 | keepalive = 900 5 | accesslog = "-" 6 | errorlog = "-" 7 | -------------------------------------------------------------------------------- /__tests__/e2e/custom/python/code/requirements.txt: -------------------------------------------------------------------------------- 1 | gunicorn 2 | flask -------------------------------------------------------------------------------- /__tests__/e2e/custom/python/code/server.py: -------------------------------------------------------------------------------- 1 | from flask.logging import default_handler 2 | import time 3 | from flask import Flask 4 | from flask import request 5 | import json 6 | import sys 7 | import traceback 8 | import logging 9 | 10 | 11 | log = logging.getLogger("werkzeug") 12 | log.setLevel(logging.ERROR) 13 | 14 | 15 | app = Flask(__name__) 16 | 17 | 18 | REQUEST_ID_HEADER = "x-fc-request-id" 19 | 20 | 21 | @app.route("/invoke", methods=["POST"]) 22 | def event_invoke(): 23 | rid = request.headers.get(REQUEST_ID_HEADER) 24 | print("FC Invoke Start RequestId: " + rid) 25 | 26 | data = request.stream.read() 27 | print(data) 28 | 29 | try: 30 | # do your things, for example: 31 | evt = json.loads(data) 32 | print(evt) 33 | except Exception as e: 34 | exc_info = sys.exc_info() 35 | trace = traceback.format_tb(exc_info[2]) 36 | errRet = {"message": str(e), "stack": trace} 37 | print(errRet) 38 | print("FC Invoke End RequestId: " + rid) 39 | return errRet, 404, [("x-fc-status", "404")] 40 | 41 | print("FC Invoke End RequestId: " + rid) 42 | 43 | return data 44 | 45 | 46 | @app.route("/", methods=["GET"]) 47 | def home(): 48 | return "hello world" 49 | 50 | 51 | if __name__ == "__main__": 52 | app.run(host="0.0.0.0", port=8099) 53 | -------------------------------------------------------------------------------- /__tests__/e2e/custom/python/s.yaml: -------------------------------------------------------------------------------- 1 | edition: 3.0.0 2 | name: test-custom-python 3 | access: "quanxi" 4 | 5 | vars: 6 | region: ${env('REGION', 'cn-hongkong')} 7 | 8 | resources: 9 | helloworld: 10 | component: ${env('fc_component_version', path('../../../../'))} 11 | props: 12 | region: ${vars.region} 13 | functionName: fc3-event-custom-${env('fc_component_function_name', 'python310')} 14 | handler: index.handler 15 | timeout: 60 16 | memorySize: 1536 17 | cpu: 1 18 | diskSize: 512 19 | runtime: custom 20 | code: ./code 21 | instanceConcurrency: 10 22 | environmentVariables: 23 | PYTHONPATH: /code/python 24 | PATH: /code/python/bin:/usr/local/bin/apache-maven/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/ruby/bin 25 | customRuntimeConfig: 26 | command: 27 | - gunicorn 28 | args: 29 | - '-c' 30 | - 'gunicorn_conf.py' 31 | - 'server:app' 32 | port: 8099 33 | -------------------------------------------------------------------------------- /__tests__/e2e/custom/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | echo "test custom go runtime ..." 6 | rm -rf ./go/code/go.sum 7 | export fc_component_function_name=go1-$(uname)-$(uname -m) 8 | s deploy -y -t ./go/s.yaml 9 | s invoke -e '{"hello":"fc custom go"}' -t ./go/s.yaml 10 | s local invoke -e '{"hello":"fc custom go"}' -t ./go/s.yaml 11 | s info -y -t ./go/s.yaml 12 | s remove -y -t ./go/s.yaml 13 | rm -rf ./go/code/target 14 | 15 | echo "test custom python runtime ..." 16 | rm -rf ./python/code/python 17 | rm -rf ./python/code/__pycache__ 18 | export fc_component_function_name=python310-$(uname)-$(uname -m) 19 | s build -t ./python/s.yaml 20 | s local invoke -e '{"hello":"fc custom python"}' -t ./python/s.yaml 21 | s deploy -y -t ./python/s.yaml 22 | s invoke -e '{"hello":"fc custom python"}' -t ./python/s.yaml 23 | s info -y -t ./python/s.yaml 24 | s remove -y -t ./python/s.yaml 25 | 26 | echo "test custom java(springboot) runtime ..." 27 | rm -rf ./springboot/code/target 28 | export fc_component_function_name=springboot-$(uname)-$(uname -m) 29 | s deploy -y -t ./springboot/s.yaml 30 | s invoke --event-file ./springboot/event/http.json -t ./springboot/s.yaml 31 | s info -t ./springboot/s.yaml 32 | s jar_zip local invoke --event-file ./springboot/event/http.json -t ./springboot/s.yaml 33 | s jar local invoke --event-file ./springboot/event/http.json -t ./springboot/s.yaml 34 | s remove -y -t ./springboot/s.yaml 35 | 36 | rm -rf ./go/code/target 37 | rm -rf ./python/code/python 38 | rm -rf ./python/code/__pycache__ 39 | rm -rf ./springboot/code/target 40 | -------------------------------------------------------------------------------- /__tests__/e2e/custom/run-windows.ps1: -------------------------------------------------------------------------------- 1 | $ErrorActionPreference = "Stop" 2 | 3 | Write-Host "test custom go runtime ..." 4 | $env:fc_component_function_name = "go1-$($env:OS)-$($env:PROCESSOR_ARCHITECTURE)" 5 | $env:GOOS = "linux" 6 | $env:GOARCH = "amd64" 7 | cd ./go/code; go mod tidy; go build -o ./target/main; cd ../../ 8 | s deploy -y -t ./go/s.yaml --skip-actions 9 | s invoke -e '{"hello":"fc custom go"}' -t ./go/s.yaml 10 | s local invoke -e '{"hello":"fc custom go"}' -t ./go/s.yaml 11 | s info -y -t ./go/s.yaml 12 | s remove -y -t ./go/s.yaml 13 | Remove-Item -Recurse -Force ./go/code/target -ErrorAction SilentlyContinue 14 | 15 | 16 | Write-Host "test custom python runtime ..." 17 | $env:fc_component_function_name = "python310-$($env:OS)-$($env:PROCESSOR_ARCHITECTURE)" 18 | s build -t ./python/s.yaml 19 | s local invoke -e '{"hello":"fc custom python"}' -t ./python/s.yaml 20 | s deploy -y -t ./python/s.yaml 21 | s invoke -e '{"hello":"fc custom python"}' -t ./python/s.yaml 22 | s info -y -t ./python/s.yaml 23 | s remove -y -t ./python/s.yaml 24 | Remove-Item -Recurse -Force ./python/code/python -ErrorAction SilentlyContinue 25 | Remove-Item -Recurse -Force ./python/code/__pycache__ -ErrorAction SilentlyContinue 26 | 27 | Write-Host "test custom java(springboot) runtime ..." 28 | $env:fc_component_function_name = "springboot-$($env:OS)-$($env:PROCESSOR_ARCHITECTURE)" 29 | s deploy -y -t ./springboot/s.yaml 30 | s invoke --event-file ./springboot/event/http.json -t ./springboot/s.yaml 31 | s info -t ./springboot/s.yaml 32 | s jar_zip local invoke --event-file ./springboot/event/http.json -t ./springboot/s.yaml 33 | s jar local invoke --event-file ./springboot/event/http.json -t ./springboot/s.yaml 34 | s remove -y -t ./springboot/s.yaml 35 | Remove-Item -Recurse -Force ./springboot/code/target -ErrorAction SilentlyContinue 36 | -------------------------------------------------------------------------------- /__tests__/e2e/custom/springboot/code/.fcignore: -------------------------------------------------------------------------------- 1 | .s 2 | Dockerfile 3 | mvnw 4 | pom.xml 5 | src 6 | mvnw.cmd 7 | .fcignore 8 | -------------------------------------------------------------------------------- /__tests__/e2e/custom/springboot/code/.gitignore: -------------------------------------------------------------------------------- 1 | target -------------------------------------------------------------------------------- /__tests__/e2e/custom/springboot/code/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jdk-alpine 2 | ARG JAR_FILE=target/*.jar 3 | COPY ${JAR_FILE} webframework.jar 4 | ENTRYPOINT ["java","-jar","/webframework.jar"] -------------------------------------------------------------------------------- /__tests__/e2e/custom/springboot/code/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.8.RELEASE 9 | 10 | 11 | com.example 12 | webframework 13 | 0.0.1-SNAPSHOT 14 | webframework 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-test 30 | test 31 | 32 | 33 | 34 | 35 | ${project.name} 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-maven-plugin 40 | 41 | true 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /__tests__/e2e/custom/springboot/code/src/main/java/com/example/webframework/WebFrameworkApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.webframework; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.RequestHeader; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | @SpringBootApplication 15 | @RestController 16 | public class WebFrameworkApplication { 17 | 18 | public static void main(String[] args) { 19 | SpringApplication.run(WebFrameworkApplication.class, args); 20 | } 21 | 22 | @GetMapping("/") 23 | public ResponseEntity welcome() { 24 | String welcome = "" + 26 | "" + 27 | "Serverless Devs - Powered By Serverless Devs" + 28 | "" 29 | + 30 | "" + 31 | "" + 32 | "" + 33 | "" + 34 | "Devsapp" + 35 | "这是一个 Spring Boot 项目" + 36 | "自豪的通过Serverless Devs进行部署" + 37 | "您也可以快速体验: " + 38 | "• 下载Serverless Devs工具:npm install @serverless-devs/s" + 39 | "• 初始化项目:s init start-springboot" + 40 | "• 项目部署:s deploy" + 41 | "Serverless Devs 钉钉交流群:33947367 " + 42 | "
您也可以快速体验: " + 38 | "• 下载Serverless Devs工具:npm install @serverless-devs/s" + 39 | "• 初始化项目:s init start-springboot" + 40 | "• 项目部署:s deploy" + 41 | "Serverless Devs 钉钉交流群:33947367