├── .github └── workflows │ └── release.yml ├── .gitignore ├── LATEST ├── Makefile ├── README-EN.md ├── README.md ├── commons ├── Dockerfile.java11-stretch-base ├── Dockerfile.java8-stretch-base ├── Dockerfile.jessie-base ├── Dockerfile.php7.2-stretch-base ├── Dockerfile.python27stretch-base ├── Dockerfile.python36stretch-base ├── Dockerfile.python39stretch-base ├── Dockerfile.stretch-base ├── Makefile ├── System.Net.HttpListener.dll ├── debian-buster-sources.list ├── debian-jessie-sources.list ├── debian-stretch-sources.list ├── function-compute-mock-2.0.sh ├── function-compute-mock.sh ├── mocker │ ├── go.mod │ ├── go.sum │ └── main.go ├── nodejs-agent.sh ├── pip.conf ├── pycompile └── update-alternatives ├── custom.debian10 ├── base │ └── Dockerfile ├── build │ └── Dockerfile └── run │ └── Dockerfile ├── custom ├── base │ └── Dockerfile ├── build │ ├── Dockerfile │ ├── pom.xml │ └── settings.xml └── run │ └── Dockerfile ├── demos ├── dotnetcore2.1 │ ├── Program.cs │ ├── README.md │ ├── dotnetcore2.1.csproj │ └── env.list ├── java11 │ ├── README.md │ ├── env.list │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── examples │ │ │ └── Hello.java │ └── target │ │ └── java11-1.0.0.jar ├── java8 │ ├── README.md │ ├── env.list │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── examples │ │ │ └── Hello.java │ └── target │ │ └── java8-1.0.0.jar ├── nodejs10 │ ├── README.md │ ├── env.list │ └── index.js ├── nodejs12 │ ├── README.md │ ├── env.list │ └── index.js ├── nodejs6 │ ├── README.md │ ├── env.list │ └── index.js ├── nodejs8 │ ├── README.md │ ├── env.list │ └── index.js ├── php7.2 │ ├── README.md │ ├── env.list │ └── index.php ├── python2.7 │ ├── README.md │ ├── env.list │ └── index.py └── python3.6 │ ├── README.md │ ├── env.list │ └── index.py ├── dotnetcore2.1 ├── base │ └── Dockerfile ├── build │ └── Dockerfile └── run │ ├── Dockerfile │ ├── agent.sh │ ├── debugger │ ├── Debugger.csproj │ └── Program.cs │ ├── runtime │ └── Aliyun.Serverless.CA.dll │ └── vsdbg │ └── GetVsDbg.sh ├── figures └── fc-docker-nodejs6.png ├── go1 ├── base │ └── Dockerfile ├── build │ └── Dockerfile └── run │ └── Dockerfile ├── java11 ├── base │ ├── Dockerfile │ ├── java11-example │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── example │ │ │ └── App.java │ ├── pom.xml │ └── settings.xml ├── build │ └── Dockerfile └── run │ ├── Dockerfile │ └── agent.sh ├── java8 ├── base │ ├── Dockerfile │ ├── java8-example │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── example │ │ │ └── App.java │ ├── pom.xml │ └── settings.xml ├── build │ └── Dockerfile └── run │ ├── Dockerfile │ └── agent.sh ├── nodejs10 ├── base │ └── Dockerfile ├── build │ └── Dockerfile └── run │ └── Dockerfile ├── nodejs12 ├── base │ └── Dockerfile ├── build │ └── Dockerfile └── run │ └── Dockerfile ├── nodejs14 ├── base │ └── Dockerfile ├── build │ └── Dockerfile └── run │ └── Dockerfile ├── nodejs16 ├── base │ └── Dockerfile ├── build │ └── Dockerfile └── run │ └── Dockerfile ├── nodejs6 ├── base │ └── Dockerfile ├── build │ └── Dockerfile └── run │ └── Dockerfile ├── nodejs8 ├── base │ └── Dockerfile ├── build │ └── Dockerfile └── run │ └── Dockerfile ├── php7.2 ├── base │ ├── Dockerfile │ ├── composer.json │ └── composer.lock ├── build │ └── Dockerfile └── run │ ├── Dockerfile │ ├── agent.sh │ └── xdebug-2.6.1.tgz ├── python2.7 ├── base │ ├── Dockerfile │ └── requirements.txt ├── build │ └── Dockerfile └── run │ ├── Dockerfile │ └── agent.sh ├── python3.10 ├── base │ └── Dockerfile ├── build │ └── Dockerfile └── run │ └── Dockerfile ├── python3.6 ├── base │ ├── Dockerfile │ └── requirements.txt ├── build │ └── Dockerfile └── run │ ├── Dockerfile │ └── agent.sh ├── python3.9 ├── base │ ├── Dockerfile │ └── requirements.txt ├── build │ └── Dockerfile └── run │ ├── Dockerfile │ └── agent.sh ├── test.sh └── utils └── dump ├── dump-dotnetcore ├── .gitignore ├── Program.cs └── dump-dotnetcore.csproj ├── dump-java11 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── aliyun │ └── fc │ └── runtime │ └── DumpJava11.java ├── dump-java8 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── aliyun │ └── fc │ └── runtime │ └── DumpJava8.java ├── dump-nodejs ├── dump-nodejs.js ├── package-lock.json └── package.json ├── dump-php └── dump-php.php ├── dump-python └── dump-python.py └── s.yaml /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release fc-docker images 2 | 3 | on: 4 | release: 5 | types: [created] 6 | 7 | env: 8 | DOCKER_USER: ${{secrets.DOCKER_USER}} 9 | DOCKER_PASS: ${{secrets.DOCKER_PASS}} 10 | ALIYUN_DOCKER_USER: ${{secrets.ALIYUN_DOCKER_USER}} 11 | ALIYUN_DOCKER_PASS: ${{secrets.ALIYUN_DOCKER_PASS}} 12 | 13 | jobs: 14 | release-images: 15 | runs-on: ubuntu-latest 16 | strategy: 17 | max-parallel: 16 18 | fail-fast: false 19 | matrix: 20 | runtime: 21 | [ 22 | java8, 23 | java11, 24 | nodejs6, 25 | nodejs8, 26 | nodejs10, 27 | nodejs12, 28 | nodejs14, 29 | nodejs16, 30 | python2.7, 31 | python3.6, 32 | python3.9, 33 | php7.2, 34 | dotnetcore2.1, 35 | custom, 36 | go1, 37 | python3.10, 38 | custom.debian10, 39 | ] 40 | steps: 41 | - uses: actions/checkout@v2 42 | - uses: docker-practice/actions-setup-docker@master 43 | - name: build-push to dockerhub 44 | run: | 45 | make build-push RUNTIME=${{ matrix.runtime }} TAG=$(head -n 1 LATEST) VARIANT=base 46 | make build-push RUNTIME=${{ matrix.runtime }} TAG=$(head -n 1 LATEST) VARIANT=build 47 | make build-push RUNTIME=${{ matrix.runtime }} TAG=$(head -n 1 LATEST) VARIANT=run 48 | make build-push RUNTIME=${{ matrix.runtime }} TAG=latest VARIANT=base 49 | make build-push RUNTIME=${{ matrix.runtime }} TAG=latest VARIANT=build 50 | make build-push RUNTIME=${{ matrix.runtime }} TAG=latest VARIANT=run 51 | - name: build-push to acr 52 | run: | 53 | make build-push RUNTIME=${{ matrix.runtime }} TAG=$(head -n 1 LATEST) REGISTRY="registry.cn-beijing.aliyuncs.com" VARIANT=base 54 | make build-push RUNTIME=${{ matrix.runtime }} TAG=$(head -n 1 LATEST) REGISTRY="registry.cn-beijing.aliyuncs.com" VARIANT=build 55 | make build-push RUNTIME=${{ matrix.runtime }} TAG=$(head -n 1 LATEST) REGISTRY="registry.cn-beijing.aliyuncs.com" VARIANT=run 56 | make build-push RUNTIME=${{ matrix.runtime }} TAG=latest REGISTRY="registry.cn-beijing.aliyuncs.com" VARIANT=base 57 | make build-push RUNTIME=${{ matrix.runtime }} TAG=latest REGISTRY="registry.cn-beijing.aliyuncs.com" VARIANT=build 58 | make build-push RUNTIME=${{ matrix.runtime }} TAG=latest REGISTRY="registry.cn-beijing.aliyuncs.com" VARIANT=run 59 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | */.DS_Store 2 | .idea/ 3 | .settings/ 4 | .classpath 5 | .project 6 | *~ 7 | node_modules/ 8 | .vscode 9 | utils/dump/dump-java*/target/ 10 | *.iml 11 | demos/java*/target/** 12 | !demos/java*/target/java*-1.0.0.jar 13 | demos/dotnetcore2.1/[oO]bj 14 | demos/dotnetcore2.1/[bB]in 15 | dotnetcore2.1/run/debugger/[oO]bj 16 | dotnetcore2.1/run/debugger/[bB]in 17 | *.pyc 18 | __pycache__/ 19 | .bash_history 20 | utils/dump/.fun 21 | .s -------------------------------------------------------------------------------- /LATEST: -------------------------------------------------------------------------------- 1 | 1.10.10 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: login build build-and-push update-latest 2 | 3 | SHELL = /bin/bash 4 | .SHELLFLAGS = -ec 5 | 6 | IMAGE_PREFIX ?= runtime- 7 | REPO ?= aliyunfc 8 | 9 | RUNTIMES ?= java8 java11 nodejs6 nodejs8 nodejs10 nodejs12 nodejs14 nodejs16 python2.7 python3.6 python3.9 php7.2 dotnetcore2.1 go1 custom python3.10 custom.debian10 10 | VARIANTS ?= base build run 11 | 12 | FUN_VERSION ?= v3.6.20 13 | FCLI_VERSION ?= v1.0.4 14 | FUN_INSTALL_VERSION ?= v0.16.4 15 | 16 | # build or empty 17 | TAG_PREFIX := $(VARIANT:run%=%) 18 | # build or empty or build-version or -version 19 | WITH_VERSION := $(if $(TAG),$(TAG_PREFIX)-$(TAG),$(TAG_PREFIX)) 20 | 21 | # build or empty or build-version or version 22 | IMAGE_TAG_WITHOUT_HYPHEN := $(WITH_VERSION:-%=%) 23 | 24 | IMAGE_TAG := $(if $(IMAGE_TAG_WITHOUT_HYPHEN),:$(IMAGE_TAG_WITHOUT_HYPHEN),$(IMAGE_TAG_WITHOUT_HYPHEN)) 25 | 26 | IMAGE := $(REPO)/$(IMAGE_PREFIX)$(RUNTIME)$(IMAGE_TAG) 27 | 28 | DIR := $(RUNTIME)$(if $(VARIANT),/$(VARIANT)) 29 | 30 | BUILD_ARG_TAG := $(if $(TAG),base-$(TAG),base) 31 | 32 | check-runtime-env: 33 | ifndef RUNTIME 34 | $(error RUNTIME is undefined) 35 | endif 36 | 37 | check-variant-env: 38 | ifndef VARIANT 39 | $(error VARIANT is undefined) 40 | endif 41 | 42 | check-tag: 43 | ifndef TAG 44 | $(error TAG is undefined) 45 | endif 46 | 47 | login: 48 | @if [ -n "$(DOCKER_PASS)" ] && [ -n "$(DOCKER_USER)" ]; then \ 49 | if [ -n "$(REGISTRY)" ]; then \ 50 | echo "$(ALIYUN_DOCKER_PASS)" | docker login -u $(ALIYUN_DOCKER_USER) --password-stdin $(REGISTRY); \ 51 | else \ 52 | echo "$(DOCKER_PASS)" | docker login -u $(DOCKER_USER) --password-stdin; \ 53 | fi \ 54 | else \ 55 | if ! grep -q "index.docker.io" ~/.docker/config.json; then \ 56 | echo "you must provide DOCKER_USER and DOCKER_PASS for docker login."; \ 57 | exit 1; \ 58 | fi; \ 59 | fi; 60 | 61 | build: check-runtime-env 62 | @if [ -n "$(VARIANT)" ]; then \ 63 | echo "docker build -f \"$(DIR)/Dockerfile\" -t \"$(IMAGE)\" --build-arg TAG=$(BUILD_ARG_TAG) --build-arg FUN_VERSION=${FUN_VERSION} --build-arg FCLI_VERSION=${FCLI_VERSION} --build-arg FUN_INSTALL_VERSION=${FUN_INSTALL_VERSION} ."; \ 64 | if ! docker build -f "$(DIR)/Dockerfile" -t "$(IMAGE)" --build-arg TAG=$(BUILD_ARG_TAG) --build-arg FUN_VERSION=${FUN_VERSION} --build-arg FCLI_VERSION=${FCLI_VERSION} --build-arg FUN_INSTALL_VERSION=${FUN_INSTALL_VERSION} .; then \ 65 | exit 1; \ 66 | fi \ 67 | else \ 68 | for VARIANT in "base" "build" "run" ; do \ 69 | make build RUNTIME=$(RUNTIME) VARIANT=$$VARIANT TAG=$$TAG || exit 1; \ 70 | done \ 71 | fi; 72 | 73 | # build multi-arch images by docker buildx 74 | buildx-push: check-runtime-env login 75 | @if [ -n "$(VARIANT)" ]; then \ 76 | echo "docker buildx build --platform linux/amd64 --push -f \"$(DIR)/Dockerfile\" -t \"$(IMAGE)\" --build-arg TAG=$(BUILD_ARG_TAG) --build-arg FUN_VERSION=${FUN_VERSION} --build-arg FCLI_VERSION=${FCLI_VERSION} --build-arg FUN_INSTALL_VERSION=${FUN_INSTALL_VERSION} ."; \ 77 | if ! docker buildx build --platform linux/amd64 --push -f "$(DIR)/Dockerfile" -t "$(IMAGE)" --build-arg TAG=$(BUILD_ARG_TAG) --build-arg FUN_VERSION=${FUN_VERSION} --build-arg FCLI_VERSION=${FCLI_VERSION} --build-arg FUN_INSTALL_VERSION=${FUN_INSTALL_VERSION} .; then \ 78 | exit 1; \ 79 | fi \ 80 | else \ 81 | for VARIANT in "base" "build" "run" ; do \ 82 | make buildx-push RUNTIME=$(RUNTIME) VARIANT=$$VARIANT TAG=$$TAG || exit 1; \ 83 | done \ 84 | fi; 85 | 86 | test: check-runtime-env 87 | IMAGE=$(IMAGE) RUNTIME=$(RUNTIME) ./test.sh 88 | 89 | test-all: 90 | @for RUNTIME in $(RUNTIMES) ; do \ 91 | make test RUNTIME=$$RUNTIME VARIANT=run TAG=$$TAG; || exit 1; \ 92 | done 93 | 94 | build-all: 95 | @for RUNTIME in $(RUNTIMES) ; do \ 96 | for VARIANT in $(VARIANTS) ; do \ 97 | make build RUNTIME=$$RUNTIME VARIANT=$$VARIANT TAG=$$TAG || exit 1; \ 98 | done; \ 99 | done 100 | 101 | push: check-runtime-env login 102 | @if [ -n "$(VARIANT)" ]; then \ 103 | echo "docker push $(IMAGE)"; \ 104 | if [ -n "$(REGISTRY)" ]; then \ 105 | docker tag $(IMAGE) $(REGISTRY)/$(IMAGE) && \ 106 | docker push $(REGISTRY)/$(IMAGE); \ 107 | else \ 108 | docker push $(IMAGE); \ 109 | fi \ 110 | else \ 111 | for VARIANT in "base" "build" "run" ; do \ 112 | make push RUNTIME=$$RUNTIME VARIANT=$$VARIANT TAG=$$TAG; \ 113 | done \ 114 | fi; 115 | 116 | push-all: 117 | for RUNTIME in $(RUNTIMES) ; do \ 118 | for VARIANT in $(VARIANTS) ; do \ 119 | make push RUNTIME=$$RUNTIME VARIANT=$$VARIANT TAG=$$TAG; \ 120 | done \ 121 | done 122 | 123 | build-push: login build push 124 | 125 | build-push-all: login build-all push-all 126 | 127 | update-latest: check-runtime-env login 128 | @if [ -n "$(VARIANT)" ]; then \ 129 | LATEST_VERSION=$(shell (head -n 1 LATEST)); \ 130 | if [ "run" != "$$VARIANT" ]; then DEST_TAG=$$VARIANT; SOURCE_TAG=$$VARIANT-$$LATEST_VERSION; else DEST_TAG=latest; SOURCE_TAG=$$LATEST_VERSION; fi; \ 131 | if docker pull $(REPO)/$(IMAGE_PREFIX)$(RUNTIME):$$SOURCE_TAG; then \ 132 | if [ -n "$(REGISTRY)" ] ; then \ 133 | docker pull $(REPO)/$(IMAGE_PREFIX)$(RUNTIME):$$SOURCE_TAG && \ 134 | docker tag $(REPO)/$(IMAGE_PREFIX)$(RUNTIME):$$SOURCE_TAG $(REGISTRY)/$(REPO)/$(IMAGE_PREFIX)$(RUNTIME):$$DEST_TAG && \ 135 | docker push $(REGISTRY)/$(REPO)/$(IMAGE_PREFIX)$(RUNTIME):$$DEST_TAG; \ 136 | else \ 137 | docker pull $(REPO)/$(IMAGE_PREFIX)$(RUNTIME):$$SOURCE_TAG && \ 138 | docker tag $(REPO)/$(IMAGE_PREFIX)$(RUNTIME):$$SOURCE_TAG $(REPO)/$(IMAGE_PREFIX)$(RUNTIME):$$DEST_TAG && \ 139 | docker push $(REPO)/$(IMAGE_PREFIX)$(RUNTIME):$$DEST_TAG; \ 140 | fi \ 141 | fi; \ 142 | else \ 143 | for VARIANT in "base" "build" "run" ; do \ 144 | make update-latest RUNTIME=$$RUNTIME VARIANT=$$VARIANT TAG=$$TAG; \ 145 | done \ 146 | fi; 147 | 148 | 149 | update-latest-all: login 150 | @for RUNTIME in $(RUNTIMES) ; do \ 151 | for VARIANT in $(VARIANTS) ; do \ 152 | make update-latest RUNTIME=$$RUNTIME VARIANT=$$VARIANT; \ 153 | done \ 154 | done 155 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## fc-docker 2 | 3 | [![Build Status](https://travis-ci.org/aliyun/fc-docker.svg?branch=master)](https://travis-ci.org/aliyun/fc-docker) 4 | 5 | [English](https://github.com/aliyun/fc-docker/blob/master/README-EN.md) 6 | 7 | fc docker 是对线上函数运行环境的完全模拟,并且能够让您在本地编译、运行函数。 8 | 9 | ![fc docker nodejs6](./figures/fc-docker-nodejs6.png) 10 | 11 | 您能够通过 fc-docker 在本地机器开发测试您的函数,并且该函数的运行结果会与线上结果一致。 12 | 13 | 目前已经获得支持的 fc runtime 14 | 15 | | Runtime | Image | 16 | | ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 17 | | [nodejs6](https://hub.docker.com/r/aliyunfc/runtime-nodejs6/tags) | ![](https://img.shields.io/github/workflow/status/aliyun/fc-docker/release%20fc-docker%20images) ![](https://img.shields.io/docker/image-size/aliyunfc/runtime-nodejs6) ![](https://img.shields.io/docker/pulls/aliyunfc/runtime-nodejs6.svg) | 18 | | [nodejs8](https://hub.docker.com/r/aliyunfc/runtime-nodejs8/tags) | ![](https://img.shields.io/github/workflow/status/aliyun/fc-docker/release%20fc-docker%20images) ![](https://img.shields.io/docker/image-size/aliyunfc/runtime-nodejs8) ![](https://img.shields.io/docker/pulls/aliyunfc/runtime-nodejs8.svg) | 19 | | [nodejs10](https://hub.docker.com/r/aliyunfc/runtime-nodejs10/tags) | ![](https://img.shields.io/github/workflow/status/aliyun/fc-docker/release%20fc-docker%20images) ![](https://img.shields.io/docker/image-size/aliyunfc/runtime-nodejs10) ![](https://img.shields.io/docker/pulls/aliyunfc/runtime-nodejs10.svg) | 20 | | [nodejs12](https://hub.docker.com/r/aliyunfc/runtime-nodejs12/tags) | ![](https://img.shields.io/github/workflow/status/aliyun/fc-docker/release%20fc-docker%20images) ![](https://img.shields.io/docker/image-size/aliyunfc/runtime-nodejs12) ![](https://img.shields.io/docker/pulls/aliyunfc/runtime-nodejs12.svg) | 21 | | [nodejs14](https://hub.docker.com/r/aliyunfc/runtime-nodejs14/tags) | ![](https://img.shields.io/github/workflow/status/aliyun/fc-docker/release%20fc-docker%20images) ![](https://img.shields.io/docker/image-size/aliyunfc/runtime-nodejs14) ![](https://img.shields.io/docker/pulls/aliyunfc/runtime-nodejs14.svg) | 22 | | [python2.7](https://hub.docker.com/r/aliyunfc/runtime-python2.7/tags) | ![](https://img.shields.io/github/workflow/status/aliyun/fc-docker/release%20fc-docker%20images) ![](https://img.shields.io/docker/image-size/aliyunfc/runtime-python2.7) ![](https://img.shields.io/docker/pulls/aliyunfc/runtime-python2.7.svg) | 23 | | [python3.6](https://hub.docker.com/r/aliyunfc/runtime-python3.6/tags) | ![](https://img.shields.io/github/workflow/status/aliyun/fc-docker/release%20fc-docker%20images) ![](https://img.shields.io/docker/image-size/aliyunfc/runtime-python3.6) ![](https://img.shields.io/docker/pulls/aliyunfc/runtime-python3.6.svg) | 24 | | [python3.9](https://hub.docker.com/r/aliyunfc/runtime-python3.9/tags) | ![](https://img.shields.io/github/workflow/status/aliyun/fc-docker/release%20fc-docker%20images) ![](https://img.shields.io/docker/image-size/aliyunfc/runtime-python3.9) ![](https://img.shields.io/docker/pulls/aliyunfc/runtime-python3.9.svg) | 25 | | [java8](https://hub.docker.com/r/aliyunfc/runtime-java8/tags) | ![](https://img.shields.io/github/workflow/status/aliyun/fc-docker/release%20fc-docker%20images) ![](https://img.shields.io/docker/image-size/aliyunfc/runtime-java8) ![](https://img.shields.io/docker/pulls/aliyunfc/runtime-java8.svg) | 26 | | [java11](https://hub.docker.com/r/aliyunfc/runtime-java11/tags) | ![](https://img.shields.io/github/workflow/status/aliyun/fc-docker/release%20fc-docker%20images) ![](https://img.shields.io/docker/image-size/aliyunfc/runtime-java11) ![](https://img.shields.io/docker/pulls/aliyunfc/runtime-java11.svg) | 27 | | [php7.2](https://hub.docker.com/r/aliyunfc/runtime-php7.2/tags) | ![](https://img.shields.io/github/workflow/status/aliyun/fc-docker/release%20fc-docker%20images) ![](https://img.shields.io/docker/image-size/aliyunfc/runtime-php7.2) ![](https://img.shields.io/docker/pulls/aliyunfc/runtime-php7.2.svg) | 28 | | [dotnetcore2.1](https://hub.docker.com/r/aliyunfc/runtime-dotnetcore2.1/tags) | ![](https://img.shields.io/github/workflow/status/aliyun/fc-docker/release%20fc-docker%20images) ![](https://img.shields.io/docker/image-size/aliyunfc/runtime-dotnetcore2.1) ![](https://img.shields.io/docker/pulls/aliyunfc/runtime-dotnetcore2.1.svg) | 29 | | [custom](https://hub.docker.com/r/aliyunfc/runtime-custom/tags) | ![](https://img.shields.io/github/workflow/status/aliyun/fc-docker/release%20fc-docker%20images) ![](https://img.shields.io/docker/image-size/aliyunfc/runtime-custom) ![](https://img.shields.io/docker/pulls/aliyunfc/runtime-custom.svg) | 30 | | [go1](https://hub.docker.com/r/aliyunfc/runtime-go1/tags) | ![](https://img.shields.io/github/workflow/status/aliyun/fc-docker/release%20fc-docker%20images) ![](https://img.shields.io/docker/image-size/aliyunfc/runtime-go1) ![](https://img.shields.io/docker/pulls/aliyunfc/runtime-go1.svg) | 31 | 32 | 除了可以运行您的函数,本项目还包含 runtime 对应的用于编译项目的镜像。他们包含了常用的编译工具打包工具,比如 gcc、g++、npm、maven 等。 33 | 34 | 注意:[Fun](https://github.com/aliyun/fun) 现已基于 fc-docker,推出了 fun local 子命令,用于本地运行、调试函数。体验更好,推荐优先使用 Fun。 35 | 36 | ## 使用条件 37 | 38 | 要使用本项目,需要首先安装 [docker](https://www.docker.com/)。 39 | 40 | ## 示例 41 | 42 | 您可以在 demos 目录体验: 43 | 44 | ```shell 45 | # 进入 demos/nodejs6 或者 demos/nodejs8 或者 demos/nodejs10 或者 demos/nodejs12 目录,执行下面命令分别在对应目录中运行函数: 46 | 47 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-nodejs6 --handler "index.handler" --event '{"key" : "value"}' 48 | 49 | # 进入 demos/python2.7 目录,执行下面命令在 python2.7 中运行函数: 50 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-python2.7 --handler "index.handler" --event '{"some": "event"}' 51 | 52 | # 进入 demos/python3.6 目录,执行下面命令在 python3.6 中运行函数: 53 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-python3.6 --handler "index.handler" --event '{"some": "event"}' 54 | 55 | # 进入 demos/python3.9 目录,执行下面命令在 python3.9 中运行函数: 56 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-python3.9 --handler "index.handler" --event '{"some": "event"}' 57 | 58 | # 进入 demos/php7.2 目录,执行下面命令在 php7.2 中运行函数: 59 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-php7.2 --handler "index.handler" --event '{"some": "event"}' 60 | 61 | # 进入 demos/java8 目录,执行 mvn package 打包函数,然后执行下面命令运行函数: 62 | docker run -v $(pwd)/target/java8-1.0.0.jar:/code/java8-1.0.0.jar --env-file ./env.list aliyunfc/runtime-java8 --handler "examples.Hello::handleRequest" 63 | 64 | ``` 65 | 66 | 支持更多的长/短参数,列表如下: 67 | 68 | | 短参数 | 长参数 | 参数含义 | 69 | | :----- | :---------------------: | --------------------: | 70 | | -h | --handler | 函数入口 | 71 | | 无 | --timeout | 函数超时时间 | 72 | | -i | --initializer | 函数初始化入口 | 73 | | -e | --initializationTimeout | 初始化超时时间 | 74 | | 无 | --event | 上传 event | 75 | | 无 | --stdin | event 从 stdin 中获取 | 76 | | 无 | --server | server 模式 | 77 | 78 | build 镜像的使用方法: 79 | 80 | ```shell 81 | # 下载 nodejs 依赖(npm rebuild) 82 | docker run --rm -v $(pwd):/code aliyunfc/runtime-nodejs6:build 83 | 84 | # 在 build 容器中运行自定义命令 85 | docker run --rm -v $(pwd):/code aliyunfc/runtime-python2.7:build fun 86 | docker run --rm -v $(pwd):/code aliyunfc/runtime-python3.6:build fcli 87 | docker run --rm -v $(pwd):/code aliyunfc/runtime-python3.9:build fcli 88 | 89 | # 在 build 容器中运行交互式 bash 90 | docker run --rm -it -v $(pwd):/code aliyunfc/runtime-python2.7:build bash 91 | ``` 92 | 93 | ## 环境变量 94 | 95 | 本项目支持通过环境变量定制容器的一些行为,可用的环境变量包括: 96 | 97 | - FC_ACCESS_KEY_ID 98 | - FC_ACCESS_KEY_SECRET 99 | - FC_SECURITY_TOKEN 100 | - FC_FUNCTION_NAME 101 | 102 | 使用方法为: 103 | 104 | ```shell 105 | docker run --rm -it -e FC_ACCESS_KEY_ID=xxxxxxx -e FC_ACCESS_KEY_SECRET=xxxxxxxx -v $(pwd):/code nodejs6 106 | ``` 107 | 108 | ## build 环境中包含的依赖 109 | 110 | - fcli 111 | - fun 112 | - vim 113 | - zip 114 | - git 115 | - build-essential 116 | - clang 117 | - libgmp3-dev 118 | - python2.7-dev 119 | - apt-utils 120 | - dialog 121 | -------------------------------------------------------------------------------- /commons/Dockerfile.java11-stretch-base: -------------------------------------------------------------------------------- 1 | FROM aliyunfc/fc-runtime:stretch-base 2 | 3 | RUN mkdir -p /usr/share/man/man1 4 | RUN apt-get update && apt-get install -y \ 5 | openjdk-11-jdk \ 6 | maven \ 7 | --no-install-recommends && rm -r /var/lib/apt/lists/* -------------------------------------------------------------------------------- /commons/Dockerfile.java8-stretch-base: -------------------------------------------------------------------------------- 1 | FROM aliyunfc/fc-runtime:stretch-base 2 | 3 | RUN mkdir -p /usr/share/man/man1 4 | RUN apt-get update && apt-get install -y \ 5 | openjdk-8-jdk \ 6 | maven \ 7 | --no-install-recommends && rm -r /var/lib/apt/lists/* -------------------------------------------------------------------------------- /commons/Dockerfile.jessie-base: -------------------------------------------------------------------------------- 1 | FROM reg.docker.alibaba-inc.com/serverless/debian:8 2 | 3 | RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak 4 | COPY ./debian-jessie-sources.list /etc/apt/sources.list 5 | 6 | # Install common libraries 7 | RUN apt-get update && apt-get install -y --force-yes \ 8 | imagemagick \ 9 | libopencv-dev \ 10 | fonts-wqy-zenhei \ 11 | fonts-wqy-microhei \ 12 | cmake \ 13 | && rm -r /var/lib/apt/lists/* 14 | 15 | RUN curl -o /tmp/ffmpeg.tar.gz https://lambda-public.oss-cn-hangzhou.aliyuncs.com/runtime/ffmpeg.tar.gz \ 16 | && tar -xzf /tmp/ffmpeg.tar.gz -C /usr/local/bin \ 17 | && rm -rf /tmp/ffmpeg.tar.gz 18 | 19 | # support proxied debug 20 | RUN apt-get update && apt-get install -y \ 21 | nfs-common \ 22 | gnupg \ 23 | --no-install-recommends && rm -r /var/lib/apt/lists/* 24 | 25 | RUN apt-get update && apt-get install -y \ 26 | curl \ 27 | wget \ 28 | ca-certificates \ 29 | gcc \ 30 | g++ \ 31 | make \ 32 | --no-install-recommends && rm -r /var/lib/apt/lists/* 33 | 34 | RUN chmod -R 777 /tmp/ 35 | 36 | # Function configuration. 37 | ARG FC_RUNTIME_PATH=/var/fc/runtime 38 | ENV FC_FUNC_CODE_PATH=/code/ \ 39 | FC_FUNC_LOG_PATH=/var/log/fc 40 | 41 | ENV FC_SERVER_PORT=9000 \ 42 | FC_SERVER_LOG_LEVEL=INFO 43 | 44 | # http://bugs.python.org/issue19846 45 | # > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. 46 | ENV LANG C.UTF-8 47 | 48 | # Generate usernames 49 | RUN for i in $(seq 10000 10999); do \ 50 | echo "user$i:x:$i:$i::/tmp:/usr/sbin/nologin" >> /etc/passwd; \ 51 | done -------------------------------------------------------------------------------- /commons/Dockerfile.php7.2-stretch-base: -------------------------------------------------------------------------------- 1 | FROM aliyunfc/php7.2-stretch:standard 2 | 3 | RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak 4 | COPY debian-stretch-sources.list /etc/apt/sources.list 5 | 6 | # https://tracker.debian.org/pkg/imagemagick 7 | RUN apt-get update && apt-get install -y --force-yes \ 8 | wget \ 9 | unzip\ 10 | libssl-dev \ 11 | libpng-dev \ 12 | libbz2-dev \ 13 | cython \ 14 | libmagickwand-dev \ 15 | libmagickcore-dev \ 16 | libmemcached-dev \ 17 | --no-install-recommends && rm -r /var/lib/apt/lists/* 18 | 19 | RUN /bin/sh -c 'curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer' 20 | 21 | # ensure session.so loads before redis.so, https://github.com/phpredis/phpredis/issues/470 22 | RUN mv /usr/local/etc/php/conf.d/docker-php-ext-session.ini /usr/local/etc/php/conf.d/docker-php-ext-a_session.ini 23 | 24 | RUN pecl channel-update pecl.php.net 25 | RUN pecl install redis-4.1.1 26 | RUN pecl install xdebug-2.6.0 27 | RUN pecl install imagick-3.4.3 28 | RUN pecl install protobuf-3.6.0 29 | RUN pecl install memcached-3.0.4 30 | RUN docker-php-ext-enable redis xdebug imagick protobuf memcached 31 | 32 | RUN docker-php-ext-install zip gd -------------------------------------------------------------------------------- /commons/Dockerfile.python27stretch-base: -------------------------------------------------------------------------------- 1 | FROM aliyunfc/fc-runtime:stretch-base 2 | 3 | RUN apt-get update && apt-get install -y libbz2-dev python2.7 python-pip python2.7-dev libffi-dev libxml2-dev zlib1g-dev \ 4 | --no-install-recommends && rm -r /var/lib/apt/lists/* 5 | 6 | RUN apt-get update && apt-get install -y --no-install-recommends \ 7 | libcurl4-openssl-dev libssl-dev \ 8 | && rm -rf /var/lib/apt/lists/* 9 | # Start a shell by default 10 | CMD ["bash"] 11 | -------------------------------------------------------------------------------- /commons/Dockerfile.python36stretch-base: -------------------------------------------------------------------------------- 1 | FROM aliyunfc/fc-runtime:stretch-base 2 | 3 | ENV LANG C.UTF-8 4 | # Install python3.6 5 | RUN apt-get update && apt-get install -y --no-install-recommends \ 6 | libbluetooth-dev \ 7 | tk-dev \ 8 | libbz2-dev \ 9 | && rm -rf /var/lib/apt/lists/* 10 | 11 | RUN apt-get update && apt-get install -y \ 12 | gnupg \ 13 | dirmngr \ 14 | && rm -rf /var/lib/apt/lists/* 15 | 16 | ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D 17 | ENV PYTHON_VERSION 3.6.15 18 | 19 | RUN set -ex \ 20 | \ 21 | && wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \ 22 | && wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \ 23 | && export GNUPGHOME="$(mktemp -d)" \ 24 | && gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY" \ 25 | && gpg --batch --verify python.tar.xz.asc python.tar.xz \ 26 | && { command -v gpgconf > /dev/null && gpgconf --kill all || :; } \ 27 | && rm -rf "$GNUPGHOME" python.tar.xz.asc \ 28 | && mkdir -p /usr/src/python \ 29 | && tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \ 30 | && rm python.tar.xz \ 31 | \ 32 | && cd /usr/src/python \ 33 | && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ 34 | && ./configure \ 35 | --build="$gnuArch" \ 36 | --enable-loadable-sqlite-extensions \ 37 | --enable-optimizations \ 38 | --enable-option-checking=fatal \ 39 | --enable-shared \ 40 | --with-system-expat \ 41 | --with-system-ffi \ 42 | --without-ensurepip \ 43 | && make -j "$(nproc)" \ 44 | # setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916 45 | PROFILE_TASK='-m test.regrtest --pgo \ 46 | test_array \ 47 | test_base64 \ 48 | test_binascii \ 49 | test_binhex \ 50 | test_binop \ 51 | test_bytes \ 52 | test_c_locale_coercion \ 53 | test_class \ 54 | test_cmath \ 55 | test_codecs \ 56 | test_compile \ 57 | test_complex \ 58 | test_csv \ 59 | test_decimal \ 60 | test_dict \ 61 | test_float \ 62 | test_fstring \ 63 | test_hashlib \ 64 | test_io \ 65 | test_iter \ 66 | test_json \ 67 | test_long \ 68 | test_math \ 69 | test_memoryview \ 70 | test_pickle \ 71 | test_re \ 72 | test_set \ 73 | test_slice \ 74 | test_struct \ 75 | test_threading \ 76 | test_time \ 77 | test_traceback \ 78 | test_unicode \ 79 | ' \ 80 | && make install \ 81 | && rm -rf /usr/src/python \ 82 | \ 83 | && find /usr/local -depth \ 84 | \( \ 85 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 86 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name '*.a' \) \) \ 87 | -o \( -type f -a -name 'wininst-*.exe' \) \ 88 | \) -exec rm -rf '{}' + \ 89 | \ 90 | && ldconfig \ 91 | \ 92 | && python3 --version 93 | 94 | # make some useful symlinks that are expected to exist 95 | RUN cd /usr/local/bin \ 96 | && ln -s idle3 idle \ 97 | && ln -s pydoc3 pydoc \ 98 | && ln -s python3 python \ 99 | && ln -s python3-config python-config 100 | 101 | # if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value ''" 102 | ENV PYTHON_PIP_VERSION 21.2.4 103 | # https://github.com/docker-library/python/issues/365 104 | ENV PYTHON_SETUPTOOLS_VERSION 57.5.0 105 | # https://github.com/pypa/get-pip 106 | ENV PYTHON_GET_PIP_URL https://bootstrap.pypa.io/pip/3.6/get-pip.py 107 | 108 | RUN set -ex; \ 109 | \ 110 | wget -O get-pip.py "$PYTHON_GET_PIP_URL"; \ 111 | python get-pip.py \ 112 | --disable-pip-version-check \ 113 | --no-cache-dir \ 114 | "pip==$PYTHON_PIP_VERSION" \ 115 | "setuptools==$PYTHON_SETUPTOOLS_VERSION" \ 116 | ; \ 117 | pip --version; \ 118 | \ 119 | find /usr/local -depth \ 120 | \( \ 121 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 122 | -o \ 123 | \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ 124 | \) -exec rm -rf '{}' +; \ 125 | rm -f get-pip.py 126 | 127 | RUN apt-get update && apt-get install -y --no-install-recommends \ 128 | libcurl4-openssl-dev libssl-dev \ 129 | && rm -rf /var/lib/apt/lists/* 130 | 131 | # Start a shell by default 132 | CMD ["bash"] 133 | 134 | -------------------------------------------------------------------------------- /commons/Dockerfile.python39stretch-base: -------------------------------------------------------------------------------- 1 | FROM aliyunfc/fc-runtime:stretch-base 2 | 3 | ENV LANG C.UTF-8 4 | # Install python3.9 5 | RUN apt-get update && apt-get install -y --no-install-recommends \ 6 | build-essential libssl-dev zlib1g-dev \ 7 | libreadline-dev libsqlite3-dev llvm \ 8 | libncursesw5-dev xz-utils libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \ 9 | libbluetooth-dev \ 10 | tk-dev \ 11 | libbz2-dev \ 12 | && rm -rf /var/lib/apt/lists/* 13 | 14 | RUN apt-get update && apt-get install -y \ 15 | gnupg \ 16 | dirmngr \ 17 | && rm -rf /var/lib/apt/lists/* 18 | 19 | ENV GPG_KEY E3FF2839C048B25C084DEBE9B26995E310250568 20 | ENV PYTHON_VERSION 3.9.8 21 | 22 | RUN set -ex \ 23 | \ 24 | && wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \ 25 | && wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \ 26 | && export GNUPGHOME="$(mktemp -d)" \ 27 | && gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY" \ 28 | && gpg --batch --verify python.tar.xz.asc python.tar.xz \ 29 | && { command -v gpgconf > /dev/null && gpgconf --kill all || :; } \ 30 | && rm -rf "$GNUPGHOME" python.tar.xz.asc \ 31 | && mkdir -p /usr/src/python \ 32 | && tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \ 33 | && rm python.tar.xz \ 34 | \ 35 | && cd /usr/src/python \ 36 | && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ 37 | && ./configure \ 38 | --build="$gnuArch" \ 39 | --enable-loadable-sqlite-extensions \ 40 | --enable-optimizations \ 41 | --enable-option-checking=fatal \ 42 | --enable-shared \ 43 | --with-system-expat \ 44 | --with-system-ffi \ 45 | --without-ensurepip \ 46 | && make -j "$(nproc)" \ 47 | # setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916 48 | PROFILE_TASK='-m test.regrtest --pgo \ 49 | test_array \ 50 | test_base64 \ 51 | test_binascii \ 52 | test_binhex \ 53 | test_binop \ 54 | test_bytes \ 55 | test_c_locale_coercion \ 56 | test_class \ 57 | test_cmath \ 58 | test_codecs \ 59 | test_compile \ 60 | test_complex \ 61 | test_csv \ 62 | test_decimal \ 63 | test_dict \ 64 | test_float \ 65 | test_fstring \ 66 | test_hashlib \ 67 | test_io \ 68 | test_iter \ 69 | test_json \ 70 | test_long \ 71 | test_math \ 72 | test_memoryview \ 73 | test_pickle \ 74 | test_re \ 75 | test_set \ 76 | test_slice \ 77 | test_struct \ 78 | test_threading \ 79 | test_time \ 80 | test_traceback \ 81 | test_unicode \ 82 | ' \ 83 | && make install \ 84 | && rm -rf /usr/src/python \ 85 | \ 86 | && find /usr/local -depth \ 87 | \( \ 88 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 89 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name '*.a' \) \) \ 90 | -o \( -type f -a -name 'wininst-*.exe' \) \ 91 | \) -exec rm -rf '{}' + \ 92 | \ 93 | && ldconfig \ 94 | \ 95 | && python3 --version 96 | 97 | # make some useful symlinks that are expected to exist 98 | RUN cd /usr/local/bin \ 99 | && ln -s idle3 idle \ 100 | && ln -s pydoc3 pydoc \ 101 | && ln -s python3 python \ 102 | && ln -s python3-config python-config 103 | 104 | RUN apt-get purge -y --auto-remove \ 105 | build-essential libssl-dev zlib1g-dev \ 106 | libreadline-dev libsqlite3-dev llvm \ 107 | libncursesw5-dev xz-utils libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev 108 | 109 | # if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value ''" 110 | ENV PYTHON_PIP_VERSION 21.2.4 111 | # https://github.com/docker-library/python/issues/365 112 | ENV PYTHON_SETUPTOOLS_VERSION 57.5.0 113 | # https://github.com/pypa/get-pip 114 | ENV PYTHON_GET_PIP_URL https://bootstrap.pypa.io/get-pip.py 115 | 116 | RUN set -ex; \ 117 | \ 118 | wget -O get-pip.py "$PYTHON_GET_PIP_URL"; \ 119 | python get-pip.py \ 120 | --disable-pip-version-check \ 121 | --no-cache-dir \ 122 | "pip==$PYTHON_PIP_VERSION" \ 123 | "setuptools==$PYTHON_SETUPTOOLS_VERSION" \ 124 | ; \ 125 | pip --version; \ 126 | \ 127 | find /usr/local -depth \ 128 | \( \ 129 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 130 | -o \ 131 | \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ 132 | \) -exec rm -rf '{}' +; \ 133 | rm -f get-pip.py 134 | 135 | RUN apt-get update && apt-get install -y --no-install-recommends \ 136 | libcurl4-openssl-dev libssl-dev \ 137 | && rm -rf /var/lib/apt/lists/* -------------------------------------------------------------------------------- /commons/Dockerfile.stretch-base: -------------------------------------------------------------------------------- 1 | FROM debian:stretch 2 | 3 | LABEL MAINTAINER alibaba-serverless-fc 4 | 5 | #change apt-get source to aliyun 6 | RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak 7 | COPY debian-stretch-sources.list /etc/apt/sources.list 8 | 9 | # Suppress opencv error: "libdc1394 error: Failed to initialize libdc1394" 10 | RUN ln /dev/null /dev/raw1394 11 | 12 | # Install common libraries 13 | RUN apt-get update && apt-get install -y \ 14 | apt-utils \ 15 | procps \ 16 | wget \ 17 | libssl-dev \ 18 | telnet \ 19 | curl \ 20 | cython \ 21 | imagemagick \ 22 | libopencv-dev\ 23 | fonts-wqy-zenhei \ 24 | vim \ 25 | fonts-wqy-microhei \ 26 | libpng-dev \ 27 | libbz2-dev \ 28 | tk \ 29 | libmemcached11 \ 30 | libmemcachedutil2 \ 31 | --no-install-recommends && rm -r /var/lib/apt/lists/* 32 | 33 | # get libpng12-0,libmysqlclient18,libssl1.0.0 in jessie 34 | # https://packages.debian.org/search?keywords=libpng12-0 35 | # RUN cp /etc/apt/sources.list /etc/apt/sources.list.bak \ 36 | # && echo "deb http://deb.debian.org/debian/ jessie main contrib non-free" > /etc/apt/sources.list \ 37 | # && echo "deb-src http://deb.debian.org/debian/ jessie main contrib non-free" >> /etc/apt/sources.list \ 38 | # && echo "deb http://security.debian.org/ jessie/updates main contrib non-free" >> /etc/apt/sources.list \ 39 | # && echo "deb-src http://security.debian.org/ jessie/updates main contrib non-free" >> /etc/apt/sources.list \ 40 | # && echo "deb http://archive.debian.org/debian jessie-backports main contrib non-free" >> /etc/apt/sources.list \ 41 | # && echo "deb-src http://archive.debian.org/debian jessie-backports main contrib non-free" >> /etc/apt/sources.list \ 42 | # && echo "Acquire::Check-Valid-Until \"false\";" > /etc/apt/apt.conf.d/100disablechecks 43 | 44 | RUN cp /etc/apt/sources.list /etc/apt/sources.list.bak 45 | COPY ./debian-jessie-sources.list /etc/apt/sources.list 46 | # RUN apt-get install debian-archive-keyring 47 | 48 | RUN apt-get update && apt-get install -y \ 49 | libpng12-0 \ 50 | libmysqlclient18 \ 51 | libssl1.0.0 \ 52 | libwebp5 \ 53 | --no-install-recommends \ 54 | --allow-unauthenticated \ 55 | && rm -r /var/lib/apt/lists/* 56 | 57 | RUN mv /etc/apt/sources.list.bak /etc/apt/sources.list 58 | 59 | RUN apt-get update && apt-get install -y \ 60 | nfs-common gnupg ca-certificates \ 61 | --no-install-recommends && rm -r /var/lib/apt/lists/* 62 | 63 | RUN curl -o /tmp/ffmpeg.tar.gz https://lambda-public.oss-cn-hangzhou.aliyuncs.com/runtime/ffmpeg.tar.gz \ 64 | && tar -xzf /tmp/ffmpeg.tar.gz -C /usr/local/bin \ 65 | && rm -rf /tmp/ffmpeg.tar.gz 66 | 67 | RUN apt-get update && apt-get install -y \ 68 | libssl-dev \ 69 | gcc \ 70 | make \ 71 | g++ \ 72 | --no-install-recommends && rm -r /var/lib/apt/lists/* 73 | 74 | RUN chmod -R 777 /tmp/ 75 | 76 | # Function configuration. 77 | ARG FC_RUNTIME_PATH=/var/fc/runtime 78 | ENV FC_FUNC_CODE_PATH=/code/ \ 79 | FC_FUNC_LOG_PATH=/var/log/fc 80 | 81 | ENV FC_SERVER_PORT=9000 \ 82 | FC_SERVER_LOG_LEVEL=INFO 83 | 84 | # http://bugs.python.org/issue19846 85 | # > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. 86 | ENV LANG C.UTF-8 87 | 88 | # Generate usernames 89 | RUN for i in $(seq 10000 10999); do \ 90 | echo "user$i:x:$i:$i::/tmp:/usr/sbin/nologin" >> /etc/passwd; \ 91 | done -------------------------------------------------------------------------------- /commons/Makefile: -------------------------------------------------------------------------------- 1 | 2 | build: 3 | docker build -t aliyunfc/fc-runtime:java8-stretch-base -f Dockerfile.java8-stretch-base . 4 | docker build -t aliyunfc/fc-runtime:java11-stretch-base -f Dockerfile.java11-stretch-base . 5 | docker build -t aliyunfc/fc-runtime:python36-stretch-base -f Dockerfile.python36stretch-base . 6 | docker build -t aliyunfc/fc-runtime:python39-stretch-base -f Dockerfile.python39stretch-base . 7 | docker build -t aliyunfc/fc-runtime:python27-stretch-base -f Dockerfile.python27stretch-base . 8 | docker build -t aliyunfc/fc-runtime:php7.2-stretch-base -f Dockerfile.php7.2-stretch-base . 9 | 10 | push: 11 | docker push aliyunfc/fc-runtime:java8-stretch-base 12 | docker push aliyunfc/fc-runtime:java11-stretch-base 13 | docker push aliyunfc/fc-runtime:python36-stretch-base 14 | docker push aliyunfc/fc-runtime:python39-stretch-base 15 | docker push aliyunfc/fc-runtime:python27-stretch-base 16 | docker push aliyunfc/fc-runtime:php7.2-stretch-base 17 | 18 | build-and-push-jessie: 19 | docker build -t aliyunfc/fc-runtime:jessie -f Dockerfile.jessie-base . 20 | docker push aliyunfc/fc-runtime:jessie 21 | 22 | build-and-push-stretch: 23 | docker build -t aliyunfc/fc-runtime:stretch-base -f Dockerfile.stretch-base . 24 | docker push aliyunfc/fc-runtime:stretch-base 25 | 26 | build-and-push: 27 | make build 28 | make push -------------------------------------------------------------------------------- /commons/System.Net.HttpListener.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliyun/fc-docker/d3f748b5daf434c1ab97bdc6319dd01d60438259/commons/System.Net.HttpListener.dll -------------------------------------------------------------------------------- /commons/debian-buster-sources.list: -------------------------------------------------------------------------------- 1 | deb http://mirrors.aliyun.com/debian/ buster main non-free contrib 2 | deb http://mirrors.aliyun.com/debian-security buster/updates main 3 | deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib 4 | deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib 5 | 6 | deb-src http://mirrors.aliyun.com/debian-security buster/updates main 7 | deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib 8 | deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib 9 | deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib -------------------------------------------------------------------------------- /commons/debian-jessie-sources.list: -------------------------------------------------------------------------------- 1 | deb http://archive.debian.org/debian/ jessie main non-free contrib 2 | deb-src http://archive.debian.org/debian/ jessie main non-free contrib 3 | deb http://archive.debian.org/debian-security/ jessie/updates main non-free contrib 4 | deb-src http://archive.debian.org/debian-security/ jessie/updates main non-free contrib -------------------------------------------------------------------------------- /commons/debian-stretch-sources.list: -------------------------------------------------------------------------------- 1 | deb http://archive.debian.org/debian/ stretch main contrib non-free 2 | deb http://archive.debian.org/debian/ stretch-proposed-updates main non-free contrib 3 | deb http://archive.debian.org/debian/ stretch-backports main non-free contrib 4 | deb http://archive.debian.org/debian-security stretch/updates main contrib non-free 5 | deb-src http://archive.debian.org/debian/ stretch main contrib non-free 6 | deb-src http://archive.debian.org/debian/ stretch-proposed-updates main contrib non-free 7 | deb-src http://archive.debian.org/debian/ stretch-backports main contrib non-free 8 | deb-src http://archive.debian.org/debian-security stretch/updates main contrib non-free -------------------------------------------------------------------------------- /commons/function-compute-mock-2.0.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SHELL_DIR="$(dirname $0)" 4 | event="" 5 | 6 | GREEN='\033[0;32m' 7 | BLUE='\033[0;34m' 8 | NC='\033[0m' # No Color 9 | 10 | handler="index.handler" 11 | 12 | timeout=3 13 | memory=128 14 | initializer= 15 | initializationTimeout=3 16 | 17 | while true; do 18 | case "$1" in 19 | -h | --handler ) handler="$2"; shift 2;; 20 | -i | --initializer ) initializer="$2"; shift 2;; 21 | -e | --initializationTimeout ) initializationTimeout="$2"; shift 2 ;; 22 | --timeout ) timeout="$2"; shift 2 ;; 23 | --event ) event="$2"; shift 2 ;; 24 | --stdin ) STDIN=true; shift ;; # use stdin as event 25 | --http ) HTTP_MODE=true; shift ;; 26 | --event-decode ) EVENT_DECODE=true; shift ;; 27 | --server) SERVER_MODE=true; shift ;; 28 | --start) START_RUNTIME=true; shift ;; 29 | --fast-invoke) FAST_INVOKE=true; shift ;; 30 | -- ) shift; break ;; 31 | "" ) break ;; 32 | * ) echo -e "\n\t Please use the long and short parameter mode. \n\t For more details, please refer to https://github.com/aliyun/fc-docker. \n\n"; exit -1 ;; 33 | esac 34 | done 35 | 36 | 37 | agentScript="${AGENT_SCRIPT:-fc-rie}" 38 | agentPath="${SHELL_DIR}/${agentScript}" 39 | 40 | if [ ! -f "$agentPath" ]; then 41 | echo "error: $agentPath not exist" 42 | exit 1; 43 | fi 44 | 45 | #FAST_INVOKE=true 46 | if [ -n "$FAST_INVOKE" ]; then 47 | exec "$agentPath" --fastInvoke --initializer "$initializer" --initializationTimeout "$initializationTimeout" --handler "$handler" --timeout "$timeout" --event "$event" 48 | exit 0; 49 | fi 50 | 51 | if [ -n "$START_RUNTIME" ]; then 52 | if [ -n "$SERVER_MODE" ]; then 53 | exec "$agentPath" 54 | exit 0; 55 | else 56 | exec "$agentPath" & 57 | fi 58 | fi 59 | 60 | requestId="$(cat /proc/sys/kernel/random/uuid)" 61 | 62 | hostLimit="$(free -m | awk 'NR==2{printf $2 }')" 63 | 64 | dockerLimit=8589934592 #8G, 暂时随机设置的一个值 65 | # docker 20 版本有变更: https://github.com/oracle/docker-images/issues/1939 66 | if [[ -f /sys/fs/cgroup/cgroup.controllers ]]; then 67 | dockerLimit=8589934592 #8G, 暂时随机设置的一个值 68 | else 69 | dockerLimit="$[$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes) / 1024 / 1024]" 70 | fi 71 | 72 | # min(hostLimit, dockerLimit) 73 | memoryLimit=$([ $hostLimit -le $dockerLimit ] && echo $hostLimit || echo $dockerLimit) 74 | serverPort=${FC_SERVER_PORT:-9000} 75 | 76 | # wait until server started 77 | # link https://stackoverflow.com/questions/9609130/efficiently-test-if-a-port-is-open-on-linux-without-nmap-or-netcat 78 | while ! &>/dev/null /dev/null > /etc/sudoers 17 | 18 | ARG FUN_INSTALL_VERSION 19 | 20 | RUN curl -o fun-install.zip https://gosspublic.alicdn.com/fun-install/fun-install-${FUN_INSTALL_VERSION}-linux-64.zip \ 21 | && unzip -o fun-install.zip -d /usr/local/bin/ \ 22 | && rm fun-install.zip \ 23 | && mv /usr/local/bin/fun-install-v* /usr/local/bin/fun-install \ 24 | && ln -s /usr/local/bin/fun-install /usr/local/bin/s-install 25 | 26 | RUN mv /usr/bin/update-alternatives /usr/bin/update-alternatives-origin \ 27 | && ((test -f /usr/bin/pycompile && mv /usr/bin/pycompile /usr/bin/pycompile-origin) || true) 28 | 29 | COPY commons/update-alternatives /usr/bin/ 30 | 31 | COPY commons/pycompile /usr/bin/ 32 | 33 | RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ 34 | 35 | RUN ln -s /var/fc/lang/python3.10/bin/pip /usr/local/bin/pip 36 | 37 | WORKDIR /code 38 | -------------------------------------------------------------------------------- /custom.debian10/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM golang:1.20.2-buster as builder 3 | 4 | COPY commons/mocker /code 5 | 6 | WORKDIR /code 7 | 8 | # https://github.com/goproxy/goproxy.cn 9 | ENV GOPROXY https://goproxy.io 10 | 11 | RUN go mod download 12 | 13 | RUN GOARCH=amd64 GOOS=linux go build -o mock main.go 14 | 15 | FROM aliyunfc/runtime-custom.debian10:${TAG} 16 | 17 | COPY --from=builder /code/mock /var/fc/runtime/mock 18 | 19 | ENTRYPOINT ["/var/fc/runtime/mock"] 20 | -------------------------------------------------------------------------------- /custom/base/Dockerfile: -------------------------------------------------------------------------------- 1 | # aliyunfc/fc-runtime:custom-stretch-base see commons directory 2 | FROM aliyunfc/fc-runtime:custom-stretch-base-v1 3 | 4 | COPY ./commons/debian-stretch-sources.list /etc/apt/sources.list 5 | 6 | RUN apt-get update && apt-get install -y --no-install-recommends \ 7 | libcurl4-openssl-dev libssl-dev \ 8 | && rm -rf /var/lib/apt/lists/* 9 | 10 | ENV FC_SERVER_PORT=9000 \ 11 | FC_FUNC_CODE_PATH=/code 12 | 13 | ENV PYTHONPATH=/code 14 | 15 | ENV BOOTSTRAP_FILE=bootstrap 16 | 17 | ENV LD_LIBRARY_PATH=${FC_FUNC_CODE_PATH}:${FC_FUNC_CODE_PATH}/lib:/usr/local/lib 18 | 19 | WORKDIR ${FC_FUNC_CODE_PATH} 20 | 21 | # Start a shell by default 22 | CMD ["bash"] 23 | ENTRYPOINT [] -------------------------------------------------------------------------------- /custom/build/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-custom:${TAG} 3 | ENV DEBIAN_FRONTEND=noninteractive 4 | 5 | RUN mkdir -p /mnt/auto 6 | 7 | RUN apt-get update \ 8 | && apt-get --no-install-recommends install -y apt-utils ca-certificates \ 9 | dialog \ 10 | clang \ 11 | build-essential \ 12 | libgmp3-dev \ 13 | sudo \ 14 | libffi-dev \ 15 | zlibc \ 16 | zlib1g \ 17 | zlib1g-dev \ 18 | libssl-dev \ 19 | libreadline-dev \ 20 | && rm -rf /var/lib/apt/lists/* 21 | 22 | RUN echo "ALL ALL=NOPASSWD: ALL" >> /etc/sudoers 23 | 24 | ARG FUN_VERSION 25 | ARG FCLI_VERSION 26 | ARG FUN_INSTALL_VERSION 27 | 28 | RUN curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-${FCLI_VERSION}-linux-amd64.zip \ 29 | && unzip -o fcli.zip -d /usr/local/bin/ \ 30 | && rm fcli.zip 31 | 32 | RUN curl -o fun.zip https://gosspublic.alicdn.com/fun/fun-${FUN_VERSION}-linux.zip \ 33 | && unzip -o fun.zip -d /usr/local/bin/ \ 34 | && rm fun.zip \ 35 | && mv /usr/local/bin/fun-v* /usr/local/bin/fun 36 | 37 | RUN curl -o fun-install.zip https://gosspublic.alicdn.com/fun-install/fun-install-${FUN_INSTALL_VERSION}-linux-64.zip \ 38 | && unzip -o fun-install.zip -d /usr/local/bin/ \ 39 | && rm fun-install.zip \ 40 | && mv /usr/local/bin/fun-install-v* /usr/local/bin/fun-install \ 41 | && ln -s /usr/local/bin/fun-install /usr/local/bin/s-install 42 | 43 | RUN mv /usr/bin/update-alternatives /usr/bin/update-alternatives-origin \ 44 | && ((test -f /usr/bin/pycompile && mv /usr/bin/pycompile /usr/bin/pycompile-origin) || true) 45 | 46 | COPY commons/update-alternatives /usr/bin/ 47 | 48 | COPY commons/pycompile /usr/bin/ 49 | 50 | # custom maven speedup 51 | COPY custom/build/pom.xml . 52 | COPY custom/build/settings.xml /usr/share/maven/conf/settings.xml 53 | RUN ["mvn", "dependency:go-offline"] 54 | RUN rm -f pom.xml 55 | 56 | RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ 57 | RUN npm config set registry https://registry.npmmirror.com 58 | RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ 59 | RUN pip install --upgrade pip 60 | 61 | WORKDIR /code 62 | -------------------------------------------------------------------------------- /custom/build/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 | 12 | com.example 13 | demo 14 | 0.0.1-SNAPSHOT 15 | demo 16 | Demo project for Spring Boot 17 | 18 | 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-test 31 | test 32 | 33 | 34 | 35 | 36 | ${project.name} 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-maven-plugin 41 | 42 | true 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /custom/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM golang:1.12.9-stretch as builder 3 | 4 | COPY commons/mocker /code 5 | 6 | WORKDIR /code 7 | 8 | # https://github.com/goproxy/goproxy.cn 9 | ENV GOPROXY https://goproxy.io 10 | 11 | RUN go mod download 12 | 13 | RUN GOARCH=amd64 GOOS=linux go build -o mock main.go 14 | 15 | FROM aliyunfc/runtime-custom:${TAG} 16 | 17 | COPY --from=builder /code/mock /var/fc/runtime/custom/mock 18 | 19 | ENTRYPOINT ["/var/fc/runtime/custom/mock"] 20 | -------------------------------------------------------------------------------- /demos/dotnetcore2.1/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Text; 4 | using Microsoft.Extensions.Logging; 5 | 6 | using Aliyun.Serverless.Core; 7 | 8 | namespace dotnetcore2._1 9 | { 10 | public class App 11 | { 12 | public int counter; 13 | public App() 14 | { 15 | this.counter = 0; 16 | } 17 | 18 | public static string StreamToString(Stream stream) 19 | { 20 | using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) 21 | { 22 | return reader.ReadToEnd(); 23 | } 24 | } 25 | 26 | public void Initialize(IFcContext context) 27 | { 28 | ILogger logger = context.Logger; 29 | logger.LogInformation(String.Format("RequestID is {0} ", context.RequestId)); 30 | this.counter = this.counter + 1; 31 | } 32 | 33 | public Stream HandleRequest(Stream input, IFcContext context) 34 | { 35 | ILogger logger = context.Logger; 36 | logger.LogInformation(String.Format("Event {0} ", StreamToString(input))); 37 | logger.LogInformation(String.Format("Context {0} ", Newtonsoft.Json.JsonConvert.SerializeObject(context))); 38 | logger.LogInformation(String.Format("Handle request {0} ", context.RequestId)); 39 | this.counter = this.counter + 2; 40 | String counterString = String.Format("{0}", this.counter); 41 | byte[] data = Encoding.UTF8.GetBytes(counterString); 42 | MemoryStream output = new MemoryStream(); 43 | output.Write(data, 0, data.Length); 44 | output.Flush(); 45 | return output; 46 | } 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /demos/dotnetcore2.1/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Using short/long param 3 | docker run --rm -it -v $(pwd):/code aliyunfc/runtime-dotnetcore2.1 --handler "dotnetcore2.1::dotnetcore2._1.App::HandleRequest" 4 | 5 | docker run --rm -it -v $(pwd):/code aliyunfc/runtime-dotnetcore2.1 --handler "dotnetcore2.1::dotnetcore2._1.App::HandleRequest" --event '{"key" : "value"}' 6 | 7 | docker run --rm -it -e FC_ACCESS_KEY_ID=xxxxx -e FC_ACCESS_KEY_SECRET=xxxxx -v $(pwd):/code aliyunfc/runtime-dotnetcore2.1 --handler "dotnetcore2.1::dotnetcore2._1.App::HandleRequest" --event '{"key" : "value"}' 8 | 9 | # Using initializer feature. 10 | docker run --rm -it -v $(pwd):/code aliyunfc/runtime-dotnetcore2.1 --handler "dotnetcore2.1::dotnetcore2._1.App::HandleRequest" --initializer "dotnetcore2.1::dotnetcore2._1.App::Initialize" 11 | 12 | docker run --rm -it -v $(pwd):/code aliyunfc/runtime-nodejs6 --initializer "index.initializer" --handler "index.handler" --event '{"key" : "value"}' -------------------------------------------------------------------------------- /demos/dotnetcore2.1/dotnetcore2.1.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Library 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /demos/dotnetcore2.1/env.list: -------------------------------------------------------------------------------- 1 | FC_ACCESS_KEY_ID=xxxx 2 | FC_ACCESS_KEY_SECRET=yyyy 3 | FC_ACCOUNT_ID=123456 4 | FC_REGION=cn-shanghai 5 | FC_FUNCTION_NAME=func 6 | FC_HANDLER=index.handler 7 | FC_MEMORY_SIZE=128 8 | FC_TIMEOUT=3 9 | FC_INITIALIZER=index.initializer 10 | FC_INITIALIZATION_TIMEOUT=3 11 | FC_SERVICE_NAME=svr 12 | FC_SERVICE_LOG_PROJECT=undefined 13 | FC_SERVICE_LOG_STORE=undefined -------------------------------------------------------------------------------- /demos/java11/README.md: -------------------------------------------------------------------------------- 1 | ```bash 2 | # 本地是 jdk11 3 | mvn package 4 | 5 | docker run --rm -v $(pwd)/target/java11-1.0.0.jar:/code/java11-1.0.0.jar --env-file ./env.list aliyunfc/runtime-java11 --handler "examples.Hello::handleRequest" 6 | 7 | docker run --rm -v $(pwd)/target/java11-1.0.0.jar:/code/java11-1.0.0.jar --env-file ./env.list aliyunfc/runtime-java11 --handler "examples.Hello::handleRequest" 8 | ``` 9 | -------------------------------------------------------------------------------- /demos/java11/env.list: -------------------------------------------------------------------------------- 1 | FC_ACCESS_KEY_ID=xxxx 2 | FC_ACCESS_KEY_SECRET=yyyy 3 | FC_ACCOUNT_ID=123456 4 | FC_REGION=cn-shanghai 5 | FC_FUNCTION_NAME=func 6 | FC_HANDLER=index.handler 7 | FC_MEMORY_SIZE=128 8 | FC_TIMEOUT=3 9 | FC_INITIALIZER=index.initializer 10 | FC_INITIALIZATION_TIMEOUT=3 11 | FC_SERVICE_NAME=svr 12 | FC_SERVICE_LOG_PROJECT=undefined 13 | FC_SERVICE_LOG_STORE=undefined -------------------------------------------------------------------------------- /demos/java11/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | examples 6 | java11 7 | 1.0.0 8 | jar 9 | 10 | 11 | 12 | com.aliyun.fc.runtime 13 | fc-java-core 14 | 1.2.0 15 | 16 | 17 | 18 | 19 | 20 | 21 | maven-assembly-plugin 22 | 3.1.0 23 | 24 | 25 | jar-with-dependencies 26 | 27 | false 28 | 29 | 30 | 31 | make-assembly 32 | package 33 | 34 | single 35 | 36 | 37 | 38 | 39 | 40 | org.apache.maven.plugins 41 | maven-compiler-plugin 42 | 43 | 1.8 44 | 1.8 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /demos/java11/src/main/java/examples/Hello.java: -------------------------------------------------------------------------------- 1 | package examples; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.io.OutputStream; 7 | import java.util.Scanner; 8 | 9 | import com.aliyun.fc.runtime.*; 10 | 11 | public class Hello implements StreamRequestHandler, FunctionInitializer { 12 | public int counter; 13 | public Hello() { 14 | this.counter = 0; 15 | } 16 | 17 | @Override 18 | public void initialize(Context context) throws IOException { 19 | FunctionComputeLogger logger = context.getLogger(); 20 | logger.debug(String.format("RequestID is %s %n", context.getRequestId())); 21 | this.counter = this.counter + 1; 22 | } 23 | @Override 24 | public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException { 25 | FunctionComputeLogger logger = context.getLogger(); 26 | logger.debug(String.format("Handle request %s %n", context.getRequestId())); 27 | this.counter = this.counter + 2; 28 | String counterString = String.format("%d", this.counter); 29 | outputStream.write(new String(counterString).getBytes()); 30 | outputStream.flush(); 31 | } 32 | } -------------------------------------------------------------------------------- /demos/java11/target/java11-1.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliyun/fc-docker/d3f748b5daf434c1ab97bdc6319dd01d60438259/demos/java11/target/java11-1.0.0.jar -------------------------------------------------------------------------------- /demos/java8/README.md: -------------------------------------------------------------------------------- 1 | ```bash 2 | # 本地是 jdk8 3 | mvn package 4 | 5 | docker run --rm -v $(pwd)/target/java8-1.0.0.jar:/code/java8-1.0.0.jar --env-file ./env.list aliyunfc/runtime-java8 --handler "examples.Hello::handleRequest" 6 | 7 | docker run --rm -v $(pwd)/target/java8-1.0.0.jar:/code/java8-1.0.0.jar --env-file ./env.list aliyunfc/runtime-java8 --handler "examples.Hello::handleRequest" 8 | ``` 9 | -------------------------------------------------------------------------------- /demos/java8/env.list: -------------------------------------------------------------------------------- 1 | FC_ACCESS_KEY_ID=xxxx 2 | FC_ACCESS_KEY_SECRET=yyyy 3 | FC_ACCOUNT_ID=123456 4 | FC_REGION=cn-shanghai 5 | FC_FUNCTION_NAME=func 6 | FC_HANDLER=index.handler 7 | FC_MEMORY_SIZE=128 8 | FC_TIMEOUT=3 9 | FC_INITIALIZER=index.initializer 10 | FC_INITIALIZATION_TIMEOUT=3 11 | FC_SERVICE_NAME=svr 12 | FC_SERVICE_LOG_PROJECT=undefined 13 | FC_SERVICE_LOG_STORE=undefined -------------------------------------------------------------------------------- /demos/java8/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | examples 6 | java8 7 | 1.0.0 8 | jar 9 | 10 | 11 | 12 | com.aliyun.fc.runtime 13 | fc-java-core 14 | 1.2.0 15 | 16 | 17 | 18 | 19 | 20 | 21 | maven-assembly-plugin 22 | 3.1.0 23 | 24 | 25 | jar-with-dependencies 26 | 27 | false 28 | 29 | 30 | 31 | make-assembly 32 | package 33 | 34 | single 35 | 36 | 37 | 38 | 39 | 40 | org.apache.maven.plugins 41 | maven-compiler-plugin 42 | 43 | 1.8 44 | 1.8 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /demos/java8/src/main/java/examples/Hello.java: -------------------------------------------------------------------------------- 1 | package examples; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.io.OutputStream; 7 | import java.util.Scanner; 8 | 9 | import com.aliyun.fc.runtime.*; 10 | 11 | public class Hello implements StreamRequestHandler, FunctionInitializer { 12 | public int counter; 13 | public Hello() { 14 | this.counter = 0; 15 | } 16 | 17 | @Override 18 | public void initialize(Context context) throws IOException { 19 | FunctionComputeLogger logger = context.getLogger(); 20 | logger.debug(String.format("RequestID is %s %n", context.getRequestId())); 21 | this.counter = this.counter + 1; 22 | } 23 | @Override 24 | public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException { 25 | FunctionComputeLogger logger = context.getLogger(); 26 | logger.debug(String.format("Handle request %s %n", context.getRequestId())); 27 | this.counter = this.counter + 2; 28 | String counterString = String.format("%d", this.counter); 29 | outputStream.write(new String(counterString).getBytes()); 30 | outputStream.flush(); 31 | } 32 | } -------------------------------------------------------------------------------- /demos/java8/target/java8-1.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliyun/fc-docker/d3f748b5daf434c1ab97bdc6319dd01d60438259/demos/java8/target/java8-1.0.0.jar -------------------------------------------------------------------------------- /demos/nodejs10/README.md: -------------------------------------------------------------------------------- 1 | # Using short/long param 2 | 3 | ```bash 4 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-nodejs10 --handler "index.handler" 5 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-nodejs10 --handler "index.handler" --event '{"key" : "value"}' 6 | ``` 7 | 8 | # Using initializer feature. 9 | 10 | ```bash 11 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-nodejs10 --initializer "index.initializer" --handler "index.handler" --event '{"key" : "value"}' 12 | ``` 13 | -------------------------------------------------------------------------------- /demos/nodejs10/env.list: -------------------------------------------------------------------------------- 1 | FC_ACCESS_KEY_ID=xxxx 2 | FC_ACCESS_KEY_SECRET=yyyy 3 | FC_ACCOUNT_ID=123456 4 | FC_REGION=cn-shanghai 5 | FC_FUNCTION_NAME=func 6 | FC_HANDLER=index.handler 7 | FC_MEMORY_SIZE=128 8 | FC_TIMEOUT=3 9 | FC_INITIALIZER=index.initializer 10 | FC_INITIALIZATION_TIMEOUT=3 11 | FC_SERVICE_NAME=svr 12 | FC_SERVICE_LOG_PROJECT=undefined 13 | FC_SERVICE_LOG_STORE=undefined -------------------------------------------------------------------------------- /demos/nodejs10/index.js: -------------------------------------------------------------------------------- 1 | var counter = 0; 2 | exports.initializer = function(context, callback) { 3 | counter += 1; 4 | callback(null, ""); 5 | }; 6 | 7 | exports.handler = function(event, context, callback) { 8 | var eventObj = JSON.parse(event.toString()); 9 | console.log("event: " + event); 10 | console.log('context: ', JSON.stringify(context)); 11 | 12 | const data = { x: 42, y: 50 }; 13 | console.table(data); 14 | 15 | counter += 2; 16 | callback(null, String(counter)); 17 | }; -------------------------------------------------------------------------------- /demos/nodejs12/README.md: -------------------------------------------------------------------------------- 1 | # Using short/long param 2 | 3 | ```bash 4 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-nodejs12 --handler "index.handler" 5 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-nodejs12 --handler "index.handler" --event '{"key" : "value"}' 6 | ``` 7 | 8 | # Using initializer feature. 9 | 10 | ```bash 11 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-nodejs12 --initializer "index.initializer" --handler "index.handler" --event '{"key" : "value"}' 12 | ``` 13 | -------------------------------------------------------------------------------- /demos/nodejs12/env.list: -------------------------------------------------------------------------------- 1 | FC_ACCESS_KEY_ID=xxxx 2 | FC_ACCESS_KEY_SECRET=yyyy 3 | FC_ACCOUNT_ID=123456 4 | FC_REGION=cn-shanghai 5 | FC_FUNCTION_NAME=func 6 | FC_HANDLER=index.handler 7 | FC_MEMORY_SIZE=128 8 | FC_TIMEOUT=3 9 | FC_INITIALIZER=index.initializer 10 | FC_INITIALIZATION_TIMEOUT=3 11 | FC_SERVICE_NAME=svr 12 | FC_SERVICE_LOG_PROJECT=undefined 13 | FC_SERVICE_LOG_STORE=undefined -------------------------------------------------------------------------------- /demos/nodejs12/index.js: -------------------------------------------------------------------------------- 1 | var counter = 0; 2 | exports.initializer = function(context, callback) { 3 | counter += 1; 4 | callback(null, ""); 5 | }; 6 | 7 | exports.handler = function(event, context, callback) { 8 | // var eventObj = JSON.parse(event.toString()); 9 | console.log("event: " + event); 10 | console.log('context: ', JSON.stringify(context)); 11 | 12 | const object = { x: 42, y: 50 }; 13 | const entries = Object.entries(object); 14 | console.log(Object.fromEntries(entries)); // New grammar for nodejs 12 15 | 16 | counter += 2; 17 | callback(null, String(counter)); 18 | }; -------------------------------------------------------------------------------- /demos/nodejs6/README.md: -------------------------------------------------------------------------------- 1 | # Using short/long param 2 | 3 | ```bash 4 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-nodejs6 --handler "index.handler" 5 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-nodejs6 --handler "index.handler" --event '{"key" : "value"}' 6 | ``` 7 | 8 | # Using initializer feature. 9 | 10 | ```bash 11 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-nodejs6 --initializer "index.initializer" --handler "index.handler" --event '{"key" : "value"}' 12 | ``` 13 | -------------------------------------------------------------------------------- /demos/nodejs6/env.list: -------------------------------------------------------------------------------- 1 | FC_ACCESS_KEY_ID=xxxx 2 | FC_ACCESS_KEY_SECRET=yyyy 3 | FC_ACCOUNT_ID=123456 4 | FC_REGION=cn-shanghai 5 | FC_FUNCTION_NAME=func 6 | FC_HANDLER=index.handler 7 | FC_MEMORY_SIZE=128 8 | FC_TIMEOUT=3 9 | FC_INITIALIZER=index.initializer 10 | FC_INITIALIZATION_TIMEOUT=3 11 | FC_SERVICE_NAME=svr 12 | FC_SERVICE_LOG_PROJECT=undefined 13 | FC_SERVICE_LOG_STORE=undefined -------------------------------------------------------------------------------- /demos/nodejs6/index.js: -------------------------------------------------------------------------------- 1 | var counter = 0; 2 | exports.initializer = function(context, callback) { 3 | counter += 1; 4 | callback(null, ""); 5 | }; 6 | 7 | exports.handler = function(event, context, callback) { 8 | var eventObj = JSON.parse(event.toString()); 9 | console.log("event: " + event); 10 | console.log('context: ', JSON.stringify(context)); 11 | counter += 2; 12 | callback(null, String(counter)); 13 | }; -------------------------------------------------------------------------------- /demos/nodejs8/README.md: -------------------------------------------------------------------------------- 1 | # Using short/long param 2 | 3 | ```bash 4 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-nodejs8 --handler "index.handler" 5 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-nodejs8 --handler "index.handler" --event '{"key" : "value"}' 6 | ``` 7 | 8 | # Using initializer feature. 9 | 10 | ```bash 11 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-nodejs8 --initializer "index.initializer" --handler "index.handler" --event '{"key" : "value"}' 12 | ``` 13 | -------------------------------------------------------------------------------- /demos/nodejs8/env.list: -------------------------------------------------------------------------------- 1 | FC_ACCESS_KEY_ID=xxxx 2 | FC_ACCESS_KEY_SECRET=yyyy 3 | FC_ACCOUNT_ID=123456 4 | FC_REGION=cn-shanghai 5 | FC_FUNCTION_NAME=func 6 | FC_HANDLER=index.handler 7 | FC_MEMORY_SIZE=128 8 | FC_TIMEOUT=3 9 | FC_INITIALIZER=index.initializer 10 | FC_INITIALIZATION_TIMEOUT=3 11 | FC_SERVICE_NAME=svr 12 | FC_SERVICE_LOG_PROJECT=undefined 13 | FC_SERVICE_LOG_STORE=undefined -------------------------------------------------------------------------------- /demos/nodejs8/index.js: -------------------------------------------------------------------------------- 1 | var counter = 0; 2 | exports.initializer = function(context, callback) { 3 | counter += 1; 4 | callback(null, ""); 5 | }; 6 | 7 | exports.handler = function(event, context, callback) { 8 | var eventObj = JSON.parse(event.toString()); 9 | console.log("event: " + event); 10 | console.log('context: ', JSON.stringify(context)); 11 | counter += 2; 12 | callback(null, String(counter)); 13 | }; -------------------------------------------------------------------------------- /demos/php7.2/README.md: -------------------------------------------------------------------------------- 1 | # Using short/long param 2 | 3 | ```bash 4 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-php7.2 --handler "index.handler" 5 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-php7.2 --handler "index.handler" --event '{"key" : "value"}' 6 | ``` 7 | 8 | # Using initializer feature. 9 | 10 | ```bash 11 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-php7.2 --initializer "index.initializer" --handler "index.handler" --event '{"key" : "value"}' 12 | ``` 13 | -------------------------------------------------------------------------------- /demos/php7.2/env.list: -------------------------------------------------------------------------------- 1 | FC_ACCESS_KEY_ID=xxxx 2 | FC_ACCESS_KEY_SECRET=yyyy 3 | FC_ACCOUNT_ID=123456 4 | FC_REGION=cn-shanghai 5 | FC_FUNCTION_NAME=func 6 | FC_HANDLER=index.handler 7 | FC_MEMORY_SIZE=128 8 | FC_TIMEOUT=3 9 | FC_INITIALIZER=index.initializer 10 | FC_INITIALIZATION_TIMEOUT=3 11 | FC_SERVICE_NAME=svr 12 | FC_SERVICE_LOG_PROJECT=undefined 13 | FC_SERVICE_LOG_STORE=undefined -------------------------------------------------------------------------------- /demos/php7.2/index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demos/python2.7/README.md: -------------------------------------------------------------------------------- 1 | # Using short/long param 2 | 3 | ```bash 4 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-python2.7 --handler "index.handler" 5 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-python2.7 --handler "index.handler" --event '{"key" : "value"}' 6 | ``` 7 | 8 | # Using initializer feature. 9 | 10 | ```bash 11 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-python2.7 --initializer "index.initializer" --handler "index.handler" --event '{"key" : "value"}' 12 | ``` 13 | -------------------------------------------------------------------------------- /demos/python2.7/env.list: -------------------------------------------------------------------------------- 1 | FC_ACCESS_KEY_ID=xxxx 2 | FC_ACCESS_KEY_SECRET=yyyy 3 | FC_ACCOUNT_ID=123456 4 | FC_REGION=cn-shanghai 5 | FC_FUNCTION_NAME=func 6 | FC_HANDLER=index.handler 7 | FC_MEMORY_SIZE=128 8 | FC_TIMEOUT=3 9 | FC_INITIALIZER=index.initializer 10 | FC_INITIALIZATION_TIMEOUT=3 11 | FC_SERVICE_NAME=svr 12 | FC_SERVICE_LOG_PROJECT=undefined 13 | FC_SERVICE_LOG_STORE=undefined -------------------------------------------------------------------------------- /demos/python2.7/index.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | counter = 0 4 | def initializer(context): 5 | global counter 6 | counter += 1 7 | 8 | def handler(event, context): 9 | global counter 10 | counter += 2 11 | logger = logging.getLogger("handler") 12 | logger.setLevel(logging.INFO) 13 | logger.info('event: ' + event) 14 | logger.info('context: ' + str(context)) 15 | 16 | return counter -------------------------------------------------------------------------------- /demos/python3.6/README.md: -------------------------------------------------------------------------------- 1 | # Using short/long param 2 | 3 | ```bash 4 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-python3.6 --handler "index.handler" 5 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-python3.6 --handler "index.handler" --event '{"key" : "value"}' 6 | ``` 7 | 8 | # Using initializer feature. 9 | 10 | ```bash 11 | docker run --rm -v $(pwd):/code --env-file ./env.list aliyunfc/runtime-python3.6 --initializer "index.initializer" --handler "index.handler" --event '{"key" : "value"}' 12 | ``` 13 | -------------------------------------------------------------------------------- /demos/python3.6/env.list: -------------------------------------------------------------------------------- 1 | FC_ACCESS_KEY_ID=xxxx 2 | FC_ACCESS_KEY_SECRET=yyyy 3 | FC_ACCOUNT_ID=123456 4 | FC_REGION=cn-shanghai 5 | FC_FUNCTION_NAME=func 6 | FC_HANDLER=index.handler 7 | FC_MEMORY_SIZE=128 8 | FC_TIMEOUT=3 9 | FC_INITIALIZER=index.initializer 10 | FC_INITIALIZATION_TIMEOUT=3 11 | FC_SERVICE_NAME=svr 12 | FC_SERVICE_LOG_PROJECT=undefined 13 | FC_SERVICE_LOG_STORE=undefined -------------------------------------------------------------------------------- /demos/python3.6/index.py: -------------------------------------------------------------------------------- 1 | import logging 2 | counter = 0 3 | def initializer(context): 4 | global counter 5 | counter += 1 6 | 7 | def handler(event, context): 8 | global counter 9 | counter += 2 10 | logger = logging.getLogger("handler") 11 | logger.setLevel(logging.INFO) 12 | 13 | return counter 14 | -------------------------------------------------------------------------------- /dotnetcore2.1/base/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM registry.cn-beijing.aliyuncs.com/aliyunfc/runtime-dotnetcore2.1:dev-v3 2 | 3 | LABEL maintainer="alibaba-serverless-fc" 4 | 5 | RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak 6 | COPY commons/debian-stretch-sources.list /etc/apt/sources.list 7 | 8 | # Install .NET Core SDK 9 | ENV DOTNET_SDK_VERSION 2.1.803 10 | 11 | # https://dotnetcli.azureedge.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz 12 | RUN curl -SL --output dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz \ 13 | && dotnet_sha512='57d48d6ca1bd92ac348dc05220d984811c0cf005774d7afdfbbf125a842acb0a26572146ed25a7eb26f4e0404fe840b70d1e7ec1fb7c9a5c6cfe81fefc41b363' \ 14 | && echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \ 15 | && mkdir -p /usr/share/dotnet \ 16 | && tar -zxf dotnet.tar.gz -C /usr/share/dotnet \ 17 | && rm dotnet.tar.gz 18 | 19 | # FC runtime dir path 20 | ARG FC_RUNTIME_PATH=/var/fc/runtime 21 | 22 | ENV FC_SERVER_PATH=/var/fc/runtime/dotnetcore2.1 23 | ENV FC_SERVER_PORT=9000 \ 24 | FC_SERVER_CAM_PORT=10080 \ 25 | FC_SERVER_LOG_PATH=${FC_SERVER_PATH}/var/log \ 26 | FC_SERVER_LOG_LEVEL=info 27 | 28 | EXPOSE ${FC_SERVER_PORT} 29 | 30 | ENV FC_FUNC_CODE_PATH=/code/ \ 31 | FC_RUNTIME_ROOT_PATH=${FC_SERVER_PATH}/bootstrap \ 32 | FC_RUNTIME_SYSTEM_PATH=${FC_SERVER_PATH} 33 | 34 | ENV LD_LIBRARY_PATH=${FC_FUNC_CODE_PATH}:${FC_FUNC_CODE_PATH}lib:${FC_FUNC_CODE_PATH}runtimes/linux-x64/native \ 35 | PATH=${FC_FUNC_CODE_PATH}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 36 | 37 | # Create function directories. 38 | RUN mkdir -p \ 39 | ${FC_FUNC_CODE_PATH} \ 40 | ${FC_RUNTIME_ROOT_PATH} \ 41 | ${FC_RUNTIME_SYSTEM_PATH} 42 | 43 | # Change work directory. 44 | WORKDIR ${FC_SERVER_PATH} 45 | 46 | RUN mkdir -p ${FC_SERVER_LOG_PATH} 47 | RUN chmod 777 ${FC_SERVER_LOG_PATH} 48 | RUN chmod -R 777 /tmp/ 49 | 50 | # Generate usernames 51 | RUN for i in $(seq 10000 10999); do \ 52 | echo "user$i:x:$i:$i::/tmp:/usr/sbin/nologin" >> /etc/passwd; \ 53 | done 54 | 55 | ENV SystemLogLevel=TRACE 56 | ENV FcDotnetHttpUseLiteServer=true 57 | 58 | # Start a shell by default 59 | CMD ["bash"] 60 | -------------------------------------------------------------------------------- /dotnetcore2.1/build/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-dotnetcore2.1:${TAG} 3 | 4 | ENV DEBIAN_FRONTEND=noninteractive 5 | 6 | RUN mkdir -p /mnt/auto 7 | 8 | RUN apt-get update \ 9 | && apt-get --no-install-recommends install -y apt-utils ca-certificates \ 10 | dialog \ 11 | vim \ 12 | cmake \ 13 | zip \ 14 | unzip \ 15 | clang \ 16 | build-essential \ 17 | libgmp3-dev \ 18 | python2.7-dev \ 19 | sudo \ 20 | && rm -rf /var/lib/apt/lists/* 21 | 22 | RUN echo "ALL ALL=NOPASSWD: ALL" >> /etc/sudoers 23 | 24 | ARG FUN_VERSION 25 | ARG FCLI_VERSION 26 | ARG FUN_INSTALL_VERSION 27 | 28 | RUN curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-${FCLI_VERSION}-linux-amd64.zip \ 29 | && unzip -o fcli.zip -d /usr/local/bin/ \ 30 | && rm fcli.zip 31 | 32 | RUN curl -o fun.zip https://gosspublic.alicdn.com/fun/fun-${FUN_VERSION}-linux.zip \ 33 | && unzip -o fun.zip -d /usr/local/bin/ \ 34 | && rm fun.zip \ 35 | && mv /usr/local/bin/fun-v* /usr/local/bin/fun 36 | 37 | RUN curl -o fun-install.zip https://gosspublic.alicdn.com/fun-install/fun-install-${FUN_INSTALL_VERSION}-linux-64.zip \ 38 | && unzip -o fun-install.zip -d /usr/local/bin/ \ 39 | && rm fun-install.zip \ 40 | && mv /usr/local/bin/fun-install-v* /usr/local/bin/fun-install \ 41 | && ln -s /usr/local/bin/fun-install /usr/local/bin/s-install 42 | 43 | RUN mv /usr/bin/update-alternatives /usr/bin/update-alternatives-origin \ 44 | && ((test -f /usr/bin/pycompile && mv /usr/bin/pycompile /usr/bin/pycompile-origin) || true) 45 | 46 | COPY commons/update-alternatives /usr/bin/ 47 | 48 | COPY commons/pycompile /usr/bin/ 49 | 50 | WORKDIR /code -------------------------------------------------------------------------------- /dotnetcore2.1/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM golang:1.12.9-stretch as builder 3 | 4 | COPY commons/mocker /code 5 | 6 | WORKDIR /code 7 | 8 | # https://github.com/goproxy/goproxy.cn 9 | ENV GOPROXY https://goproxy.io 10 | 11 | RUN go mod download 12 | 13 | RUN GOARCH=amd64 GOOS=linux go build -o mock main.go 14 | 15 | FROM aliyunfc/runtime-dotnetcore2.1:${TAG} 16 | 17 | RUN rm -rf /var/runtime /var/lang && \ 18 | curl http://cli.so/ca_tgz/dotnetcore2.1.tgz | tar -zx -C / && \ 19 | rm -rf /var/fc/runtime/*/var/log/* 20 | 21 | RUN apt-get update \ 22 | && apt-get --no-install-recommends install -y apt-utils ca-certificates procps unzip \ 23 | && rm -rf /var/lib/apt/lists/* 24 | 25 | COPY dotnetcore2.1/run/agent.sh /var/fc/runtime/dotnetcore2.1/agent.sh 26 | 27 | COPY --from=builder /code/mock /var/fc/runtime/dotnetcore2.1/mock 28 | 29 | COPY dotnetcore2.1/run/vsdbg/GetVsDbg.sh /vsdbg/GetVsDbg.sh 30 | RUN bash /vsdbg/GetVsDbg.sh -v latest -l /vsdbg 31 | RUN apt-get purge -y unzip 32 | 33 | COPY dotnetcore2.1/run/runtime /var/fc/runtime/dotnetcore2.1/bootstrap 34 | # fix the dotnetcore2.1's bug on System.Net.HttpListener.dll. Once it's offically released, remove it. 35 | COPY commons/System.Net.HttpListener.dll /usr/share/dotnet/shared/Microsoft.NETCore.App/2.1.15 36 | 37 | COPY dotnetcore2.1/run/debugger /debugger 38 | WORKDIR /debugger 39 | RUN dotnet publish --configuration Release --output /debugger/output 40 | RUN cp /debugger/output/Debugger.* /var/fc/runtime/dotnetcore2.1/bootstrap 41 | 42 | 43 | RUN apt-get update && apt-get install -y nfs-common --no-install-recommends && rm -r /var/lib/apt/lists/* 44 | 45 | WORKDIR /code 46 | 47 | ENV AGENT_DIR=/var/fc/runtime/dotnetcore2.1 \ 48 | AGENT_SCRIPT=agent.sh 49 | 50 | ENTRYPOINT ["/var/fc/runtime/dotnetcore2.1/mock"] 51 | -------------------------------------------------------------------------------- /dotnetcore2.1/run/agent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | CURDIR="$( cd "$( /usr/bin/dirname "${BASH_SOURCE[0]}" )" && pwd -P )" 3 | 4 | # Set some default configuration. 5 | export FC_SERVER_PORT=${FC_SERVER_PORT:=9000} 6 | export FC_SERVER_PATH=${FC_SERVER_PATH:=${CURDIR}} 7 | export FC_SERVER_LOG_PATH=${FC_SERVER_LOG_PATH:=${CURDIR}/var/log} 8 | export FC_SERVER_LOG_LEVEL=${FC_SERVER_LOG_LEVEL:=INFO} 9 | 10 | export FC_FUNC_CODE_PATH=${FC_FUNC_CODE_PATH:=${CURDIR}} 11 | export FC_FUNC_LOG_PATH=${FC_FUNC_LOG_PATH:=${CURDIR}/var/log} 12 | 13 | serverPort=${FC_SERVER_PORT:-9000} 14 | codePath=${FC_FUNC_CODE_PATH:-${CURDIR}} 15 | /usr/bin/dotnet /var/fc/runtime/dotnetcore2.1/bootstrap/Aliyun.Serverless.CA.dll -port ${serverPort} -codepath ${codePath} -------------------------------------------------------------------------------- /dotnetcore2.1/run/debugger/Debugger.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Library 5 | netcoreapp2.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /dotnetcore2.1/run/debugger/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Threading.Tasks; 4 | 5 | namespace Debugger 6 | { 7 | public class DebuggerExtension 8 | { 9 | private static readonly TimeSpan DEBUGGER_STATUS_QUERY_INTERVAL = TimeSpan.FromMilliseconds(50); 10 | private static readonly TimeSpan DEBUGGER_STATUS_QUERT_TIMEOUT = TimeSpan.FromMinutes(10); 11 | 12 | public static void Run() 13 | { 14 | String debugOptions = Environment.GetEnvironmentVariable("DEBUG_OPTIONS"); 15 | if (!String.IsNullOrEmpty(debugOptions)) 16 | { 17 | Console.WriteLine("Waiting for the debugger to attach..."); 18 | 19 | if (!WaitForAttaching( 20 | DEBUGGER_STATUS_QUERY_INTERVAL, 21 | DEBUGGER_STATUS_QUERT_TIMEOUT)) 22 | { 23 | Console.WriteLine("Timeout. Proceeding without debugger."); 24 | } 25 | } 26 | } 27 | 28 | public static bool WaitForAttaching(TimeSpan interval, TimeSpan timeout) 29 | { 30 | Stopwatch stopwatch = Stopwatch.StartNew(); 31 | 32 | while (!System.Diagnostics.Debugger.IsAttached) 33 | { 34 | if (stopwatch.Elapsed > timeout) 35 | { 36 | return false; 37 | } 38 | Task.Delay(interval).Wait(); 39 | } 40 | return true; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /dotnetcore2.1/run/runtime/Aliyun.Serverless.CA.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliyun/fc-docker/d3f748b5daf434c1ab97bdc6319dd01d60438259/dotnetcore2.1/run/runtime/Aliyun.Serverless.CA.dll -------------------------------------------------------------------------------- /figures/fc-docker-nodejs6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliyun/fc-docker/d3f748b5daf434c1ab97bdc6319dd01d60438259/figures/fc-docker-nodejs6.png -------------------------------------------------------------------------------- /go1/base/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.17-buster -------------------------------------------------------------------------------- /go1/build/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.17-buster -------------------------------------------------------------------------------- /go1/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-go1:${TAG} 3 | ENV FC_RUNTIME=go1 4 | ENV FC_RIE_VERSION=0.0.4 5 | 6 | COPY commons/function-compute-mock-2.0.sh /var/fc/runtime/go1/mock 7 | RUN cd /var/fc/runtime/go1 && \ 8 | curl -o /tmp/fc-rie.tar.gz https://fc-runtime-public.oss-cn-hangzhou.aliyuncs.com/fc-rie-v${FC_RIE_VERSION}.tar.gz && \ 9 | tar xf /tmp/fc-rie.tar.gz -C /var/fc/runtime/go1/ && \ 10 | mv /var/fc/runtime/go1/fc-rie-x86_64 /var/fc/runtime/go1/fc-rie && \ 11 | rm /tmp/fc-rie.tar.gz 12 | 13 | WORKDIR /var/fc/runtime/go1 14 | 15 | ENTRYPOINT ["/var/fc/runtime/go1/mock"] 16 | -------------------------------------------------------------------------------- /java11/base/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM aliyunfc/fc-runtime:java11-stretch-base 2 | 3 | # Environment variables can be overwritten by running 4 | # $ docker run --env = 5 | ENV FC_SERVER_PATH=/var/fc/runtime/java11 6 | 7 | ENV FC_RUNTIME_ROOT_PATH=${FC_SERVER_PATH}/bootstrap \ 8 | FC_RUNTIME_SYSTEM_PATH=${FC_SERVER_PATH} 9 | 10 | ENV FC_SERVER_PORT=9000 \ 11 | FC_SERVER_LOG_PATH=${FC_SERVER_PATH}/var/log \ 12 | FC_SERVER_LOG_LEVEL=debug \ 13 | FC_FUNC_CODE_PATH=/code 14 | 15 | ENV LD_LIBRARY_PATH=${FC_FUNC_CODE_PATH}:${FC_FUNC_CODE_PATH}/lib 16 | 17 | RUN mkdir -p ${FC_SERVER_LOG_PATH} 18 | RUN chmod 777 ${FC_SERVER_LOG_PATH} 19 | RUN chmod -R 777 /tmp/ 20 | 21 | ENV MAVEN_REPOSITORY=/cache/maven.repository 22 | 23 | # Change work directory. 24 | WORKDIR ${FC_FUNC_CODE_PATH} 25 | 26 | RUN ln -s /bin/bash /usr/bin/bash \ 27 | && ln -s /bin/grep /usr/bin/grep 28 | 29 | # Copy all files to home directory. 30 | COPY java11/base/pom.xml . 31 | COPY java11/base/settings.xml /root/.m2/settings.xml 32 | 33 | #download all the dependencies 34 | RUN ["mvn", "clean", "install"] 35 | RUN ["mvn", "dependency:go-offline"] 36 | RUN rm -f pom.xml 37 | 38 | WORKDIR /root 39 | COPY ./java11/base/java11-example /root/java11-example 40 | WORKDIR /root/java11-example 41 | RUN ["mvn", "clean", "package"] 42 | WORKDIR /root 43 | RUN rm -rf java11-example -------------------------------------------------------------------------------- /java11/base/java11-example/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | example 5 | HelloFCJava 6 | jar 7 | 1.0-SNAPSHOT 8 | HelloFCJava 9 | 10 | 11 | 12 | junit 13 | junit 14 | 3.8.1 15 | test 16 | 17 | 18 | com.aliyun.fc.runtime 19 | fc-java-core 20 | 1.3.0 21 | 22 | 23 | 24 | 25 | 26 | 27 | maven-assembly-plugin 28 | 29 | 30 | jar-with-dependencies 31 | 32 | 33 | 34 | 35 | make-my-jar-with-dependencies 36 | package 37 | 38 | single 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 11 48 | 11 49 | true 50 | 51 | 52 | -------------------------------------------------------------------------------- /java11/base/java11-example/src/main/java/example/App.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.io.OutputStream; 6 | 7 | import com.aliyun.fc.runtime.Context; 8 | import com.aliyun.fc.runtime.StreamRequestHandler; 9 | import com.aliyun.fc.runtime.FunctionInitializer; 10 | 11 | /** 12 | * Hello world! 13 | * 14 | */ 15 | public class App implements StreamRequestHandler, FunctionInitializer { 16 | 17 | public void initialize(Context context) throws IOException { 18 | //TODO 19 | } 20 | 21 | @Override 22 | public void handleRequest( 23 | InputStream inputStream, OutputStream outputStream, Context context) throws IOException { 24 | outputStream.write(new String("hello world\n").getBytes()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /java11/base/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.aliyun.fc.runtime 6 | java-runtime 7 | 1.0 8 | 9 | 11 10 | UTF-8 11 | 9.4.18.v20190429 12 | 13 | 14 | 15 | central 16 | Alibaba Repositories Group 17 | http://repo.alibaba-inc.com/nexus/content/groups/public/ 18 | 19 | true 20 | 21 | 22 | true 23 | 24 | 25 | 26 | 27 | 28 | 29 | org.apache.maven.plugins 30 | maven-dependency-plugin 31 | 32 | 33 | copy-dependencies 34 | process-sources 35 | 36 | copy-dependencies 37 | 38 | 39 | ${project.build.directory}/lib 40 | false 41 | false 42 | true 43 | 44 | 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-assembly-plugin 50 | 51 | 52 | jar-with-dependencies 53 | 54 | 55 | true 56 | 57 | aliyun.serverless.runtime.context.AliFCLogger 58 | 59 | 60 | true 61 | 62 | 63 | 64 | 65 | 66 | create-my-bundle 67 | compile 68 | 69 | single 70 | 71 | 72 | 73 | jar-with-dependencies 74 | 75 | 76 | 77 | 78 | 79 | 80 | org.apache.maven.plugins 81 | maven-compiler-plugin 82 | 3.6.1 83 | 84 | ${project.java.version} 85 | ${project.java.version} 86 | ${project.build.sourceEncoding} 87 | 88 | -Xlint:unchecked 89 | 90 | 91 | 92 | 93 | org.apache.maven.plugins 94 | maven-surefire-plugin 95 | 2.20 96 | 97 | 98 | org.apache.maven.surefire 99 | surefire-junit47 100 | 2.20 101 | 102 | 103 | com.google.code.findbugs 104 | jsr305 105 | 2.0.1 106 | 107 | 108 | 109 | suites 110 | 4 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | com.fasterxml.jackson.core 120 | jackson-databind 121 | 2.8.8 122 | 123 | 124 | org.apache.logging.log4j 125 | log4j-api 126 | 2.17.0 127 | 128 | 129 | org.apache.logging.log4j 130 | log4j-core 131 | 2.17.0 132 | 133 | 134 | 135 | 136 | org.eclipse.jetty 137 | jetty-server 138 | ${project.jetty.version} 139 | 140 | 141 | 142 | 143 | commons-lang 144 | commons-lang 145 | 2.6 146 | 147 | 148 | 149 | 150 | com.aliyun.fc.runtime 151 | fc-java-core 152 | 1.3.1 153 | 154 | 155 | com.aliyun.fc.runtime 156 | fc-java-event 157 | 1.0.0 158 | test 159 | 160 | 161 | 162 | com.aliyun.oss 163 | aliyun-sdk-oss 164 | 2.6.1 165 | test 166 | 167 | 168 | junit 169 | junit 170 | 4.12 171 | test 172 | 173 | 174 | -------------------------------------------------------------------------------- /java11/base/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | alimaven 8 | aliyun maven 9 | http://maven.aliyun.com/nexus/content/groups/public/ 10 | central 11 | 12 | 13 | -------------------------------------------------------------------------------- /java11/build/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-java11:${TAG} 3 | ENV DEBIAN_FRONTEND=noninteractive 4 | 5 | RUN mkdir -p /mnt/auto 6 | RUN apt-get update \ 7 | && apt-get --no-install-recommends install -y apt-utils ca-certificates \ 8 | dialog \ 9 | vim \ 10 | cmake \ 11 | zip \ 12 | unzip \ 13 | clang \ 14 | build-essential \ 15 | libgmp3-dev \ 16 | python2.7-dev \ 17 | sudo \ 18 | && rm -rf /var/lib/apt/lists/* 19 | 20 | RUN echo "ALL ALL=NOPASSWD: ALL" >> /etc/sudoers 21 | 22 | ARG FUN_VERSION 23 | ARG FCLI_VERSION 24 | ARG FUN_INSTALL_VERSION 25 | 26 | RUN curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-${FCLI_VERSION}-linux-amd64.zip \ 27 | && unzip -o fcli.zip -d /usr/local/bin/ \ 28 | && rm fcli.zip 29 | 30 | RUN curl -o fun.zip https://gosspublic.alicdn.com/fun/fun-${FUN_VERSION}-linux.zip \ 31 | && unzip -o fun.zip -d /usr/local/bin/ \ 32 | && rm fun.zip \ 33 | && mv /usr/local/bin/fun-v* /usr/local/bin/fun 34 | 35 | RUN curl -o fun-install.zip https://gosspublic.alicdn.com/fun-install/fun-install-${FUN_INSTALL_VERSION}-linux-64.zip \ 36 | && unzip -o fun-install.zip -d /usr/local/bin/ \ 37 | && rm fun-install.zip \ 38 | && mv /usr/local/bin/fun-install-v* /usr/local/bin/fun-install \ 39 | && ln -s /usr/local/bin/fun-install /usr/local/bin/s-install 40 | 41 | RUN mv /usr/bin/update-alternatives /usr/bin/update-alternatives-origin \ 42 | && ((test -f /usr/bin/pycompile && mv /usr/bin/pycompile /usr/bin/pycompile-origin) || true) 43 | 44 | COPY commons/update-alternatives /usr/bin/ 45 | 46 | COPY commons/pycompile /usr/bin/ 47 | 48 | RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak 49 | COPY commons/debian-buster-sources.list /etc/apt/sources.list 50 | 51 | WORKDIR /code 52 | -------------------------------------------------------------------------------- /java11/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-java11:${TAG} 3 | 4 | RUN rm -rf /var/runtime /var/lang && \ 5 | curl http://cli.so/ca_tgz/java11.tgz | tar -zx -C / && \ 6 | rm -rf /var/fc/runtime/*/var/log/* 7 | 8 | COPY commons/function-compute-mock.sh /var/fc/runtime/java11/mock 9 | COPY java11/run/agent.sh /var/fc/runtime/java11/agent.sh 10 | 11 | # Set home working directory. 12 | WORKDIR ${FC_FUNC_CODE_PATH} 13 | 14 | #set async logger 15 | ENV Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector 16 | 17 | # Enable CDS 18 | RUN /usr/bin/java -Xshare:dump 19 | 20 | ENTRYPOINT ["/var/fc/runtime/java11/mock"] 21 | -------------------------------------------------------------------------------- /java11/run/agent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ################################################################### 3 | # To start the java server, use this script. 4 | #################################################################### 5 | 6 | Help() { 7 | echo "Usage:" 8 | echo " $0 command" 9 | echo "Commands" 10 | echo " start start up server" 11 | echo " help print help page" 12 | } 13 | 14 | 15 | if [ $# -eq 0 ] 16 | then 17 | echo "Missing arguments." 18 | Help 19 | exit 0; 20 | fi 21 | 22 | command=$1 23 | case ${command} in 24 | "start") 25 | # Save FC_* vars in local vars with keys lower-cased 26 | for ent in $(/usr/bin/env | /bin/grep FC_); do 27 | key=$(echo $ent | /usr/bin/cut -d= -f1) 28 | value=$(echo $ent | /usr/bin/cut -d= -f2) 29 | eval "$(echo $key | /usr/bin/tr 'A-Z' 'a-z')=$value" 30 | done 31 | 32 | # Since java doesn't have a way to unset environment vars, we unset them here. 33 | for ent in $(/usr/bin/env | /bin/grep FC_ | /bin/grep -v FC_FUNC_CODE_PATH); do 34 | key=$(echo $ent | /usr/bin/cut -d= -f1) 35 | unset $key 36 | done 37 | 38 | params="${DEBUG_OPTIONS} " 39 | params+="-cp ${fc_runtime_root_path}/*:${fc_runtime_root_path} " 40 | params+="-Dfc.runtime.system.path=${fc_runtime_system_path} " 41 | params+="-Dfc.func.code.path=${fc_func_code_path} " 42 | params+="-Dfile.encoding=UTF-8 " 43 | params+="-Dsun.jnu.encoding=UTF-8 " 44 | params+="-Dfc.server.log.path=${fc_server_log_path} " 45 | params+="-Xmx${fc_max_server_heap_size} -Xms${fc_min_server_heap_size} " 46 | 47 | params+="-XX:+UseSerialGC " 48 | params+="-Xshare:on " 49 | params+="-Djava.security.egd=file:/dev/./urandom " 50 | /usr/bin/java $params aliyun.serverless.runtime.http.AliFCAgent 51 | 52 | ;; 53 | "help") 54 | Help 55 | ;; 56 | *) 57 | Help 58 | ;; 59 | esac 60 | -------------------------------------------------------------------------------- /java8/base/Dockerfile: -------------------------------------------------------------------------------- 1 | # aliyunfc/fc-runtime:java8-stretch-base see commons directory 2 | FROM aliyunfc/fc-runtime:java8-stretch-base 3 | 4 | # Environment variables can be overwritten by running 5 | # $ docker run --env = 6 | ENV FC_SERVER_PATH=/var/fc/runtime/java8 7 | 8 | ENV FC_RUNTIME_ROOT_PATH=${FC_SERVER_PATH}/bootstrap \ 9 | FC_RUNTIME_SYSTEM_PATH=${FC_SERVER_PATH} 10 | 11 | ENV FC_SERVER_PORT=9000 \ 12 | FC_SERVER_LOG_PATH=${FC_SERVER_PATH}/var/log \ 13 | FC_SERVER_LOG_LEVEL=debug \ 14 | FC_FUNC_CODE_PATH=/code 15 | 16 | ENV LD_LIBRARY_PATH=${FC_FUNC_CODE_PATH}:${FC_FUNC_CODE_PATH}/lib 17 | 18 | RUN mkdir -p ${FC_SERVER_LOG_PATH} 19 | RUN chmod 777 ${FC_SERVER_LOG_PATH} 20 | RUN chmod -R 777 /tmp/ 21 | 22 | ENV MAVEN_REPOSITORY=/cache/maven.repository 23 | 24 | # Change work directory. 25 | WORKDIR ${FC_FUNC_CODE_PATH} 26 | 27 | RUN ln -s /bin/bash /usr/bin/bash \ 28 | && ln -s /bin/grep /usr/bin/grep 29 | 30 | # Copy all files to home directory. 31 | COPY java8/base/pom.xml . 32 | COPY java8/base/settings.xml /root/.m2/settings.xml 33 | 34 | #download all the dependencies 35 | RUN ["mvn", "clean", "install"] 36 | RUN ["mvn", "dependency:go-offline"] 37 | RUN rm -f pom.xml 38 | 39 | WORKDIR /root 40 | COPY ./java8/base/java8-example /root/java8-example 41 | WORKDIR /root/java8-example 42 | RUN ["mvn", "clean", "package"] 43 | WORKDIR /root 44 | RUN rm -rf java8-example -------------------------------------------------------------------------------- /java8/base/java8-example/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | example 5 | HelloFCJava 6 | jar 7 | 1.0-SNAPSHOT 8 | HelloFCJava 9 | 10 | 11 | 12 | junit 13 | junit 14 | 3.8.1 15 | test 16 | 17 | 18 | com.aliyun.fc.runtime 19 | fc-java-core 20 | 1.3.0 21 | 22 | 23 | 24 | 25 | 26 | 27 | maven-assembly-plugin 28 | 29 | 30 | jar-with-dependencies 31 | 32 | 33 | 34 | 35 | make-my-jar-with-dependencies 36 | package 37 | 38 | single 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 1.8 48 | 1.8 49 | true 50 | 51 | 52 | -------------------------------------------------------------------------------- /java8/base/java8-example/src/main/java/example/App.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.io.OutputStream; 6 | 7 | import com.aliyun.fc.runtime.Context; 8 | import com.aliyun.fc.runtime.StreamRequestHandler; 9 | import com.aliyun.fc.runtime.FunctionInitializer; 10 | 11 | /** 12 | * Hello world! 13 | * 14 | */ 15 | public class App implements StreamRequestHandler, FunctionInitializer { 16 | 17 | public void initialize(Context context) throws IOException { 18 | //TODO 19 | } 20 | 21 | @Override 22 | public void handleRequest( 23 | InputStream inputStream, OutputStream outputStream, Context context) throws IOException { 24 | outputStream.write(new String("hello world\n").getBytes()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /java8/base/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.aliyun.fc.runtime 6 | java-runtime 7 | 1.0 8 | 9 | 1.8 10 | UTF-8 11 | 9.4.18.v20190429 12 | 13 | 14 | 15 | central 16 | Alibaba Repositories Group 17 | http://repo.alibaba-inc.com/nexus/content/groups/public/ 18 | 19 | true 20 | 21 | 22 | true 23 | 24 | 25 | 26 | 27 | 28 | 29 | org.apache.maven.plugins 30 | maven-dependency-plugin 31 | 32 | 33 | copy-dependencies 34 | process-sources 35 | 36 | copy-dependencies 37 | 38 | 39 | ${project.build.directory}/lib 40 | false 41 | false 42 | true 43 | 44 | 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-assembly-plugin 50 | 51 | 52 | create-my-bundle 53 | compile 54 | 55 | single 56 | 57 | 58 | 59 | jar-with-dependencies 60 | 61 | 62 | 63 | 64 | 65 | 66 | org.apache.maven.plugins 67 | maven-compiler-plugin 68 | 3.6.1 69 | 70 | ${project.java.version} 71 | ${project.java.version} 72 | ${project.build.sourceEncoding} 73 | 74 | -Xlint:unchecked 75 | 76 | 77 | 78 | 79 | org.apache.maven.plugins 80 | maven-surefire-plugin 81 | 2.20 82 | 83 | 84 | org.apache.maven.surefire 85 | surefire-junit47 86 | 2.20 87 | 88 | 89 | com.google.code.findbugs 90 | jsr305 91 | 2.0.1 92 | 93 | 94 | 95 | suites 96 | 4 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | com.fasterxml.jackson.core 106 | jackson-databind 107 | 2.8.8 108 | 109 | 110 | org.apache.logging.log4j 111 | log4j-api 112 | 2.17.0 113 | 114 | 115 | org.apache.logging.log4j 116 | log4j-core 117 | 2.17.0 118 | 119 | 120 | 121 | 122 | org.eclipse.jetty 123 | jetty-server 124 | ${project.jetty.version} 125 | 126 | 127 | 128 | 129 | commons-lang 130 | commons-lang 131 | 2.6 132 | 133 | 134 | 135 | 136 | com.aliyun.fc.runtime 137 | fc-java-core 138 | 1.3.1 139 | 140 | 141 | com.aliyun.fc.runtime 142 | fc-java-event 143 | 1.0.0 144 | test 145 | 146 | 147 | 148 | com.aliyun.oss 149 | aliyun-sdk-oss 150 | 2.6.1 151 | test 152 | 153 | 154 | junit 155 | junit 156 | 4.12 157 | test 158 | 159 | 160 | -------------------------------------------------------------------------------- /java8/base/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | alimaven 8 | aliyun maven 9 | http://maven.aliyun.com/nexus/content/groups/public/ 10 | central 11 | 12 | 13 | -------------------------------------------------------------------------------- /java8/build/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-java8:${TAG} 3 | ENV DEBIAN_FRONTEND=noninteractive 4 | 5 | RUN mkdir -p /mnt/auto 6 | RUN apt-get -o Acquire::Check-Valid-Until=false update \ 7 | && apt-get --no-install-recommends install -y apt-utils ca-certificates \ 8 | dialog \ 9 | vim \ 10 | cmake \ 11 | zip \ 12 | unzip \ 13 | clang \ 14 | build-essential \ 15 | libgmp3-dev \ 16 | python2.7-dev \ 17 | sudo \ 18 | && rm -rf /var/lib/apt/lists/* 19 | 20 | RUN echo "ALL ALL=NOPASSWD: ALL" >> /etc/sudoers 21 | 22 | ARG FUN_VERSION 23 | ARG FCLI_VERSION 24 | ARG FUN_INSTALL_VERSION 25 | 26 | RUN curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-${FCLI_VERSION}-linux-amd64.zip \ 27 | && unzip -o fcli.zip -d /usr/local/bin/ \ 28 | && rm fcli.zip 29 | 30 | RUN curl -o fun.zip https://gosspublic.alicdn.com/fun/fun-${FUN_VERSION}-linux.zip \ 31 | && unzip -o fun.zip -d /usr/local/bin/ \ 32 | && rm fun.zip \ 33 | && mv /usr/local/bin/fun-v* /usr/local/bin/fun 34 | 35 | RUN curl -o fun-install.zip https://gosspublic.alicdn.com/fun-install/fun-install-${FUN_INSTALL_VERSION}-linux-64.zip \ 36 | && unzip -o fun-install.zip -d /usr/local/bin/ \ 37 | && rm fun-install.zip \ 38 | && mv /usr/local/bin/fun-install-v* /usr/local/bin/fun-install \ 39 | && ln -s /usr/local/bin/fun-install /usr/local/bin/s-install 40 | 41 | RUN mv /usr/bin/update-alternatives /usr/bin/update-alternatives-origin \ 42 | && ((test -f /usr/bin/pycompile && mv /usr/bin/pycompile /usr/bin/pycompile-origin) || true) 43 | 44 | COPY commons/update-alternatives /usr/bin/ 45 | 46 | COPY commons/pycompile /usr/bin/ 47 | 48 | WORKDIR /code 49 | -------------------------------------------------------------------------------- /java8/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-java8:${TAG} 3 | 4 | RUN rm -rf /var/runtime /var/lang && \ 5 | curl http://cli.so/ca_tgz/java8.tgz | tar -zx -C / && \ 6 | rm -rf /var/fc/runtime/*/var/log/* 7 | 8 | COPY commons/function-compute-mock.sh /var/fc/runtime/java8/mock 9 | COPY java8/run/agent.sh /var/fc/runtime/java8/agent.sh 10 | 11 | ENTRYPOINT ["/var/fc/runtime/java8/mock"] 12 | -------------------------------------------------------------------------------- /java8/run/agent.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | ################################################################### 3 | # To start the java server, use this script. 4 | #################################################################### 5 | 6 | Help() { 7 | echo "Usage:" 8 | echo " $0 command" 9 | echo "Commands" 10 | echo " start start up server" 11 | echo " help print help page" 12 | } 13 | 14 | 15 | if [ $# -eq 0 ] 16 | then 17 | echo "Missing arguments." 18 | Help 19 | exit 0; 20 | fi 21 | 22 | command=$1 23 | case ${command} in 24 | "start") 25 | # Save FC_* vars in local vars with keys lower-cased 26 | for ent in $(/usr/bin/env | /usr/bin/grep FC_); do 27 | key=$(echo $ent | /usr/bin/cut -d= -f1) 28 | value=$(echo $ent | /usr/bin/cut -d= -f2) 29 | eval "$(echo $key | /usr/bin/tr 'A-Z' 'a-z')=$value" 30 | done 31 | 32 | # Since java doesn't have a way to unset environment vars, we unset them here. 33 | for ent in $(/usr/bin/env | /usr/bin/grep FC_ | /usr/bin/grep -v FC_FUNC_CODE_PATH); do 34 | key=$(echo $ent | /usr/bin/cut -d= -f1) 35 | unset $key 36 | done 37 | 38 | params="${DEBUG_OPTIONS} " 39 | params+="-cp ${fc_runtime_root_path}/*:${fc_runtime_root_path} " 40 | if [[ "${fc_enable_log4j_config}" == "true" ]]; then 41 | params+="-Dlog4j.configurationFile=${fc_server_path}/src/main/resources/log4j2.xml " 42 | fi 43 | params+="-Dfc.runtime.system.path=${fc_runtime_system_path} " 44 | params+="-Dfc.func.code.path=${fc_func_code_path} " 45 | params+="-Dfile.encoding=UTF-8 " 46 | params+="-Dsun.jnu.encoding=UTF-8 " 47 | params+="-Dfc.server.log.path=${fc_server_log_path} " 48 | params+="-Xmx${fc_max_server_heap_size} -Xms${fc_min_server_heap_size} " 49 | 50 | if [[ "${fc_enable_new_java_ca}" == "true" ]]; then 51 | params+="-XX:+UseSerialGC " 52 | params+="-Xshare:auto " # fc-docker fix: fix java http trigger could not debug bug 53 | params+="-Dfc.enable.debug.java.ca=${fc_enable_debug_java_ca} " 54 | params+="-Djava.security.egd=file:/dev/./urandom " 55 | /usr/bin/java $params aliyun.serverless.runtime.http.AliFCAgent 56 | else 57 | params+="-Dsun.net.httpserver.idleInterval=3600 " 58 | /usr/bin/java $params aliyun.serverless.runtime.ContainerAgent 59 | fi 60 | 61 | ;; 62 | "help") 63 | Help 64 | ;; 65 | *) 66 | Help 67 | ;; 68 | esac 69 | -------------------------------------------------------------------------------- /nodejs10/base/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM aliyunfc/fc-runtime:stretch-base 2 | 3 | ENV NODE_VERSION v10.24.1 4 | RUN wget http://mirrors.nju.edu.cn/nodejs/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64.tar.gz -O /tmp/node-${NODE_VERSION}-linux-x64.tar.gz \ 5 | && cd /tmp && tar -zxvf /tmp/node-${NODE_VERSION}-linux-x64.tar.gz \ 6 | && cp /tmp/node-${NODE_VERSION}-linux-x64/bin/node /usr/local/bin/ \ 7 | && cp -r /tmp/node-${NODE_VERSION}-linux-x64/lib/node_modules /usr/local/lib/node_modules \ 8 | && cp -r /tmp/node-${NODE_VERSION}-linux-x64/include/node /usr/local/include/node \ 9 | && ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \ 10 | && ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \ 11 | && rm -rf /tmp/node-${NODE_VERSION}-linux-x64* 12 | 13 | # Environment variables. 14 | ENV FC_SERVER_PATH=/var/fc/runtime/nodejs10 15 | ENV FC_SERVER_LOG_PATH=${FC_SERVER_PATH}/var/log 16 | ENV LD_LIBRARY_PATH=${FC_FUNC_CODE_PATH}:${FC_FUNC_CODE_PATH}/lib 17 | ENV PATH=${FC_SERVER_PATH}/node_modules/.bin:${PATH} 18 | ENV NODE_PATH=/usr/local/lib/node_modules:/opt/nodejs/node10/node_modules:/opt/nodejs/node_modules 19 | 20 | # Create directory. 21 | RUN mkdir -p ${FC_SERVER_PATH} 22 | 23 | # Create directories. 24 | RUN mkdir -p \ 25 | ${FC_SERVER_LOG_PATH} 26 | 27 | RUN chmod 777 ${FC_SERVER_LOG_PATH} 28 | RUN chmod -R 777 /tmp/ 29 | 30 | # Change work directory. 31 | WORKDIR ${FC_SERVER_PATH} 32 | 33 | # Expose the port number. 34 | EXPOSE ${FC_SERVER_PORT} 35 | 36 | RUN npm install --global --unsafe-perm \ 37 | --registry http://registry.npmmirror.com \ 38 | node-pre-gyp 39 | 40 | # Install thrid party libraries for user function. 41 | RUN npm install --global --unsafe-perm \ 42 | --registry http://registry.npmmirror.com \ 43 | co@4.6.0 \ 44 | gm@1.23.0 \ 45 | ali-oss@4.10.1 \ 46 | aliyun-sdk@1.11.10 \ 47 | @alicloud/fc@1.2.2 \ 48 | tablestore@4.2.0\ 49 | @alicloud/fc2@2.1.0 \ 50 | opencv@6.2.0 \ 51 | body@5.1.0 \ 52 | raw-body@2.3.2 \ 53 | ali-mns@2.6.5 \ 54 | @alicloud/pop-core@1.7.0 \ 55 | @alicloud/fnf-2019-03-15@1.1.0 56 | 57 | RUN npm cache clean --force 58 | 59 | # Change work directory. 60 | WORKDIR ${FC_FUNC_CODE_PATH} 61 | 62 | # Start a shell by default 63 | CMD ["bash"] -------------------------------------------------------------------------------- /nodejs10/build/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-nodejs10:${TAG} 3 | 4 | RUN mkdir -p /mnt/auto 5 | RUN apt-get update \ 6 | && apt-get --no-install-recommends install -y apt-utils ca-certificates \ 7 | dialog \ 8 | vim \ 9 | cmake \ 10 | zip \ 11 | unzip \ 12 | clang \ 13 | build-essential \ 14 | libgmp3-dev \ 15 | python2.7-dev \ 16 | sudo \ 17 | && rm -rf /var/lib/apt/lists/* 18 | 19 | RUN echo "ALL ALL=NOPASSWD: ALL" >> /etc/sudoers 20 | 21 | ARG FUN_VERSION 22 | ARG FCLI_VERSION 23 | ARG FUN_INSTALL_VERSION 24 | 25 | RUN curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-${FCLI_VERSION}-linux-amd64.zip \ 26 | && unzip -o fcli.zip -d /usr/local/bin/ \ 27 | && rm fcli.zip 28 | 29 | RUN curl -o fun.zip https://gosspublic.alicdn.com/fun/fun-${FUN_VERSION}-linux.zip \ 30 | && unzip -o fun.zip -d /usr/local/bin/ \ 31 | && rm fun.zip \ 32 | && mv /usr/local/bin/fun-v* /usr/local/bin/fun 33 | 34 | RUN curl -o fun-install.zip https://gosspublic.alicdn.com/fun-install/fun-install-${FUN_INSTALL_VERSION}-linux-64.zip \ 35 | && unzip -o fun-install.zip -d /usr/local/bin/ \ 36 | && rm fun-install.zip \ 37 | && mv /usr/local/bin/fun-install-v* /usr/local/bin/fun-install \ 38 | && ln -s /usr/local/bin/fun-install /usr/local/bin/s-install 39 | 40 | RUN mv /usr/bin/update-alternatives /usr/bin/update-alternatives-origin \ 41 | && ((test -f /usr/bin/pycompile && mv /usr/bin/pycompile /usr/bin/pycompile-origin) || true) 42 | 43 | COPY commons/update-alternatives /usr/bin/ 44 | COPY commons/pycompile /usr/bin/ 45 | 46 | RUN npm config set registry https://registry.npmmirror.com 47 | 48 | RUN npm install -g yarn 49 | 50 | WORKDIR /code 51 | 52 | CMD ["npm", "rebuild"] 53 | -------------------------------------------------------------------------------- /nodejs10/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-nodejs10:${TAG} 3 | 4 | RUN rm -rf /var/runtime /var/lang && \ 5 | curl http://cli.so/ca_tgz/nodejs10.tgz | tar -zx -C / && \ 6 | rm -rf /var/fc/runtime/*/var/log/* 7 | 8 | COPY commons/function-compute-mock.sh /var/fc/runtime/nodejs10/mock 9 | COPY commons/nodejs-agent.sh /var/fc/runtime/nodejs10/agent.sh 10 | 11 | ENTRYPOINT ["/var/fc/runtime/nodejs10/mock"] 12 | -------------------------------------------------------------------------------- /nodejs12/base/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM aliyunfc/fc-runtime:stretch-base 2 | 3 | ENV NODE_VERSION v12.22.1 4 | RUN wget http://mirrors.nju.edu.cn/nodejs/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64.tar.gz -O /tmp/node-${NODE_VERSION}-linux-x64.tar.gz \ 5 | && cd /tmp && tar -zxvf /tmp/node-${NODE_VERSION}-linux-x64.tar.gz \ 6 | && cp /tmp/node-${NODE_VERSION}-linux-x64/bin/node /usr/local/bin/ \ 7 | && cp -r /tmp/node-${NODE_VERSION}-linux-x64/lib/node_modules /usr/local/lib/node_modules \ 8 | && cp -r /tmp/node-${NODE_VERSION}-linux-x64/include/node /usr/local/include/node \ 9 | && ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \ 10 | && ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \ 11 | && rm -rf /tmp/node-${NODE_VERSION}-linux-x64* 12 | 13 | # Environment variables. 14 | ENV FC_SERVER_PATH=/var/fc/runtime/nodejs12 15 | ENV FC_SERVER_LOG_PATH=${FC_SERVER_PATH}/var/log 16 | ENV LD_LIBRARY_PATH=${FC_FUNC_CODE_PATH}:${FC_FUNC_CODE_PATH}/lib 17 | ENV PATH=${FC_SERVER_PATH}/node_modules/.bin:${PATH} 18 | ENV NODE_PATH=/usr/local/lib/node_modules:/opt/nodejs/node12/node_modules:/opt/nodejs/node_modules 19 | 20 | # Create directory. 21 | RUN mkdir -p ${FC_SERVER_PATH} 22 | 23 | # Create directories. 24 | RUN mkdir -p \ 25 | ${FC_SERVER_LOG_PATH} 26 | 27 | RUN chmod 777 ${FC_SERVER_LOG_PATH} 28 | RUN chmod -R 777 /tmp/ 29 | 30 | # Change work directory. 31 | WORKDIR ${FC_SERVER_PATH} 32 | 33 | # Expose the port number. 34 | EXPOSE ${FC_SERVER_PORT} 35 | 36 | RUN npm install --global --unsafe-perm \ 37 | --registry http://registry.npmmirror.com \ 38 | node-gyp rebuild 39 | 40 | # Install thrid party libraries for user function. 41 | RUN npm install --global --unsafe-perm \ 42 | --registry http://registry.npmmirror.com \ 43 | co@4.6.0 \ 44 | gm@1.23.0 \ 45 | ali-oss@6.6.0 \ 46 | aliyun-sdk@1.12.3 \ 47 | @alicloud/fc@1.2.3 \ 48 | tablestore@5.0.7\ 49 | @alicloud/fc2@2.2.0 \ 50 | opencv@7.0.0 \ 51 | body@5.1.0 \ 52 | raw-body@2.4.1 \ 53 | ali-mns@2.6.8 \ 54 | @alicloud/pop-core@1.7.9 \ 55 | @alicloud/fnf-2019-03-15@1.1.0 56 | 57 | RUN npm cache clean --force 58 | 59 | # Change work directory. 60 | WORKDIR ${FC_FUNC_CODE_PATH} 61 | 62 | # Start a shell by default 63 | CMD ["bash"] -------------------------------------------------------------------------------- /nodejs12/build/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-nodejs12:${TAG} 3 | 4 | RUN mkdir -p /mnt/auto 5 | RUN apt-get update \ 6 | && apt-get --no-install-recommends install -y apt-utils ca-certificates \ 7 | dialog \ 8 | vim \ 9 | cmake \ 10 | zip \ 11 | unzip \ 12 | clang \ 13 | build-essential \ 14 | libgmp3-dev \ 15 | python2.7-dev \ 16 | sudo \ 17 | && rm -rf /var/lib/apt/lists/* 18 | 19 | RUN echo "ALL ALL=NOPASSWD: ALL" >> /etc/sudoers 20 | 21 | ARG FUN_VERSION 22 | ARG FCLI_VERSION 23 | ARG FUN_INSTALL_VERSION 24 | 25 | RUN curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-${FCLI_VERSION}-linux-amd64.zip \ 26 | && unzip -o fcli.zip -d /usr/local/bin/ \ 27 | && rm fcli.zip 28 | 29 | RUN curl -o fun.zip https://gosspublic.alicdn.com/fun/fun-${FUN_VERSION}-linux.zip \ 30 | && unzip -o fun.zip -d /usr/local/bin/ \ 31 | && rm fun.zip \ 32 | && mv /usr/local/bin/fun-v* /usr/local/bin/fun 33 | 34 | RUN curl -o fun-install.zip https://gosspublic.alicdn.com/fun-install/fun-install-${FUN_INSTALL_VERSION}-linux-64.zip \ 35 | && unzip -o fun-install.zip -d /usr/local/bin/ \ 36 | && rm fun-install.zip \ 37 | && mv /usr/local/bin/fun-install-v* /usr/local/bin/fun-install \ 38 | && ln -s /usr/local/bin/fun-install /usr/local/bin/s-install 39 | 40 | RUN mv /usr/bin/update-alternatives /usr/bin/update-alternatives-origin \ 41 | && ((test -f /usr/bin/pycompile && mv /usr/bin/pycompile /usr/bin/pycompile-origin) || true) 42 | 43 | COPY commons/update-alternatives /usr/bin/ 44 | COPY commons/pycompile /usr/bin/ 45 | 46 | RUN npm config set registry https://registry.npmmirror.com 47 | 48 | RUN npm install -g yarn 49 | 50 | WORKDIR /code 51 | 52 | CMD ["npm", "rebuild"] 53 | -------------------------------------------------------------------------------- /nodejs12/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-nodejs12:${TAG} 3 | 4 | RUN rm -rf /var/runtime /var/lang && \ 5 | curl http://cli.so/ca_tgz/nodejs12.tgz | tar -zx -C / && \ 6 | rm -rf /var/fc/runtime/*/var/log/* 7 | 8 | COPY commons/function-compute-mock.sh /var/fc/runtime/nodejs12/mock 9 | COPY commons/nodejs-agent.sh /var/fc/runtime/nodejs12/agent.sh 10 | 11 | ENTRYPOINT ["/var/fc/runtime/nodejs12/mock"] 12 | -------------------------------------------------------------------------------- /nodejs14/base/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM aliyunfc/fc-runtime:stretch-base 2 | 3 | ENV NODE_VERSION v14.18.1 4 | RUN wget http://mirrors.nju.edu.cn/nodejs/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64.tar.gz -O /tmp/node-${NODE_VERSION}-linux-x64.tar.gz \ 5 | && cd /tmp && tar -zxvf /tmp/node-${NODE_VERSION}-linux-x64.tar.gz \ 6 | && cp /tmp/node-${NODE_VERSION}-linux-x64/bin/node /usr/local/bin/ \ 7 | && cp -r /tmp/node-${NODE_VERSION}-linux-x64/lib/node_modules /usr/local/lib/node_modules \ 8 | && cp -r /tmp/node-${NODE_VERSION}-linux-x64/include/node /usr/local/include/node \ 9 | && ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \ 10 | && ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \ 11 | && rm -rf /tmp/node-${NODE_VERSION}-linux-x64* 12 | 13 | # Environment variables. 14 | ENV FC_SERVER_PATH=/var/fc/runtime/nodejs14 15 | ENV FC_SERVER_LOG_PATH=${FC_SERVER_PATH}/var/log 16 | ENV LD_LIBRARY_PATH=${FC_FUNC_CODE_PATH}:${FC_FUNC_CODE_PATH}/lib 17 | ENV PATH=${FC_SERVER_PATH}/node_modules/.bin:${PATH} 18 | ENV NODE_PATH=/usr/local/lib/node_modules:/opt/nodejs/node14/node_modules:/opt/nodejs/node_modules 19 | 20 | # Create directory. 21 | RUN mkdir -p ${FC_SERVER_PATH} 22 | 23 | # Create directories. 24 | RUN mkdir -p \ 25 | ${FC_SERVER_LOG_PATH} 26 | 27 | RUN chmod 777 ${FC_SERVER_LOG_PATH} 28 | RUN chmod -R 777 /tmp/ 29 | 30 | # Change work directory. 31 | WORKDIR ${FC_SERVER_PATH} 32 | 33 | # Expose the port number. 34 | EXPOSE ${FC_SERVER_PORT} 35 | 36 | # Install thrid party libraries for user function. 37 | RUN npm install --global --unsafe-perm \ 38 | --registry http://registry.npmmirror.com \ 39 | co@4.6.0 \ 40 | gm@1.23.0 \ 41 | ali-oss@6.6.0 \ 42 | aliyun-sdk@1.12.3 \ 43 | tablestore@5.0.7\ 44 | @alicloud/fc2@2.2.0 \ 45 | body@5.1.0 \ 46 | raw-body@2.4.1 \ 47 | ali-mns@2.6.8 \ 48 | @alicloud/pop-core@1.7.9 \ 49 | @alicloud/fnf-2019-03-15@1.1.0 50 | 51 | RUN npm cache clean --force 52 | 53 | # Change work directory. 54 | WORKDIR ${FC_FUNC_CODE_PATH} 55 | 56 | # Start a shell by default 57 | CMD ["bash"] -------------------------------------------------------------------------------- /nodejs14/build/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-nodejs14:${TAG} 3 | 4 | RUN mkdir -p /mnt/auto 5 | RUN apt-get update \ 6 | && apt-get --no-install-recommends install -y apt-utils ca-certificates \ 7 | dialog \ 8 | vim \ 9 | cmake \ 10 | zip \ 11 | unzip \ 12 | clang \ 13 | build-essential \ 14 | libgmp3-dev \ 15 | python2.7-dev \ 16 | sudo \ 17 | && rm -rf /var/lib/apt/lists/* 18 | 19 | RUN echo "ALL ALL=NOPASSWD: ALL" >> /etc/sudoers 20 | 21 | ARG FUN_VERSION 22 | ARG FCLI_VERSION 23 | ARG FUN_INSTALL_VERSION 24 | 25 | RUN curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-${FCLI_VERSION}-linux-amd64.zip \ 26 | && unzip -o fcli.zip -d /usr/local/bin/ \ 27 | && rm fcli.zip 28 | 29 | RUN curl -o fun.zip https://gosspublic.alicdn.com/fun/fun-${FUN_VERSION}-linux.zip \ 30 | && unzip -o fun.zip -d /usr/local/bin/ \ 31 | && rm fun.zip \ 32 | && mv /usr/local/bin/fun-v* /usr/local/bin/fun 33 | 34 | RUN curl -o fun-install.zip https://gosspublic.alicdn.com/fun-install/fun-install-${FUN_INSTALL_VERSION}-linux-64.zip \ 35 | && unzip -o fun-install.zip -d /usr/local/bin/ \ 36 | && rm fun-install.zip \ 37 | && mv /usr/local/bin/fun-install-v* /usr/local/bin/fun-install \ 38 | && ln -s /usr/local/bin/fun-install /usr/local/bin/s-install 39 | 40 | RUN mv /usr/bin/update-alternatives /usr/bin/update-alternatives-origin \ 41 | && ((test -f /usr/bin/pycompile && mv /usr/bin/pycompile /usr/bin/pycompile-origin) || true) 42 | 43 | COPY commons/update-alternatives /usr/bin/ 44 | COPY commons/pycompile /usr/bin/ 45 | 46 | RUN npm config set registry https://registry.npmmirror.com 47 | 48 | RUN npm install -g yarn 49 | 50 | WORKDIR /code 51 | 52 | CMD ["npm", "rebuild"] 53 | -------------------------------------------------------------------------------- /nodejs14/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-nodejs14:${TAG} 3 | 4 | RUN rm -rf /var/runtime /var/lang && \ 5 | curl http://cli.so/ca_tgz/nodejs14.tgz | tar -zx -C / && \ 6 | rm -rf /var/fc/runtime/*/var/log/* 7 | 8 | COPY commons/function-compute-mock.sh /var/fc/runtime/nodejs14/mock 9 | COPY commons/nodejs-agent.sh /var/fc/runtime/nodejs14/agent.sh 10 | 11 | ENTRYPOINT ["/var/fc/runtime/nodejs14/mock"] 12 | -------------------------------------------------------------------------------- /nodejs16/base/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM aliyunfc/fc-runtime:stretch-base 2 | 3 | ENV NODE_VERSION v16.15.1 4 | RUN wget http://mirrors.nju.edu.cn/nodejs/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64.tar.gz -O /tmp/node-${NODE_VERSION}-linux-x64.tar.gz \ 5 | && cd /tmp && tar -zxvf /tmp/node-${NODE_VERSION}-linux-x64.tar.gz \ 6 | && cp /tmp/node-${NODE_VERSION}-linux-x64/bin/node /usr/local/bin/ \ 7 | && cp -r /tmp/node-${NODE_VERSION}-linux-x64/lib/node_modules /usr/local/lib/node_modules \ 8 | && cp -r /tmp/node-${NODE_VERSION}-linux-x64/include/node /usr/local/include/node \ 9 | && ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \ 10 | && ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \ 11 | && rm -rf /tmp/node-${NODE_VERSION}-linux-x64* 12 | 13 | # Environment variables. 14 | ENV FC_SERVER_PATH=/var/fc/runtime/nodejs16 15 | ENV FC_SERVER_LOG_PATH=${FC_SERVER_PATH}/var/log 16 | ENV LD_LIBRARY_PATH=${FC_FUNC_CODE_PATH}:${FC_FUNC_CODE_PATH}/lib 17 | ENV PATH=${FC_SERVER_PATH}/node_modules/.bin:${PATH} 18 | ENV NODE_PATH=/usr/local/lib/node_modules:/opt/nodejs/node14/node_modules:/opt/nodejs/node_modules 19 | 20 | # Create directory. 21 | RUN mkdir -p ${FC_SERVER_PATH} 22 | 23 | # Create directories. 24 | RUN mkdir -p \ 25 | ${FC_SERVER_LOG_PATH} 26 | 27 | RUN chmod 777 ${FC_SERVER_LOG_PATH} 28 | RUN chmod -R 777 /tmp/ 29 | 30 | # Change work directory. 31 | WORKDIR ${FC_SERVER_PATH} 32 | 33 | # Expose the port number. 34 | EXPOSE ${FC_SERVER_PORT} 35 | 36 | # Install thrid party libraries for user function. 37 | RUN npm install --global --unsafe-perm \ 38 | --registry http://registry.npmmirror.com \ 39 | co@4.6.0 \ 40 | gm@1.23.0 \ 41 | ali-oss@6.6.0 \ 42 | aliyun-sdk@1.12.3 \ 43 | tablestore@5.0.7\ 44 | @alicloud/fc2@2.2.0 \ 45 | body@5.1.0 \ 46 | raw-body@2.4.1 \ 47 | ali-mns@2.6.8 \ 48 | @alicloud/pop-core@1.7.9 \ 49 | @alicloud/fnf-2019-03-15@1.1.0 50 | 51 | RUN npm cache clean --force 52 | 53 | # Change work directory. 54 | WORKDIR ${FC_FUNC_CODE_PATH} 55 | 56 | # Start a shell by default 57 | CMD ["bash"] -------------------------------------------------------------------------------- /nodejs16/build/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-nodejs16:${TAG} 3 | 4 | RUN mkdir -p /mnt/auto 5 | RUN apt-get update \ 6 | && apt-get --no-install-recommends install -y apt-utils ca-certificates \ 7 | dialog \ 8 | vim \ 9 | cmake \ 10 | zip \ 11 | unzip \ 12 | clang \ 13 | build-essential \ 14 | libgmp3-dev \ 15 | python2.7-dev \ 16 | sudo \ 17 | && rm -rf /var/lib/apt/lists/* 18 | 19 | RUN echo "ALL ALL=NOPASSWD: ALL" >> /etc/sudoers 20 | 21 | ARG FUN_VERSION 22 | ARG FCLI_VERSION 23 | ARG FUN_INSTALL_VERSION 24 | 25 | RUN curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-${FCLI_VERSION}-linux-amd64.zip \ 26 | && unzip -o fcli.zip -d /usr/local/bin/ \ 27 | && rm fcli.zip 28 | 29 | RUN curl -o fun.zip https://gosspublic.alicdn.com/fun/fun-${FUN_VERSION}-linux.zip \ 30 | && unzip -o fun.zip -d /usr/local/bin/ \ 31 | && rm fun.zip \ 32 | && mv /usr/local/bin/fun-v* /usr/local/bin/fun 33 | 34 | RUN curl -o fun-install.zip https://gosspublic.alicdn.com/fun-install/fun-install-${FUN_INSTALL_VERSION}-linux-64.zip \ 35 | && unzip -o fun-install.zip -d /usr/local/bin/ \ 36 | && rm fun-install.zip \ 37 | && mv /usr/local/bin/fun-install-v* /usr/local/bin/fun-install \ 38 | && ln -s /usr/local/bin/fun-install /usr/local/bin/s-install 39 | 40 | RUN mv /usr/bin/update-alternatives /usr/bin/update-alternatives-origin \ 41 | && ((test -f /usr/bin/pycompile && mv /usr/bin/pycompile /usr/bin/pycompile-origin) || true) 42 | 43 | COPY commons/update-alternatives /usr/bin/ 44 | COPY commons/pycompile /usr/bin/ 45 | 46 | RUN npm config set registry https://registry.npmmirror.com 47 | 48 | RUN npm install -g yarn 49 | 50 | WORKDIR /code 51 | 52 | CMD ["npm", "rebuild"] 53 | -------------------------------------------------------------------------------- /nodejs16/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-nodejs16:${TAG} 3 | 4 | RUN echo "update222222" 5 | 6 | RUN rm -rf /var/runtime /var/lang && \ 7 | curl https://serverless-devs-tool.oss-cn-hongkong.aliyuncs.com/ca_tgz/nodejs16.tgz | tar -zx -C / && \ 8 | rm -rf /var/fc/runtime/*/var/log/* 9 | 10 | COPY commons/function-compute-mock.sh /var/fc/runtime/nodejs16/mock 11 | COPY commons/nodejs-agent.sh /var/fc/runtime/nodejs16/agent.sh 12 | 13 | ENTRYPOINT ["/var/fc/runtime/nodejs16/mock"] 14 | -------------------------------------------------------------------------------- /nodejs6/base/Dockerfile: -------------------------------------------------------------------------------- 1 | # FROM aliyunfc/fc-runtime:stretch-base 2 | 3 | # ENV NODE_VERSION v6.14.2 4 | # RUN wget http://mirrors.nju.edu.cn/nodejs/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64.tar.gz -O /tmp/node-${NODE_VERSION}-linux-x64.tar.gz \ 5 | # && cd /tmp && tar -zxvf /tmp/node-${NODE_VERSION}-linux-x64.tar.gz \ 6 | # && cp /tmp/node-${NODE_VERSION}-linux-x64/bin/node /usr/local/bin/ \ 7 | # && cp -r /tmp/node-${NODE_VERSION}-linux-x64/lib/node_modules /usr/local/lib/node_modules \ 8 | # && cp -r /tmp/node-${NODE_VERSION}-linux-x64/include/node /usr/local/include/node \ 9 | # && ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \ 10 | # && ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local//bin/npx \ 11 | # && rm -rf /tmp/node-${NODE_VERSION}-linux-x64* 12 | 13 | # # Environment variables. 14 | # ENV FC_SERVER_PATH=/var/fc/runtime/nodejs6 15 | # ENV FC_SERVER_LOG_PATH=${FC_SERVER_PATH}/var/log 16 | # ENV PATH=${FC_SERVER_PATH}/node_modules/.bin:${PATH} 17 | # ENV NODE_PATH=/usr/local/lib/node_modules:/opt/nodejs/node6/node_modules:/opt/nodejs/node_modules 18 | # ENV LD_LIBRARY_PATH=${FC_FUNC_CODE_PATH}:${FC_FUNC_CODE_PATH}/lib 19 | 20 | # # Create directory. 21 | # RUN mkdir -p ${FC_SERVER_PATH} 22 | # # Change work directory. 23 | # WORKDIR ${FC_FUNC_CODE_PATH} 24 | 25 | # RUN apt-get update && apt-get install -y --allow-unauthenticated python2.7 python-pip python2.7-dev \ 26 | # --no-install-recommends && rm -r /var/lib/apt/lists/* 27 | 28 | # RUN npm install --global --unsafe-perm node-pre-gyp 29 | 30 | # # Install thrid party libraries for user function. 31 | # RUN npm install --global --unsafe-perm \ 32 | # #--registry http://registry.npmmirror.com \ 33 | # co@4.6.0 \ 34 | # gm@1.23.1 \ 35 | # ali-oss@4.10.1 \ 36 | # aliyun-sdk@1.11.10 \ 37 | # @alicloud/fc@1.2.2 \ 38 | # opencv@6.2.0 \ 39 | # tablestore@4.2.0 \ 40 | # @alicloud/fc2@2.1.0 \ 41 | # body@5.1.0 \ 42 | # raw-body@2.3.2 \ 43 | # ali-mns@2.6.5 \ 44 | # @alicloud/pop-core@1.7.0 \ 45 | # @alicloud/fnf-2019-03-15@1.1.0 46 | 47 | # RUN npm cache clean --force 48 | 49 | # # Start a shell by default 50 | # CMD ["bash"] 51 | 52 | # no change 53 | FROM aliyunfc/runtime-nodejs6:base-1.10.2 54 | COPY ./commons/debian-stretch-sources.list /etc/apt/sources.list -------------------------------------------------------------------------------- /nodejs6/build/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-nodejs6:${TAG} 3 | 4 | ENV DEBIAN_FRONTEND=noninteractive 5 | 6 | RUN mkdir -p /mnt/auto 7 | RUN apt-get update \ 8 | && apt-get --no-install-recommends install -y apt-utils ca-certificates \ 9 | dialog \ 10 | vim \ 11 | cmake \ 12 | zip \ 13 | unzip \ 14 | clang \ 15 | build-essential \ 16 | libgmp3-dev \ 17 | python2.7-dev \ 18 | sudo \ 19 | && rm -rf /var/lib/apt/lists/* 20 | 21 | RUN echo "ALL ALL=NOPASSWD: ALL" >> /etc/sudoers 22 | 23 | ARG FUN_VERSION 24 | ARG FCLI_VERSION 25 | ARG FUN_INSTALL_VERSION 26 | 27 | RUN curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-${FCLI_VERSION}-linux-amd64.zip \ 28 | && unzip -o fcli.zip -d /usr/local/bin/ \ 29 | && rm fcli.zip 30 | 31 | RUN curl -o fun.zip https://gosspublic.alicdn.com/fun/fun-${FUN_VERSION}-linux.zip \ 32 | && unzip -o fun.zip -d /usr/local/bin/ \ 33 | && rm fun.zip \ 34 | && mv /usr/local/bin/fun-v* /usr/local/bin/fun 35 | 36 | RUN curl -o fun-install.zip https://gosspublic.alicdn.com/fun-install/fun-install-${FUN_INSTALL_VERSION}-linux-64.zip \ 37 | && unzip -o fun-install.zip -d /usr/local/bin/ \ 38 | && rm fun-install.zip \ 39 | && mv /usr/local/bin/fun-install-v* /usr/local/bin/fun-install \ 40 | && ln -s /usr/local/bin/fun-install /usr/local/bin/s-install 41 | 42 | RUN mv /usr/bin/update-alternatives /usr/bin/update-alternatives-origin \ 43 | && ((test -f /usr/bin/pycompile && mv /usr/bin/pycompile /usr/bin/pycompile-origin) || true) 44 | 45 | COPY commons/update-alternatives /usr/bin/ 46 | 47 | COPY commons/pycompile /usr/bin/ 48 | 49 | RUN npm config set registry https://registry.npmmirror.com 50 | 51 | RUN npm install -g yarn 52 | 53 | WORKDIR /code 54 | 55 | CMD ["npm", "rebuild"] 56 | -------------------------------------------------------------------------------- /nodejs6/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-nodejs6:${TAG} 3 | 4 | RUN rm -rf /var/runtime /var/lang && \ 5 | curl http://cli.so/ca_tgz/nodejs6.tgz | tar -zx -C / && \ 6 | rm -rf /var/fc/runtime/*/var/log/* 7 | 8 | COPY commons/function-compute-mock.sh /var/fc/runtime/nodejs6/mock 9 | COPY commons/nodejs-agent.sh /var/fc/runtime/nodejs6/agent.sh 10 | 11 | 12 | ENTRYPOINT ["/var/fc/runtime/nodejs6/mock"] 13 | -------------------------------------------------------------------------------- /nodejs8/base/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM aliyunfc/fc-runtime:stretch-base 2 | 3 | ENV NODE_VERSION v8.17.0 4 | RUN wget http://mirrors.nju.edu.cn/nodejs/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64.tar.gz -O /tmp/node-${NODE_VERSION}-linux-x64.tar.gz \ 5 | && cd /tmp && tar -zxvf /tmp/node-${NODE_VERSION}-linux-x64.tar.gz \ 6 | && cp /tmp/node-${NODE_VERSION}-linux-x64/bin/node /usr/local/bin/ \ 7 | && cp -r /tmp/node-${NODE_VERSION}-linux-x64/lib/node_modules /usr/local/lib/node_modules \ 8 | && cp -r /tmp/node-${NODE_VERSION}-linux-x64/include/node /usr/local/include/node \ 9 | && ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \ 10 | && ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \ 11 | && rm -rf /tmp/node-${NODE_VERSION}-linux-x64* 12 | 13 | # Environment variables. 14 | ENV FC_SERVER_PATH=/var/fc/runtime/nodejs8 15 | 16 | # Create directory. 17 | RUN mkdir -p ${FC_SERVER_PATH} 18 | 19 | ENV FC_SERVER_LOG_PATH=${FC_SERVER_PATH}/var/log 20 | ENV LD_LIBRARY_PATH=${FC_FUNC_CODE_PATH}:${FC_FUNC_CODE_PATH}/lib 21 | ENV PATH=${PATH}:${FC_SERVER_PATH}/node_modules/.bin 22 | ENV NODE_PATH=/usr/local/lib/node_modules:/opt/nodejs/node8/node_modules:/opt/nodejs/node_modules 23 | 24 | # Change work directory. 25 | WORKDIR ${FC_FUNC_CODE_PATH} 26 | 27 | # Install thrid party libraries for user function. 28 | RUN npm install --global --unsafe-perm \ 29 | --registry http://registry.npmmirror.com \ 30 | co@4.6.0 \ 31 | gm@1.23.0 \ 32 | ali-oss@4.10.1 \ 33 | aliyun-sdk@1.11.10 \ 34 | @alicloud/fc@1.2.2 \ 35 | opencv@6.2.0 \ 36 | tablestore@4.2.0\ 37 | @alicloud/fc2@2.1.0 \ 38 | body@5.1.0 \ 39 | raw-body@2.3.2 \ 40 | ali-mns@2.6.5 \ 41 | @alicloud/pop-core@1.7.0 \ 42 | @alicloud/fnf-2019-03-15@1.1.0 \ 43 | axios@0.19.2 \ 44 | lodash@4.17.15 \ 45 | moment@2.25.3 \ 46 | uuid@8.0.0 47 | 48 | RUN npm cache clean --force 49 | 50 | # Start a shell by default 51 | CMD ["bash"] -------------------------------------------------------------------------------- /nodejs8/build/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-nodejs8:${TAG} 3 | ENV DEBIAN_FRONTEND=noninteractive 4 | 5 | RUN mkdir -p /mnt/auto 6 | RUN apt-get update \ 7 | && apt-get --no-install-recommends install -y apt-utils ca-certificates \ 8 | dialog \ 9 | vim \ 10 | cmake \ 11 | zip \ 12 | unzip \ 13 | clang \ 14 | build-essential \ 15 | libgmp3-dev \ 16 | python2.7-dev \ 17 | sudo \ 18 | && rm -rf /var/lib/apt/lists/* 19 | 20 | RUN echo "ALL ALL=NOPASSWD: ALL" >> /etc/sudoers 21 | 22 | ARG FUN_VERSION 23 | ARG FCLI_VERSION 24 | ARG FUN_INSTALL_VERSION 25 | 26 | RUN curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-${FCLI_VERSION}-linux-amd64.zip \ 27 | && unzip -o fcli.zip -d /usr/local/bin/ \ 28 | && rm fcli.zip 29 | 30 | RUN curl -o fun.zip https://gosspublic.alicdn.com/fun/fun-${FUN_VERSION}-linux.zip \ 31 | && unzip -o fun.zip -d /usr/local/bin/ \ 32 | && rm fun.zip \ 33 | && mv /usr/local/bin/fun-v* /usr/local/bin/fun 34 | 35 | RUN curl -o fun-install.zip https://gosspublic.alicdn.com/fun-install/fun-install-${FUN_INSTALL_VERSION}-linux-64.zip \ 36 | && unzip -o fun-install.zip -d /usr/local/bin/ \ 37 | && rm fun-install.zip \ 38 | && mv /usr/local/bin/fun-install-v* /usr/local/bin/fun-install \ 39 | && ln -s /usr/local/bin/fun-install /usr/local/bin/s-install 40 | 41 | RUN mv /usr/bin/update-alternatives /usr/bin/update-alternatives-origin \ 42 | && ((test -f /usr/bin/pycompile && mv /usr/bin/pycompile /usr/bin/pycompile-origin) || true) 43 | 44 | COPY commons/update-alternatives /usr/bin/ 45 | 46 | COPY commons/pycompile /usr/bin/ 47 | 48 | RUN npm config set registry https://registry.npmmirror.com 49 | 50 | RUN npm install -g yarn 51 | 52 | WORKDIR /code 53 | 54 | CMD ["npm", "rebuild"] 55 | -------------------------------------------------------------------------------- /nodejs8/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-nodejs8:${TAG} 3 | 4 | RUN rm -rf /var/runtime /var/lang && \ 5 | curl http://cli.so/ca_tgz/nodejs8.tgz | tar -zx -C / && \ 6 | rm -rf /var/fc/runtime/*/var/log/* 7 | 8 | COPY commons/function-compute-mock.sh /var/fc/runtime/nodejs8/mock 9 | COPY commons/nodejs-agent.sh /var/fc/runtime/nodejs8/agent.sh 10 | 11 | ENTRYPOINT ["/var/fc/runtime/nodejs8/mock"] 12 | -------------------------------------------------------------------------------- /php7.2/base/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM aliyunfc/fc-runtime:php7.2-stretch-base 2 | 3 | # Server path. 4 | ENV FC_SERVER_PATH=/var/fc/runtime/php7.2 5 | # php package path. 6 | ENV FC_PHP_LIB_PATH=${FC_SERVER_PATH}/builtIn 7 | # Create directory. 8 | RUN mkdir -p ${FC_PHP_LIB_PATH} 9 | 10 | ENV FC_SERVER_LOG_PATH=${FC_SERVER_PATH}/var/log 11 | # Create directories. 12 | RUN mkdir -p ${FC_SERVER_LOG_PATH} 13 | 14 | ENV LD_LIBRARY_PATH=${FC_FUNC_CODE_PATH}:${FC_FUNC_CODE_PATH}/lib:/usr/local/lib 15 | ENV PHP_INI_SCAN_DIR=${FC_FUNC_CODE_PATH}extension:/usr/local/etc/php/conf.d 16 | 17 | # Change work directory. 18 | WORKDIR ${FC_SERVER_PATH} 19 | 20 | # Change work directory. 21 | WORKDIR ${FC_PHP_LIB_PATH} 22 | 23 | # Install third party libraries for user function. 24 | RUN composer config -g repo.packagist composer https://packagist.phpcomposer.com 25 | COPY php7.2/base/composer.json ./ 26 | COPY php7.2/base/composer.lock ./ 27 | RUN composer install 28 | 29 | RUN echo "memory_limit=3072M" >> /usr/local/etc/php/php.ini 30 | RUN echo "enable_post_data_reading=1" >> /usr/local/etc/php/php.ini 31 | 32 | # Change work directory. 33 | WORKDIR ${FC_SERVER_PATH} -------------------------------------------------------------------------------- /php7.2/base/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "aliyunfc/fc-php-sdk": "^1.2", 4 | "aliyuncs/oss-sdk-php": "2.4.3", 5 | "aliyun/aliyun-tablestore-sdk-php": "4.1.1", 6 | "wushunyi/aliyun-sdk-mns": "^1.3.5", 7 | "alibabacloud/fnf": "^1.7" 8 | } 9 | } -------------------------------------------------------------------------------- /php7.2/build/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-php7.2:${TAG} 3 | 4 | ENV DEBIAN_FRONTEND=noninteractive 5 | 6 | RUN mkdir -p /mnt/auto 7 | RUN apt-get update \ 8 | && apt-get --no-install-recommends install -y apt-utils ca-certificates \ 9 | dialog \ 10 | vim \ 11 | cmake \ 12 | zip \ 13 | unzip \ 14 | clang \ 15 | build-essential \ 16 | libgmp3-dev \ 17 | python2.7-dev \ 18 | sudo \ 19 | && rm -rf /var/lib/apt/lists/* 20 | 21 | RUN echo "ALL ALL=NOPASSWD: ALL" >> /etc/sudoers 22 | 23 | ARG FUN_VERSION 24 | ARG FCLI_VERSION 25 | ARG FUN_INSTALL_VERSION 26 | 27 | RUN curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-${FCLI_VERSION}-linux-amd64.zip \ 28 | && unzip -o fcli.zip -d /usr/local/bin/ \ 29 | && rm fcli.zip 30 | 31 | RUN curl -o fun.zip https://gosspublic.alicdn.com/fun/fun-${FUN_VERSION}-linux.zip \ 32 | && unzip -o fun.zip -d /usr/local/bin/ \ 33 | && rm fun.zip \ 34 | && mv /usr/local/bin/fun-v* /usr/local/bin/fun 35 | 36 | RUN curl -o fun-install.zip https://gosspublic.alicdn.com/fun-install/fun-install-${FUN_INSTALL_VERSION}-linux-64.zip \ 37 | && unzip -o fun-install.zip -d /usr/local/bin/ \ 38 | && rm fun-install.zip \ 39 | && mv /usr/local/bin/fun-install-v* /usr/local/bin/fun-install \ 40 | && ln -s /usr/local/bin/fun-install /usr/local/bin/s-install 41 | 42 | RUN mv /usr/bin/update-alternatives /usr/bin/update-alternatives-origin \ 43 | && ((test -f /usr/bin/pycompile && mv /usr/bin/pycompile /usr/bin/pycompile-origin) || true) 44 | 45 | COPY commons/update-alternatives /usr/bin/ 46 | 47 | COPY commons/pycompile /usr/bin/ 48 | 49 | RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ 50 | 51 | WORKDIR /code 52 | 53 | CMD ["npm", "rebuild"] 54 | -------------------------------------------------------------------------------- /php7.2/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-php7.2:${TAG} 3 | 4 | RUN rm -rf /var/runtime /var/lang && \ 5 | curl http://cli.so/ca_tgz/php7.2.tgz | tar -zx -C / && \ 6 | rm -rf /var/fc/runtime/*/var/log/* 7 | 8 | COPY commons/function-compute-mock.sh /var/fc/runtime/php7.2/mock 9 | COPY php7.2/run/agent.sh /var/fc/runtime/php7.2/agent.sh 10 | 11 | ENV AGENT_SCRIPT=agent.sh 12 | 13 | ENTRYPOINT ["/var/fc/runtime/php7.2/mock"] 14 | -------------------------------------------------------------------------------- /php7.2/run/agent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ################################################################### 3 | # To start the server, use this script. 4 | # 5 | # The server is configured with environment variables. The full list 6 | # of environment variables can be seen in ./src/constant.js 7 | ################################################################### 8 | 9 | # The absolute path of this file. 10 | CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd -P )" 11 | 12 | # Set some default configuration. 13 | export FC_SERVER_PORT=${FC_SERVER_PORT:=9000} 14 | export FC_SERVER_PATH=${FC_SERVER_PATH:=${CURDIR}} 15 | export FC_SERVER_LOG_PATH=${FC_SERVER_LOG_PATH:=${CURDIR}/var/log} 16 | export FC_SERVER_LOG_LEVEL=${FC_SERVER_LOG_LEVEL:=INFO} 17 | 18 | export FC_FUNC_CODE_PATH=${FC_FUNC_CODE_PATH:=${CURDIR}} 19 | export FC_FUNC_LOG_PATH=${FC_FUNC_LOG_PATH:=${CURDIR}/var/log} 20 | 21 | Help() { 22 | echo "Usage:" 23 | echo " $0 command" 24 | echo "Commands" 25 | echo " start start up server" 26 | echo " help print help page" 27 | } 28 | 29 | 30 | if [ $# -eq 0 ] 31 | then 32 | echo "Missing arguments." 33 | Help 34 | exit 0; 35 | fi 36 | 37 | command=$1 38 | case ${command} in 39 | "start") 40 | php ${FC_SERVER_PATH}/src/server.php 41 | ;; 42 | "help") 43 | Help 44 | ;; 45 | *) 46 | Help 47 | ;; 48 | esac 49 | -------------------------------------------------------------------------------- /php7.2/run/xdebug-2.6.1.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aliyun/fc-docker/d3f748b5daf434c1ab97bdc6319dd01d60438259/php7.2/run/xdebug-2.6.1.tgz -------------------------------------------------------------------------------- /python2.7/base/Dockerfile: -------------------------------------------------------------------------------- 1 | # # aliyunfc/fc-runtime:python27-stretch-base see commons directory 2 | # FROM aliyunfc/fc-runtime:python27-stretch-base 3 | 4 | # COPY commons/pip.conf /etc/pip.conf 5 | 6 | # # Install third party libraries for user function. 7 | # RUN pip install -U pip setuptools 8 | 9 | # # fc-docker fix: as online 10 | # COPY python2.7/base/requirements.txt ./requirements.txt 11 | # RUN pip install -r requirements.txt --ignore-installed -i https://mirrors.aliyun.com/pypi/simple/ 12 | # RUN rm ./requirements.txt 13 | 14 | # # iot sdk support 6.1.0 15 | # RUN curl --connect-timeout 60 -m 3600 -fsSL http://lambda-public.oss-cn-hangzhou.aliyuncs.com/lambda/aliyunsdkiot_py2_v20170420.tar.gz | tar -xzC /usr/local/lib/python2.7/dist-packages/aliyunsdkiot/request/ 16 | 17 | # # Change work directory. 18 | # WORKDIR ${FC_FUNC_CODE_PATH} 19 | 20 | # # Server path. 21 | # ENV FC_SERVER_PATH=/var/fc/runtime/python2.7 22 | # ENV FC_SERVER_LOG_PATH=${FC_SERVER_PATH}/var/log 23 | # # Create directory. 24 | # RUN mkdir -p ${FC_SERVER_LOG_PATH} 25 | # ENV LD_LIBRARY_PATH=${FC_FUNC_CODE_PATH}:${FC_FUNC_CODE_PATH}/lib:/usr/local/lib 26 | 27 | # # Start a shell by default 28 | # CMD ["bash"] 29 | 30 | FROM aliyunfc/runtime-python2.7:base-1.10.8 31 | COPY ./commons/debian-stretch-sources.list /etc/apt/sources.list -------------------------------------------------------------------------------- /python2.7/base/requirements.txt: -------------------------------------------------------------------------------- 1 | aliyun-fc==0.6 2 | aliyun-fc2==2.3.0 3 | aliyun-log-python-sdk==0.6.38 4 | aliyun-mns==1.1.5 5 | aliyun-python-sdk-cdn==3.0.8 6 | aliyun-python-sdk-core==2.13.11 7 | aliyun-python-sdk-dds==2.0.7 8 | aliyun-python-sdk-ecs==4.10.1 9 | aliyun-python-sdk-fnf==1.3.0 10 | aliyun-python-sdk-imm==1.3.4 11 | aliyun-python-sdk-iot==7.8.0 12 | aliyun-python-sdk-kms==2.14.0 13 | aliyun-python-sdk-ram==3.0.0 14 | aliyun-python-sdk-rds==2.1.4 15 | aliyun-python-sdk-sts==3.0.0 16 | aliyun-python-sdk-vpc==3.0.2 17 | appdirs==1.4.3 18 | asn1crypto==0.24.0 19 | attrs==21.2.0 20 | Automat==20.2.0 21 | backports.entry-points-selectable==1.1.0 22 | Cython==0.29.14 23 | cbor==1.0.0 24 | certifi==2021.5.30 25 | cffi==1.14.6 26 | chardet==4.0.0 27 | configparser==4.0.2 28 | constantly==15.1.0 29 | contextlib2==0.6.0.post1 30 | coverage==5.5 31 | cprotobuf==0.1.10 32 | crcmod==1.7 33 | cryptography==3.3.2 34 | cssselect==1.1.0 35 | cycler==0.10.0 36 | dateparser==0.7.6 37 | debugpy==1.5.1 38 | distlib==0.3.2 39 | elasticsearch==6.8.2 40 | enum34==1.1.10 41 | filelock==3.0.12 42 | functools32==3.2.3.post2 43 | future==0.18.2 44 | futures==3.3.0 45 | greenlet==0.4.13 46 | hyperlink==21.0.0 47 | icc-rt==16.0.3 48 | idna==2.10 49 | importlib-metadata==2.1.1 50 | importlib-resources==3.3.1 51 | incremental==21.3.0 52 | intel-openmp==2021.3.0 53 | ipaddress==1.0.23 54 | jmespath==0.10.0 55 | lxml==4.6.3 56 | lz4==2.2.1 57 | matplotlib==2.0.2 58 | numpy==1.13.3 59 | opencv-python==3.3.0.10 60 | oss2==2.9.1 61 | packaging==16.8 62 | parsel==1.6.0 63 | pathlib2==2.3.6 64 | platformdirs==2.0.2 65 | protobuf==3.13.0 66 | pyasn1==0.4.8 67 | pyasn1-modules==0.2.8 68 | pycparser==2.20 69 | pycryptodome==3.10.1 70 | pydatahub==2.11.2 71 | PyDispatcher==2.0.5 72 | PyHamcrest==1.10.1 73 | pyOpenSSL==20.0.1 74 | pyparsing==2.4.7 75 | python-dateutil==2.8.2 76 | pytz==2021.1 77 | queuelib==1.6.1 78 | regex==2021.8.3 79 | requests==2.26.0 80 | scandir==1.10.0 81 | scipy==1.0.0 82 | Scrapy==1.4.0 83 | service-identity==21.1.0 84 | simplejson==3.17.3 85 | singledispatch==3.6.2 86 | six==1.16.0 87 | subprocess32==3.5.4 88 | tablestore==5.1.0 89 | Twisted==20.3.0 90 | typing==3.10.0.0 91 | tzlocal==2.1 92 | urllib3==1.26.6 93 | virtualenv==20.7.2 94 | w3lib==1.22.0 95 | Wand==0.4.4 96 | zipp==1.2.0 97 | zope.interface==5.4.0 -------------------------------------------------------------------------------- /python2.7/build/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-python2.7:${TAG} 3 | 4 | ENV DEBIAN_FRONTEND=noninteractive 5 | 6 | RUN mkdir -p /mnt/auto 7 | RUN apt-get update \ 8 | && apt-get --no-install-recommends install -y apt-utils ca-certificates \ 9 | dialog \ 10 | vim \ 11 | cmake \ 12 | zip \ 13 | unzip \ 14 | clang \ 15 | build-essential \ 16 | libgmp3-dev \ 17 | python2.7-dev \ 18 | sudo \ 19 | && rm -rf /var/lib/apt/lists/* 20 | 21 | RUN echo "ALL ALL=NOPASSWD: ALL" >> /etc/sudoers 22 | 23 | ARG FUN_VERSION 24 | ARG FCLI_VERSION 25 | ARG FUN_INSTALL_VERSION 26 | 27 | RUN curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-${FCLI_VERSION}-linux-amd64.zip \ 28 | && unzip -o fcli.zip -d /usr/local/bin/ \ 29 | && rm fcli.zip 30 | 31 | RUN curl -o fun.zip https://gosspublic.alicdn.com/fun/fun-${FUN_VERSION}-linux.zip \ 32 | && unzip -o fun.zip -d /usr/local/bin/ \ 33 | && rm fun.zip \ 34 | && mv /usr/local/bin/fun-v* /usr/local/bin/fun 35 | 36 | RUN curl -o fun-install.zip https://gosspublic.alicdn.com/fun-install/fun-install-${FUN_INSTALL_VERSION}-linux-64.zip \ 37 | && unzip -o fun-install.zip -d /usr/local/bin/ \ 38 | && rm fun-install.zip \ 39 | && mv /usr/local/bin/fun-install-v* /usr/local/bin/fun-install \ 40 | && ln -s /usr/local/bin/fun-install /usr/local/bin/s-install 41 | 42 | RUN mv /usr/bin/update-alternatives /usr/bin/update-alternatives-origin \ 43 | && ((test -f /usr/bin/pycompile && mv /usr/bin/pycompile /usr/bin/pycompile-origin) || true) 44 | 45 | COPY commons/update-alternatives /usr/bin/ 46 | 47 | COPY commons/pycompile /usr/bin/ 48 | 49 | RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ 50 | 51 | WORKDIR /code 52 | -------------------------------------------------------------------------------- /python2.7/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-python2.7:${TAG} 3 | 4 | ENV PYTHONUNBUFFERED=1 5 | 6 | RUN pip install ptvsd==4.3.2 -i https://mirrors.aliyun.com/pypi/simple/ 7 | RUN pip install pydevd==2.8.0 -i https://mirrors.aliyun.com/pypi/simple/ 8 | 9 | RUN rm -rf /var/runtime /var/lang && \ 10 | curl http://cli.so/ca_tgz/python2.7.tgz | tar -zx -C / && \ 11 | rm -rf /var/fc/runtime/*/var/log/* 12 | 13 | COPY commons/function-compute-mock.sh /var/fc/runtime/python2.7/mock 14 | COPY python2.7/run/agent.sh /var/fc/runtime/python2.7/agent.sh 15 | 16 | ENTRYPOINT ["/var/fc/runtime/python2.7/mock"] 17 | -------------------------------------------------------------------------------- /python2.7/run/agent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ################################################################### 3 | # To start the server, use this script. 4 | # 5 | # The server is configured with environment variables. The full list 6 | # of environment variables can be seen in ./src/constant.js 7 | ################################################################### 8 | 9 | # The absolute path of this file. 10 | CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd -P )" 11 | 12 | # Set some default configuration. 13 | export FC_SERVER_PORT=${FC_SERVER_PORT:=9000} 14 | export FC_SERVER_PATH=${FC_SERVER_PATH:=${CURDIR}} 15 | export FC_SERVER_LOG_PATH=${FC_SERVER_LOG_PATH:=${CURDIR}/var/log} 16 | export FC_SERVER_LOG_LEVEL=${FC_SERVER_LOG_LEVEL:=INFO} 17 | 18 | export FC_FUNC_CODE_PATH=${FC_FUNC_CODE_PATH:=${CURDIR}} 19 | export FC_FUNC_LOG_PATH=${FC_FUNC_LOG_PATH:=${CURDIR}/var/log} 20 | 21 | Help() { 22 | echo "Usage:" 23 | echo " $0 command" 24 | echo "Commands" 25 | echo " start start up server" 26 | echo " help print help page" 27 | } 28 | 29 | 30 | if [ $# -eq 0 ] 31 | then 32 | echo "Missing arguments." 33 | Help 34 | exit 0; 35 | fi 36 | 37 | command=$1 38 | case ${command} in 39 | "start") 40 | python -W ignore ${DEBUG_OPTIONS} ${FC_SERVER_PATH}/src/server.py 41 | ;; 42 | "help") 43 | Help 44 | ;; 45 | *) 46 | Help 47 | ;; 48 | esac 49 | -------------------------------------------------------------------------------- /python3.10/base/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM aliyunfc/fc-runtime:python310-buster-base-v0.1 2 | 3 | COPY commons/pip.conf /etc/pip.conf 4 | 5 | # Change work directory. 6 | WORKDIR ${FC_FUNC_CODE_PATH} 7 | 8 | # Create directory. 9 | RUN mkdir -p ${FC_SERVER_LOG_PATH} 10 | 11 | # Start a shell by default 12 | CMD ["bash"] -------------------------------------------------------------------------------- /python3.10/build/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-python3.10:${TAG} 3 | 4 | ENV DEBIAN_FRONTEND=noninteractive 5 | 6 | RUN mkdir -p /mnt/auto 7 | RUN apt-get update \ 8 | && apt-get --no-install-recommends install -y apt-utils ca-certificates \ 9 | dialog \ 10 | vim \ 11 | cmake \ 12 | zip \ 13 | unzip \ 14 | clang \ 15 | build-essential \ 16 | libgmp3-dev \ 17 | python2.7-dev \ 18 | sudo \ 19 | && rm -rf /var/lib/apt/lists/* 20 | 21 | RUN echo "ALL ALL=NOPASSWD: ALL" >> /etc/sudoers 22 | 23 | ARG FUN_INSTALL_VERSION 24 | RUN curl -o fun-install.zip https://gosspublic.alicdn.com/fun-install/fun-install-${FUN_INSTALL_VERSION}-linux-64.zip \ 25 | && unzip -o fun-install.zip -d /usr/local/bin/ \ 26 | && rm fun-install.zip \ 27 | && mv /usr/local/bin/fun-install-v* /usr/local/bin/fun-install \ 28 | && ln -s /usr/local/bin/fun-install /usr/local/bin/s-install 29 | 30 | RUN mv /usr/bin/update-alternatives /usr/bin/update-alternatives-origin \ 31 | && ((test -f /usr/bin/pycompile && mv /usr/bin/pycompile /usr/bin/pycompile-origin) || true) 32 | 33 | COPY commons/update-alternatives /usr/bin/ 34 | 35 | COPY commons/pycompile /usr/bin/ 36 | 37 | RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ 38 | 39 | WORKDIR /code -------------------------------------------------------------------------------- /python3.10/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-python3.10:${TAG} 3 | 4 | ENV PYTHONUNBUFFERED=1 5 | ENV FC_RUNTIME=python3.10 6 | 7 | RUN pip install ptvsd -i https://mirrors.aliyun.com/pypi/simple/ 8 | RUN pip install pydevd -i https://mirrors.aliyun.com/pypi/simple/ 9 | 10 | 11 | COPY commons/function-compute-mock-2.0.sh /var/fc/runtime/mock 12 | 13 | ENV FC_RIE_VERSION 0.0.3 14 | 15 | RUN cd /var/fc/runtime/python3.10 \ 16 | && curl -o /tmp/fc-rie-v${FC_RIE_VERSION}.tar.gz https://fc-runtime-public.oss-cn-hangzhou.aliyuncs.com/fc-rie-v${FC_RIE_VERSION}.tar.gz \ 17 | && tar xf /tmp/fc-rie-v${FC_RIE_VERSION}.tar.gz -C /var/fc/runtime/ \ 18 | && rm /tmp/fc-rie-v${FC_RIE_VERSION}.tar.gz 19 | 20 | WORKDIR /var/fc/runtime 21 | 22 | ENTRYPOINT ["/var/fc/runtime/mock"] 23 | -------------------------------------------------------------------------------- /python3.6/base/Dockerfile: -------------------------------------------------------------------------------- 1 | # aliyunfc/fc-runtime:python36-stretch-base see commons directory 2 | FROM aliyunfc/fc-runtime:python36-stretch-base 3 | 4 | COPY commons/pip.conf /etc/pip.conf 5 | 6 | # Change work directory. 7 | WORKDIR ${FC_FUNC_CODE_PATH} 8 | 9 | # Install third party libraries for user function. 10 | RUN pip install -U pip setuptools 11 | 12 | # fc-docker fix: as online 13 | RUN pip install Cython==0.29.27 incremental==21.3.0 Automat==20.2.0 attrs==21.4.0 constantly==15.1.0 hyperlink==21.0.0 idna==2.7 numpy==1.13.3 zope.interface==5.4.0 six==1.16.0 scipy==1.0.0 14 | COPY python3.6/base/requirements.txt ./requirements.txt 15 | RUN pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ 16 | RUN rm ./requirements.txt 17 | 18 | # iot sdk support 6.1.0 19 | RUN curl --connect-timeout 60 -m 3600 -fsSL http://lambda-public.oss-cn-hangzhou.aliyuncs.com/lambda/aliyunsdkiot_py3_v20170420.tar.gz | tar -xzC /usr/local/lib/python3.6/site-packages/aliyunsdkiot/request/ 20 | 21 | # Server path. 22 | ENV FC_SERVER_PATH=/var/fc/runtime/python3 23 | ENV FC_SERVER_LOG_PATH=${FC_SERVER_PATH}/var/log 24 | # Create directory. 25 | RUN mkdir -p ${FC_SERVER_LOG_PATH} 26 | ENV LD_LIBRARY_PATH=${FC_FUNC_CODE_PATH}:${FC_FUNC_CODE_PATH}/lib:/usr/local/lib 27 | 28 | # Start a shell by default 29 | CMD ["bash"] 30 | 31 | -------------------------------------------------------------------------------- /python3.6/base/requirements.txt: -------------------------------------------------------------------------------- 1 | aliyun-fc==0.6 2 | aliyun-fc2==2.3.0 3 | aliyun-log-python-sdk==0.6.38 4 | aliyun-mns==1.1.5 5 | aliyun-python-sdk-cdn==3.0.8 6 | aliyun-python-sdk-core==2.13.11 7 | aliyun-python-sdk-core-v3==2.13.11 8 | aliyun-python-sdk-dds==2.0.7 9 | aliyun-python-sdk-ecs==4.10.1 10 | aliyun-python-sdk-fnf==1.3.0 11 | aliyun-python-sdk-imm==1.3.4 12 | aliyun-python-sdk-iot==7.8.0 13 | aliyun-python-sdk-kms==2.14.0 14 | aliyun-python-sdk-ram==3.0.0 15 | aliyun-python-sdk-rds==2.1.4 16 | aliyun-python-sdk-sts==3.0.0 17 | aliyun-python-sdk-vpc==3.0.2 18 | asn1crypto==0.24.0 19 | backports.zoneinfo==0.2.1 20 | cbor==1.0.0 21 | certifi==2021.10.8 22 | cffi==1.11.5 23 | chardet==3.0.4 24 | charset-normalizer==2.0.11 25 | coverage==6.2 26 | cprotobuf==0.1.10 27 | crcmod==1.7 28 | cryptography==3.2.1 29 | cssselect==1.1.0 30 | cycler==0.11.0 31 | dateparser==1.1.0 32 | debugpy 33 | elasticsearch==6.8.2 34 | enum34==1.1.10 35 | future==0.18.2 36 | greenlet==0.4.13 37 | icc-rt==16.0.3 38 | importlib-resources==5.4.0 39 | intel-openmp==2022.0.2 40 | jmespath==0.10.0 41 | lxml==4.7.1 42 | lz4==3.1.10 43 | matplotlib==2.0.2 44 | opencv-python==3.3.0.10 45 | oss2==2.9.1 46 | parsel==1.6.0 47 | protobuf==3.13.0 48 | pyasn1==0.4.8 49 | pyasn1-modules==0.2.8 50 | pycparser==2.21 51 | pycryptodome==3.14.1 52 | pydatahub==2.11.2 53 | PyDispatcher==2.0.5 54 | pyOpenSSL==18.0.0 55 | pyparsing==3.0.7 56 | python-dateutil==2.8.2 57 | pytz==2021.3 58 | pytz-deprecation-shim==0.1.0.post0 59 | queuelib==1.6.2 60 | regex==2022.1.18 61 | requests==2.27.1 62 | Scrapy==1.4.0 63 | service-identity==18.1.0 64 | simplejson==3.17.6 65 | tablestore==5.1.0 66 | tzdata==2021.5 67 | tzlocal==4.1 68 | urllib3==1.23 69 | w3lib==1.22.0 70 | Wand==0.6.7 71 | zipp==3.6.0 72 | -------------------------------------------------------------------------------- /python3.6/build/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-python3.6:${TAG} 3 | 4 | ENV DEBIAN_FRONTEND=noninteractive 5 | 6 | RUN mkdir -p /mnt/auto 7 | RUN apt-get update \ 8 | && apt-get --no-install-recommends install -y apt-utils ca-certificates \ 9 | dialog \ 10 | vim \ 11 | cmake \ 12 | zip \ 13 | unzip \ 14 | clang \ 15 | build-essential \ 16 | libgmp3-dev \ 17 | python2.7-dev \ 18 | sudo \ 19 | && rm -rf /var/lib/apt/lists/* 20 | 21 | RUN echo "ALL ALL=NOPASSWD: ALL" >> /etc/sudoers 22 | 23 | ARG FUN_VERSION 24 | ARG FCLI_VERSION 25 | ARG FUN_INSTALL_VERSION 26 | 27 | RUN curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-${FCLI_VERSION}-linux-amd64.zip \ 28 | && unzip -o fcli.zip -d /usr/local/bin/ \ 29 | && rm fcli.zip 30 | 31 | RUN curl -o fun.zip https://gosspublic.alicdn.com/fun/fun-${FUN_VERSION}-linux.zip \ 32 | && unzip -o fun.zip -d /usr/local/bin/ \ 33 | && rm fun.zip \ 34 | && mv /usr/local/bin/fun-v* /usr/local/bin/fun 35 | 36 | RUN curl -o fun-install.zip https://gosspublic.alicdn.com/fun-install/fun-install-${FUN_INSTALL_VERSION}-linux-64.zip \ 37 | && unzip -o fun-install.zip -d /usr/local/bin/ \ 38 | && rm fun-install.zip \ 39 | && mv /usr/local/bin/fun-install-v* /usr/local/bin/fun-install \ 40 | && ln -s /usr/local/bin/fun-install /usr/local/bin/s-install 41 | 42 | RUN mv /usr/bin/update-alternatives /usr/bin/update-alternatives-origin \ 43 | && ((test -f /usr/bin/pycompile && mv /usr/bin/pycompile /usr/bin/pycompile-origin) || true) 44 | 45 | COPY commons/update-alternatives /usr/bin/ 46 | 47 | COPY commons/pycompile /usr/bin/ 48 | 49 | RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ 50 | 51 | WORKDIR /code -------------------------------------------------------------------------------- /python3.6/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-python3.6:${TAG} 3 | 4 | ENV PYTHONUNBUFFERED=1 5 | 6 | RUN pip install ptvsd -i https://mirrors.aliyun.com/pypi/simple/ 7 | RUN pip install pydevd -i https://mirrors.aliyun.com/pypi/simple/ 8 | 9 | RUN rm -rf /var/runtime /var/lang && \ 10 | curl http://cli.so/ca_tgz/python3.6.tgz | tar -zx -C / && \ 11 | rm -rf /var/fc/runtime/*/var/log/* 12 | 13 | COPY commons/function-compute-mock.sh /var/fc/runtime/python3/mock 14 | COPY python3.6/run/agent.sh /var/fc/runtime/python3/agent.sh 15 | 16 | ENTRYPOINT ["/var/fc/runtime/python3/mock"] 17 | -------------------------------------------------------------------------------- /python3.6/run/agent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ################################################################### 3 | # To start the server, use this script. 4 | # 5 | # The server is configured with environment variables. The full list 6 | # of environment variables can be seen in ./src/constant.js 7 | ################################################################### 8 | 9 | # The absolute path of this file. 10 | CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd -P )" 11 | 12 | # Set some default configuration. 13 | export FC_SERVER_PORT=${FC_SERVER_PORT:=9000} 14 | export FC_SERVER_PATH=${FC_SERVER_PATH:=${CURDIR}} 15 | export FC_SERVER_LOG_PATH=${FC_SERVER_LOG_PATH:=${CURDIR}/var/log} 16 | export FC_SERVER_LOG_LEVEL=${FC_SERVER_LOG_LEVEL:=INFO} 17 | 18 | export FC_FUNC_CODE_PATH=${FC_FUNC_CODE_PATH:=${CURDIR}} 19 | export FC_FUNC_LOG_PATH=${FC_FUNC_LOG_PATH:=${CURDIR}/var/log} 20 | 21 | Help() { 22 | echo "Usage:" 23 | echo " $0 command" 24 | echo "Commands" 25 | echo " start start up server" 26 | echo " help print help page" 27 | } 28 | 29 | 30 | if [ $# -eq 0 ] 31 | then 32 | echo "Missing arguments." 33 | Help 34 | exit 0; 35 | fi 36 | 37 | command=$1 38 | case ${command} in 39 | "start") 40 | python -W ignore ${DEBUG_OPTIONS} ${FC_SERVER_PATH}/src/server.py 41 | ;; 42 | "help") 43 | Help 44 | ;; 45 | *) 46 | Help 47 | ;; 48 | esac 49 | -------------------------------------------------------------------------------- /python3.9/base/Dockerfile: -------------------------------------------------------------------------------- 1 | # aliyunfc/fc-runtime:python39-stretch-base see commons directory 2 | FROM aliyunfc/fc-runtime:python39-stretch-base 3 | 4 | COPY commons/pip.conf /etc/pip.conf 5 | 6 | # Change work directory. 7 | WORKDIR ${FC_FUNC_CODE_PATH} 8 | 9 | # Install third party libraries for user function. 10 | RUN pip install -U pip -U setuptools 11 | 12 | # fc-docker fix: as online 13 | COPY python3.9/base/requirements.txt ./requirements.txt 14 | RUN pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ 15 | RUN rm ./requirements.txt 16 | 17 | # iot sdk support 6.1.0 18 | RUN curl --connect-timeout 60 -m 3600 -fsSL http://lambda-public.oss-cn-hangzhou.aliyuncs.com/lambda/aliyunsdkiot_py3_v20170420.tar.gz | tar -xzC /usr/local/lib/python3.9/site-packages/aliyunsdkiot/request/ 19 | 20 | # Server path. 21 | ENV FC_SERVER_PATH=/var/fc/runtime/python3 22 | ENV FC_SERVER_LOG_PATH=${FC_SERVER_PATH}/var/log 23 | # Create directory. 24 | RUN mkdir -p ${FC_SERVER_LOG_PATH} 25 | ENV LD_LIBRARY_PATH=${FC_FUNC_CODE_PATH}:${FC_FUNC_CODE_PATH}/lib:/usr/local/lib 26 | 27 | # Install libopencv-dev 28 | RUN apt-get update \ 29 | && apt-get install -y libopencv-dev libpq-dev \ 30 | && rm -rf /var/lib/apt/lists/* 31 | 32 | # Start a shell by default 33 | CMD ["bash"] 34 | 35 | -------------------------------------------------------------------------------- /python3.9/base/requirements.txt: -------------------------------------------------------------------------------- 1 | aiohttp==3.8.1 2 | aiosignal==1.2.0 3 | alibabacloud-credentials==0.2.0 4 | alibabacloud-endpoint-util==0.0.3 5 | alibabacloud-fc-open20210406==1.0.1 6 | alibabacloud-gateway-spi==0.0.1 7 | alibabacloud-openapi-util==0.1.5 8 | alibabacloud-tea==0.2.8 9 | alibabacloud-tea-openapi==0.3.0 10 | alibabacloud-tea-util==0.3.5 11 | aliyun-fc==0.6 12 | aliyun-fc2==2.5.0 13 | aliyun-log-python-sdk==0.7.3 14 | aliyun-mns==1.1.5 15 | aliyun-python-sdk-cdn==3.6.7 16 | aliyun-python-sdk-core==2.13.35 17 | aliyun-python-sdk-dds==3.6.0 18 | aliyun-python-sdk-ecs==4.24.11 19 | aliyun-python-sdk-fnf==1.8.0 20 | aliyun-python-sdk-imm==1.23.4 21 | aliyun-python-sdk-iot==8.30.0 22 | aliyun-python-sdk-kms==2.15.0 23 | aliyun-python-sdk-ram==3.2.0 24 | aliyun-python-sdk-rds==2.6.1 25 | aliyun-python-sdk-sts==3.1.0 26 | aliyun-python-sdk-vpc==3.0.15 27 | asn1crypto==1.4.0 28 | async-timeout==4.0.1 29 | attrs==21.2.0 30 | Automat==20.2.0 31 | cbor==1.0.0 32 | certifi==2021.10.8 33 | cffi==1.15.0 34 | chardet==4.0.0 35 | charset-normalizer==2.0.8 36 | constantly==15.1.0 37 | coverage==6.2 38 | crcmod==1.7 39 | cryptography==36.0.0 40 | cssselect==1.1.0 41 | cycler==0.11.0 42 | Cython==0.29.24 43 | dateparser==1.1.0 44 | debugpy 45 | elasticsearch==7.15.2 46 | enum34==1.1.10 47 | frozenlist==1.2.0 48 | future==0.18.2 49 | greenlet==1.1.2 50 | h2==3.2.0 51 | hpack==3.0.0 52 | hyperframe==5.2.0 53 | hyperlink==21.0.0 54 | icc-rt==2020.0.133 55 | idna==3.3 56 | incremental==21.3.0 57 | intel-openmp==2020.0.133 58 | itemadapter==0.4.0 59 | itemloaders==1.0.4 60 | jmespath==0.10.0 61 | kiwisolver==1.3.2 62 | lxml==4.6.4 63 | matplotlib==3.4.3 64 | multidict==5.2.0 65 | numpy==1.21.4 66 | opencv-python==4.5.4.58 67 | oss2==2.15.0 68 | parsel==1.6.0 69 | Pillow==8.4.0 70 | priority==1.3.0 71 | Protego==0.1.16 72 | protobuf==3.19.1 73 | pyasn1==0.4.8 74 | pyasn1-modules==0.2.8 75 | pycparser==2.21 76 | pycryptodome==3.11.0 77 | PyDispatcher==2.0.5 78 | pyOpenSSL==21.0.0 79 | pyparsing==3.0.6 80 | python-dateutil==2.8.2 81 | pytz==2021.3 82 | pytz-deprecation-shim==0.1.0.post0 83 | queuelib==1.6.2 84 | regex==2021.11.10 85 | requests==2.26.0 86 | scipy==1.7.2 87 | Scrapy==2.5.1 88 | service-identity==21.1.0 89 | six==1.16.0 90 | tablestore==5.2.1 91 | Twisted==21.7.0 92 | typing_extensions==4.0.0 93 | tzdata==2021.5 94 | tzlocal==4.1 95 | urllib3==1.26.7 96 | w3lib==1.22.0 97 | Wand==0.6.7 98 | yarl==1.7.2 99 | zope.interface==5.4.0 -------------------------------------------------------------------------------- /python3.9/build/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-python3.9:${TAG} 3 | 4 | ENV DEBIAN_FRONTEND=noninteractive 5 | 6 | RUN mkdir -p /mnt/auto 7 | RUN apt-get update \ 8 | && apt-get --no-install-recommends install -y apt-utils ca-certificates \ 9 | dialog \ 10 | vim \ 11 | cmake \ 12 | zip \ 13 | unzip \ 14 | clang \ 15 | build-essential \ 16 | libgmp3-dev \ 17 | python2.7-dev \ 18 | sudo \ 19 | && rm -rf /var/lib/apt/lists/* 20 | 21 | RUN echo "ALL ALL=NOPASSWD: ALL" >> /etc/sudoers 22 | 23 | ARG FUN_VERSION 24 | ARG FCLI_VERSION 25 | ARG FUN_INSTALL_VERSION 26 | 27 | RUN curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-${FCLI_VERSION}-linux-amd64.zip \ 28 | && unzip -o fcli.zip -d /usr/local/bin/ \ 29 | && rm fcli.zip 30 | 31 | RUN curl -o fun.zip https://gosspublic.alicdn.com/fun/fun-${FUN_VERSION}-linux.zip \ 32 | && unzip -o fun.zip -d /usr/local/bin/ \ 33 | && rm fun.zip \ 34 | && mv /usr/local/bin/fun-v* /usr/local/bin/fun 35 | 36 | RUN curl -o fun-install.zip https://gosspublic.alicdn.com/fun-install/fun-install-${FUN_INSTALL_VERSION}-linux-64.zip \ 37 | && unzip -o fun-install.zip -d /usr/local/bin/ \ 38 | && rm fun-install.zip \ 39 | && mv /usr/local/bin/fun-install-v* /usr/local/bin/fun-install \ 40 | && ln -s /usr/local/bin/fun-install /usr/local/bin/s-install 41 | 42 | RUN mv /usr/bin/update-alternatives /usr/bin/update-alternatives-origin \ 43 | && ((test -f /usr/bin/pycompile && mv /usr/bin/pycompile /usr/bin/pycompile-origin) || true) 44 | 45 | COPY commons/update-alternatives /usr/bin/ 46 | 47 | COPY commons/pycompile /usr/bin/ 48 | 49 | RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ 50 | 51 | WORKDIR /code -------------------------------------------------------------------------------- /python3.9/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG TAG="latest" 2 | FROM aliyunfc/runtime-python3.9:${TAG} 3 | 4 | ENV PYTHONUNBUFFERED=1 5 | 6 | RUN pip install ptvsd -i https://mirrors.aliyun.com/pypi/simple/ 7 | RUN pip install pydevd -i https://mirrors.aliyun.com/pypi/simple/ 8 | 9 | RUN rm -rf /var/runtime /var/lang && \ 10 | curl http://cli.so/ca_tgz/python3.9.tgz | tar -zx -C / && \ 11 | rm -rf /var/fc/runtime/*/var/log/* 12 | 13 | COPY commons/function-compute-mock.sh /var/fc/runtime/python3/mock 14 | COPY python3.9/run/agent.sh /var/fc/runtime/python3/agent.sh 15 | 16 | ENTRYPOINT ["/var/fc/runtime/python3/mock"] 17 | -------------------------------------------------------------------------------- /python3.9/run/agent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ################################################################### 3 | # To start the server, use this script. 4 | # 5 | # The server is configured with environment variables. The full list 6 | # of environment variables can be seen in ./src/constant.js 7 | ################################################################### 8 | 9 | # The absolute path of this file. 10 | CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd -P )" 11 | 12 | # Set some default configuration. 13 | export FC_SERVER_PORT=${FC_SERVER_PORT:=9000} 14 | export FC_SERVER_PATH=${FC_SERVER_PATH:=${CURDIR}} 15 | export FC_SERVER_LOG_PATH=${FC_SERVER_LOG_PATH:=${CURDIR}/var/log} 16 | export FC_SERVER_LOG_LEVEL=${FC_SERVER_LOG_LEVEL:=INFO} 17 | 18 | export FC_FUNC_CODE_PATH=${FC_FUNC_CODE_PATH:=${CURDIR}} 19 | export FC_FUNC_LOG_PATH=${FC_FUNC_LOG_PATH:=${CURDIR}/var/log} 20 | 21 | Help() { 22 | echo "Usage:" 23 | echo " $0 command" 24 | echo "Commands" 25 | echo " start start up server" 26 | echo " help print help page" 27 | } 28 | 29 | 30 | if [ $# -eq 0 ] 31 | then 32 | echo "Missing arguments." 33 | Help 34 | exit 0; 35 | fi 36 | 37 | command=$1 38 | case ${command} in 39 | "start") 40 | python -W ignore ${DEBUG_OPTIONS} ${FC_SERVER_PATH}/src/server.py 41 | ;; 42 | "help") 43 | Help 44 | ;; 45 | *) 46 | Help 47 | ;; 48 | esac 49 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | RUNTIME=${RUNTIME:?missing runtime} 6 | IMAGE=${IMAGE:?image missing} 7 | 8 | if [ ! -d "$(pwd)/demos/$RUNTIME" ]; then 9 | echo "folder $(pwd)/demos/$RUNTIME not exist, will skip related test" 10 | exit 0 11 | fi 12 | 13 | if [[ "$RUNTIME" = "java8" ]] || [[ "$RUNTIME" = "java11" ]]; then 14 | MOUNT=$(pwd)/demos/$RUNTIME/target 15 | HANDLER=examples.Hello::handleRequest 16 | INITIALIZER=examples.Hello::initialize 17 | else 18 | MOUNT=$(pwd)/demos/$RUNTIME 19 | HANDLER=index.handler 20 | INITIALIZER=initializer 21 | fi 22 | 23 | echo "mount: $MOUNT" 24 | 25 | echo "docker run --rm -v $MOUNT:/code $IMAGE -h $HANDLER -i $INITIALIZER" 26 | 27 | if ! docker run --rm -it -v $MOUNT:/code $IMAGE -h $HANDLER -i $INITIALIZER | grep -q '2' ; then 28 | echo "runtime $RUNTIME test failed"; 29 | exit 1; 30 | fi -------------------------------------------------------------------------------- /utils/dump/dump-dotnetcore/.gitignore: -------------------------------------------------------------------------------- 1 | [Bb]in/ 2 | [Oo]bj/ 3 | [Oo]ut/ -------------------------------------------------------------------------------- /utils/dump/dump-dotnetcore/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Diagnostics; 4 | using Aliyun.OSS; 5 | using Aliyun.Serverless.Core; 6 | 7 | namespace dump_dotnetcore 8 | { 9 | public class App 10 | { 11 | public string Handler(Stream input, IFcContext context) 12 | { 13 | String fileName = Environment.GetEnvironmentVariable("FileName"); 14 | String source = $"/tmp/{fileName}"; 15 | String dest = fileName; 16 | String cmd = $"tar -cpzf {source} --numeric-owner --ignore-failed-read /var/fc/runtime"; 17 | 18 | var process = new Process() 19 | { 20 | StartInfo = new ProcessStartInfo 21 | { 22 | FileName = "/bin/bash", 23 | Arguments = $"-c \"{cmd}\"", 24 | RedirectStandardOutput = true, 25 | UseShellExecute = false, 26 | CreateNoWindow = true, 27 | } 28 | }; 29 | process.Start(); 30 | string result = process.StandardOutput.ReadToEnd(); 31 | process.WaitForExit(); 32 | 33 | OssClient ossClient = new OssClient( 34 | Environment.GetEnvironmentVariable("OSSEndpoint"), 35 | context.Credentials.AccessKeyId, 36 | context.Credentials.AccessKeySecret, 37 | context.Credentials.SecurityToken 38 | ); 39 | try 40 | { 41 | // 上传文件。 42 | ossClient.PutObject( 43 | Environment.GetEnvironmentVariable("Bucket"), 44 | dest, 45 | source 46 | ); 47 | } 48 | catch (Exception ex) 49 | { 50 | return ex.Message; 51 | } 52 | return result; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /utils/dump/dump-dotnetcore/dump-dotnetcore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Library 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /utils/dump/dump-java11/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.aliyun.fc.runtime 6 | dump-java11 7 | 1.0.0 8 | jar 9 | 10 | 11 | 12 | com.aliyun.fc.runtime 13 | fc-java-core 14 | 1.2.0 15 | 16 | 17 | com.aliyun.oss 18 | aliyun-sdk-oss 19 | 2.6.1 20 | 21 | 22 | 23 | 24 | 25 | 26 | maven-assembly-plugin 27 | 3.1.0 28 | 29 | 30 | jar-with-dependencies 31 | 32 | false 33 | 34 | 35 | 36 | make-assembly 37 | package 38 | 39 | single 40 | 41 | 42 | 43 | 44 | 45 | org.apache.maven.plugins 46 | maven-compiler-plugin 47 | 48 | 1.8 49 | 1.8 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /utils/dump/dump-java11/src/main/java/com/aliyun/fc/runtime/DumpJava11.java: -------------------------------------------------------------------------------- 1 | package com.aliyun.fc.runtime; 2 | 3 | import com.aliyun.oss.OSSClient; 4 | 5 | import java.io.File; 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.io.OutputStream; 9 | import java.util.Scanner; 10 | 11 | public class DumpJava11 implements StreamRequestHandler { 12 | 13 | @Override 14 | public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException { 15 | String filename = System.getenv("FileName"); 16 | String bucketName = System.getenv("Bucket"); 17 | String endpoint = System.getenv("OSSEndpoint"); 18 | String source = String.format("/tmp/%s", filename); 19 | String target = String.format("%s", filename); 20 | 21 | String cmd = String.format("tar -cpzf %s --numeric-owner --ignore-failed-read /var/fc/runtime", source); 22 | 23 | Process process = Runtime.getRuntime().exec(new String[] { "sh", "-c", cmd }); 24 | 25 | try (Scanner stdoutScanner = new Scanner(process.getInputStream()); 26 | Scanner stderrScanner = new Scanner(process.getErrorStream())) { 27 | // Echo all stdout first 28 | while (stdoutScanner.hasNextLine()) { 29 | System.out.println(stdoutScanner.nextLine()); 30 | } 31 | // Then echo stderr 32 | while (stderrScanner.hasNextLine()) { 33 | System.err.println(stderrScanner.nextLine()); 34 | } 35 | } 36 | 37 | try { 38 | process.waitFor(); 39 | } catch (InterruptedException e) { 40 | e.printStackTrace(); 41 | } 42 | 43 | if (process.exitValue() != 0) { 44 | return ; 45 | } 46 | 47 | context.getLogger().info("Zipping done! Uploading..."); 48 | 49 | Credentials credentials = context.getExecutionCredentials(); 50 | 51 | OSSClient ossClient = new OSSClient(endpoint, 52 | credentials.getAccessKeyId(), 53 | credentials.getAccessKeySecret(), 54 | credentials.getSecurityToken()); 55 | 56 | ossClient.putObject(bucketName, target, new File(source)); 57 | 58 | context.getLogger().info("Uploading done!"); 59 | outputStream.write(new String("Zipping done and uploading done!").getBytes()); 60 | } 61 | } -------------------------------------------------------------------------------- /utils/dump/dump-java8/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.aliyun.fc.runtime 6 | dump-java8 7 | 1.0.0 8 | jar 9 | 10 | 11 | 12 | com.aliyun.fc.runtime 13 | fc-java-core 14 | 1.2.0 15 | 16 | 17 | com.aliyun.oss 18 | aliyun-sdk-oss 19 | 2.6.1 20 | 21 | 22 | 23 | 24 | 25 | 26 | maven-assembly-plugin 27 | 3.1.0 28 | 29 | 30 | jar-with-dependencies 31 | 32 | false 33 | 34 | 35 | 36 | make-assembly 37 | package 38 | 39 | single 40 | 41 | 42 | 43 | 44 | 45 | org.apache.maven.plugins 46 | maven-compiler-plugin 47 | 48 | 1.8 49 | 1.8 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /utils/dump/dump-java8/src/main/java/com/aliyun/fc/runtime/DumpJava8.java: -------------------------------------------------------------------------------- 1 | package com.aliyun.fc.runtime; 2 | 3 | import com.aliyun.oss.OSSClient; 4 | 5 | import java.io.File; 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.io.OutputStream; 9 | import java.util.Scanner; 10 | 11 | public class DumpJava8 implements StreamRequestHandler { 12 | 13 | @Override 14 | public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException { 15 | String filename = System.getenv("FileName"); 16 | String bucketName = System.getenv("Bucket"); 17 | String endpoint = System.getenv("OSSEndpoint"); 18 | String source = String.format("/tmp/%s", filename); 19 | String target = String.format("%s", filename); 20 | 21 | String cmd = String.format("tar -cpzf %s --numeric-owner --ignore-failed-read /var/fc/runtime", source); 22 | 23 | Process process = Runtime.getRuntime().exec(new String[] { "sh", "-c", cmd }); 24 | 25 | try (Scanner stdoutScanner = new Scanner(process.getInputStream()); 26 | Scanner stderrScanner = new Scanner(process.getErrorStream())) { 27 | // Echo all stdout first 28 | while (stdoutScanner.hasNextLine()) { 29 | System.out.println(stdoutScanner.nextLine()); 30 | } 31 | // Then echo stderr 32 | while (stderrScanner.hasNextLine()) { 33 | System.err.println(stderrScanner.nextLine()); 34 | } 35 | } 36 | 37 | try { 38 | process.waitFor(); 39 | } catch (InterruptedException e) { 40 | e.printStackTrace(); 41 | } 42 | 43 | if (process.exitValue() != 0) { 44 | return ; 45 | } 46 | 47 | context.getLogger().info("Zipping done! Uploading..."); 48 | 49 | Credentials credentials = context.getExecutionCredentials(); 50 | 51 | OSSClient ossClient = new OSSClient(endpoint, 52 | credentials.getAccessKeyId(), 53 | credentials.getAccessKeySecret(), 54 | credentials.getSecurityToken()); 55 | 56 | ossClient.putObject(bucketName, target, new File(source)); 57 | 58 | context.getLogger().info("Uploading done!"); 59 | outputStream.write(new String("Zipping done and uploading done!").getBytes()); 60 | } 61 | } -------------------------------------------------------------------------------- /utils/dump/dump-nodejs/dump-nodejs.js: -------------------------------------------------------------------------------- 1 | var OSS = require('ali-oss'); 2 | var fs = require('fs'); 3 | var childProcess = require('child_process'); 4 | 5 | function uploadFile(path, dest, context, cb) { 6 | console.log('bucket name: ', process.env['Bucket']); 7 | const oss = OSS.Wrapper({ 8 | accessKeyId: context.credentials.accessKeyId, 9 | accessKeySecret: context.credentials.accessKeySecret, 10 | stsToken: context.credentials.securityToken, 11 | bucket: process.env['Bucket'], 12 | region: process.env['OSSRegion'] 13 | }); 14 | 15 | const stream = fs.createReadStream(path); 16 | 17 | oss.putStream(dest, stream).then(function (result) { 18 | cb(null, result); 19 | }).catch(function(err) { 20 | cb(err); 21 | }); 22 | } 23 | 24 | exports.handler = function(event, context, cb) { 25 | const filename = process.env['FileName']; 26 | const source = `/tmp/${filename}`; 27 | const dest = `${filename}`; 28 | 29 | const cmd = `tar -cpzPf /tmp/${filename} --numeric-owner --ignore-failed-read /var/fc/runtime`; 30 | 31 | const child = childProcess.spawn('sh', ['-c', event.cmd || cmd]); 32 | child.stdout.setEncoding('utf8'); 33 | child.stderr.setEncoding('utf8'); 34 | child.stdout.on('data', console.log.bind(console)); 35 | child.stderr.on('data', console.error.bind(console)); 36 | child.on('error', cb); 37 | 38 | child.on('close', () => { 39 | if (event.cmd) return cb(); 40 | console.log('Zipping done! Uploading...'); 41 | uploadFile(source, dest, context, cb); 42 | }); 43 | }; 44 | -------------------------------------------------------------------------------- /utils/dump/dump-nodejs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dump-nodejs8", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "dump-nodejs8.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "ali-oss": "^4.3.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /utils/dump/dump-php/dump-php.php: -------------------------------------------------------------------------------- 1 | putObject($bucket, $dest, $contents); 32 | 33 | return 'Zipping done and uploading done!'; 34 | } 35 | -------------------------------------------------------------------------------- /utils/dump/dump-python/dump-python.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import subprocess 4 | import oss2 5 | 6 | 7 | def handler(event, context): 8 | package_dir = os.environ['PackageDir'] 9 | filename = os.environ['FileName'] 10 | source = '/tmp/{}'.format(filename) 11 | dest = filename 12 | 13 | cmd = 'tar -cpzf {} --numeric-owner --ignore-failed-read {}'.format( 14 | source, package_dir) 15 | 16 | subprocess.call(['sh', '-c', cmd]) 17 | 18 | print('Zipping done! Uploading...') 19 | 20 | creds = context.credentials 21 | auth = oss2.StsAuth(creds.access_key_id, 22 | creds.access_key_secret, 23 | creds.security_token) 24 | 25 | endpoint = os.environ['OSSEndpoint'] 26 | bucket = os.environ['Bucket'] 27 | 28 | print('endpoint: ' + endpoint) 29 | print('bucket: ' + bucket) 30 | 31 | bucket = oss2.Bucket(auth, endpoint, bucket) 32 | 33 | bucket.put_object_from_file(dest, source) 34 | 35 | return 'Zipping done and uploading done!' 36 | -------------------------------------------------------------------------------- /utils/dump/s.yaml: -------------------------------------------------------------------------------- 1 | edition: 1.0.0 2 | name: fc-util-dumps 3 | access: fc-console 4 | vars: 5 | region: cn-shanghai 6 | dump-service: 7 | name: dump-service 8 | description: dump service 9 | role: 10 | name: dump-serviceDefaultRole 11 | policies: 12 | - AliyunOSSFullAccess 13 | internetAccess: true 14 | services: 15 | fc-dump-service-dump-nodejs12: 16 | component: devsapp/fc 17 | props: 18 | region: ${vars.region} 19 | service: ${vars.dump-service} 20 | function: 21 | name: dump-nodejs12 22 | handler: dump-nodejs.handler 23 | timeout: 600 24 | runtime: nodejs12 25 | environmentVariables: 26 | Bucket: alifc-docker 27 | OSSRegion: oss-cn-shanghai 28 | FileName: nodejs12.tgz 29 | codeUri: ./dump-nodejs 30 | fc-dump-service-dump-nodejs10: 31 | component: devsapp/fc 32 | props: 33 | region: ${vars.region} 34 | service: ${vars.dump-service} 35 | function: 36 | name: dump-nodejs10 37 | handler: dump-nodejs.handler 38 | timeout: 600 39 | runtime: nodejs10 40 | environmentVariables: 41 | Bucket: alifc-docker 42 | OSSRegion: oss-cn-shanghai 43 | FileName: nodejs10.tgz 44 | codeUri: ./dump-nodejs 45 | fc-dump-service-dump-nodejs8: 46 | component: devsapp/fc 47 | props: 48 | region: ${vars.region} 49 | service: ${vars.dump-service} 50 | function: 51 | name: dump-nodejs8 52 | handler: dump-nodejs.handler 53 | timeout: 600 54 | runtime: nodejs8 55 | environmentVariables: 56 | Bucket: alifc-docker 57 | OSSRegion: oss-cn-shanghai 58 | FileName: nodejs8.tgz 59 | codeUri: ./dump-nodejs 60 | fc-dump-service-dump-nodejs6: 61 | component: devsapp/fc 62 | props: 63 | region: ${vars.region} 64 | service: ${vars.dump-service} 65 | function: 66 | name: dump-nodejs6 67 | handler: dump-nodejs.handler 68 | timeout: 600 69 | runtime: nodejs6 70 | environmentVariables: 71 | Bucket: alifc-docker 72 | OSSRegion: oss-cn-shanghai 73 | FileName: nodejs6.tgz 74 | codeUri: ./dump-nodejs 75 | fc-dump-service-dump-python27: 76 | component: devsapp/fc 77 | props: 78 | region: ${vars.region} 79 | service: ${vars.dump-service} 80 | function: 81 | name: dump-python27 82 | handler: dump-python.handler 83 | timeout: 600 84 | runtime: python2.7 85 | environmentVariables: 86 | Bucket: alifc-docker 87 | OSSRegion: oss-cn-shanghai 88 | OSSEndpoint: http://oss-cn-shanghai.aliyuncs.com 89 | FileName: python2.7.tgz 90 | PackageDir: /var/fc/runtime 91 | codeUri: ./dump-python 92 | fc-dump-service-dump-python36: 93 | component: devsapp/fc 94 | props: 95 | region: ${vars.region} 96 | service: ${vars.dump-service} 97 | function: 98 | name: dump-python36 99 | handler: dump-python.handler 100 | timeout: 600 101 | runtime: python3 102 | environmentVariables: 103 | Bucket: alifc-docker 104 | OSSRegion: oss-cn-shanghai 105 | OSSEndpoint: http://oss-cn-shanghai.aliyuncs.com 106 | FileName: python3.6.tgz 107 | PackageDir: /var/fc/runtime 108 | codeUri: ./dump-python 109 | fc-dump-service-dump-python39: 110 | component: devsapp/fc 111 | props: 112 | region: ${vars.region} 113 | service: ${vars.dump-service} 114 | function: 115 | name: dump-python39 116 | handler: dump-python.handler 117 | timeout: 600 118 | runtime: python3.9 119 | environmentVariables: 120 | Bucket: alifc-docker 121 | OSSRegion: oss-cn-shanghai 122 | OSSEndpoint: http://oss-cn-shanghai.aliyuncs.com 123 | FileName: python3.9.tgz 124 | PackageDir: /var/fc/runtime 125 | codeUri: ./dump-python 126 | fc-dump-service-dump-java8: 127 | component: devsapp/fc 128 | props: 129 | region: ${vars.region} 130 | service: ${vars.dump-service} 131 | function: 132 | name: dump-java8 133 | handler: com.aliyun.fc.runtime.DumpJava8::handleRequest 134 | timeout: 600 135 | runtime: java8 136 | environmentVariables: 137 | FileName: java8.tgz 138 | Bucket: alifc-docker 139 | OSSRegion: oss-cn-shanghai 140 | OSSEndpoint: http://oss-cn-shanghai.aliyuncs.com 141 | codeUri: ./dump-java8/target/dump-java8-1.0.0.jar 142 | fc-dump-service-dump-java11: 143 | component: devsapp/fc 144 | props: 145 | region: ${vars.region} 146 | service: ${vars.dump-service} 147 | function: 148 | name: dump-java11 149 | handler: com.aliyun.fc.runtime.DumpJava11::handleRequest 150 | timeout: 600 151 | runtime: java11 152 | environmentVariables: 153 | FileName: java11.tgz 154 | Bucket: alifc-docker 155 | OSSRegion: oss-cn-shanghai 156 | OSSEndpoint: http://oss-cn-shanghai.aliyuncs.com 157 | codeUri: ./dump-java11/target/dump-java11-1.0.0.jar 158 | fc-dump-service-dump-php72: 159 | component: devsapp/fc 160 | props: 161 | region: ${vars.region} 162 | service: ${vars.dump-service} 163 | function: 164 | name: dump-php72 165 | handler: dump-php.handler 166 | timeout: 600 167 | runtime: php7.2 168 | environmentVariables: 169 | Bucket: alifc-docker 170 | OSSRegion: oss-cn-shanghai 171 | OSSEndpoint: http://oss-cn-shanghai.aliyuncs.com 172 | FileName: php7.2.tgz 173 | PackageDir: /var/fc/runtime/php7.2 174 | codeUri: ./dump-php 175 | fc-dump-service-dump-dotnetcore21: 176 | component: devsapp/fc 177 | props: 178 | region: ${vars.region} 179 | service: ${vars.dump-service} 180 | function: 181 | name: dump-dotnetcore21 182 | handler: dump-dotnetcore::dump_dotnetcore.App::Handler 183 | timeout: 600 184 | runtime: dotnetcore2.1 185 | environmentVariables: 186 | Bucket: alifc-docker 187 | OSSEndpoint: oss-cn-shanghai.aliyuncs.com 188 | FileName: dotnetcore2.1.tgz 189 | codeUri: ./dump-dotnetcore/bin/Release/netcoreapp2.1/publish/ 190 | --------------------------------------------------------------------------------