forked from kyma-project/kyma
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Python39 runtime (kyma-project#11498)
* Add Python39 runtime * doc update * update alpine for python39 * Update docs/serverless/03-01-function-specification.md Co-authored-by: Karolina Zydek <[email protected]> * Update docs/serverless/03-04-git-source-type.md Co-authored-by: Karolina Zydek <[email protected]> * cleanup * fix typo * fix docs typo Co-authored-by: Karolina Zydek <[email protected]>
- Loading branch information
Showing
22 changed files
with
518 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
components/function-controller/config/samples/serverless_v1alpha1_function_python39.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: serverless.kyma-project.io/v1alpha1 | ||
kind: Function | ||
metadata: | ||
name: python39-sample-fn | ||
spec: | ||
runtime: python39 | ||
source: | | ||
def main(event, context): | ||
return "Hello world from Python" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
components/function-controller/pkg/apis/serverless/v1alpha1/zz_generated.deepcopy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
# | ||
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh" | ||
# | ||
# PLEASE DO NOT EDIT IT DIRECTLY. | ||
# | ||
|
||
# We use this code to manually use newest alpine and nodejs. | ||
# Use official build when it will be available. | ||
|
||
FROM alpine:3.13.5 | ||
|
||
# ensure local python is preferred over distribution python | ||
ENV PATH /usr/local/bin:$PATH | ||
|
||
# http://bugs.python.org/issue19846 | ||
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. | ||
ENV LANG C.UTF-8 | ||
|
||
# runtime dependencies | ||
RUN set -eux; \ | ||
apk add --no-cache \ | ||
# install ca-certificates so that HTTPS works consistently | ||
ca-certificates \ | ||
; | ||
# other runtime dependencies for Python are installed later | ||
|
||
ENV GPG_KEY E3FF2839C048B25C084DEBE9B26995E310250568 | ||
ENV PYTHON_VERSION 3.9.5 | ||
|
||
|
||
# expat-dev for alpine:3.13.5 is outdated and vulnerable. We will install it from edge . | ||
# We can't upgrade fully to 3.14 because it has a dependancy on a specific recent docker version https://gitlab.alpinelinux.org/alpine/aports/-/issues/12396 | ||
|
||
RUN set -ex \ | ||
&& apk add --no-cache --virtual .fetch-deps --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main \ | ||
gnupg \ | ||
tar \ | ||
xz \ | ||
expat-dev \ | ||
\ | ||
&& wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \ | ||
&& wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \ | ||
&& export GNUPGHOME="$(mktemp -d)" \ | ||
&& gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY" \ | ||
&& gpg --batch --verify python.tar.xz.asc python.tar.xz \ | ||
&& { command -v gpgconf > /dev/null && gpgconf --kill all || :; } \ | ||
&& rm -rf "$GNUPGHOME" python.tar.xz.asc \ | ||
&& mkdir -p /usr/src/python \ | ||
&& tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \ | ||
&& rm python.tar.xz \ | ||
\ | ||
&& apk add --no-cache --virtual .build-deps \ | ||
bluez-dev \ | ||
bzip2-dev \ | ||
coreutils \ | ||
dpkg-dev dpkg \ | ||
findutils \ | ||
gcc \ | ||
gdbm-dev \ | ||
libc-dev \ | ||
libffi-dev \ | ||
libnsl-dev \ | ||
libtirpc-dev \ | ||
linux-headers \ | ||
make \ | ||
ncurses-dev \ | ||
openssl-dev \ | ||
pax-utils \ | ||
readline-dev \ | ||
sqlite-dev \ | ||
tcl-dev \ | ||
tk \ | ||
tk-dev \ | ||
util-linux-dev \ | ||
xz-dev \ | ||
zlib-dev \ | ||
# add build deps before removing fetch deps in case there's overlap | ||
&& apk del --no-network .fetch-deps \ | ||
\ | ||
&& cd /usr/src/python \ | ||
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ | ||
&& ./configure \ | ||
--build="$gnuArch" \ | ||
--enable-loadable-sqlite-extensions \ | ||
--enable-optimizations \ | ||
--enable-option-checking=fatal \ | ||
--enable-shared \ | ||
--with-system-expat \ | ||
--with-system-ffi \ | ||
--without-ensurepip \ | ||
&& make -j "$(nproc)" \ | ||
# set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() | ||
# https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 | ||
EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000" \ | ||
LDFLAGS="-Wl,--strip-all" \ | ||
&& make install \ | ||
&& rm -rf /usr/src/python \ | ||
\ | ||
&& find /usr/local -depth \ | ||
\( \ | ||
\( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ | ||
-o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name '*.a' \) \) \ | ||
-o \( -type f -a -name 'wininst-*.exe' \) \ | ||
\) -exec rm -rf '{}' + \ | ||
\ | ||
&& find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | ||
| tr ',' '\n' \ | ||
| sort -u \ | ||
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ | ||
| xargs -rt apk add --no-cache --virtual .python-rundeps \ | ||
&& apk del --no-network .build-deps \ | ||
\ | ||
&& python3 --version | ||
|
||
# make some useful symlinks that are expected to exist | ||
RUN cd /usr/local/bin \ | ||
&& ln -s idle3 idle \ | ||
&& ln -s pydoc3 pydoc \ | ||
&& ln -s python3 python \ | ||
&& ln -s python3-config python-config | ||
|
||
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'" | ||
ENV PYTHON_PIP_VERSION 21.0.1 | ||
# https://github.com/pypa/get-pip | ||
ENV PYTHON_GET_PIP_URL https://github.com/pypa/get-pip/raw/29f37dbe6b3842ccd52d61816a3044173962ebeb/public/get-pip.py | ||
ENV PYTHON_GET_PIP_SHA256 e03eb8a33d3b441ff484c56a436ff10680479d4bd14e59268e67977ed40904de | ||
|
||
RUN set -ex; \ | ||
\ | ||
wget -O get-pip.py "$PYTHON_GET_PIP_URL"; \ | ||
echo "$PYTHON_GET_PIP_SHA256 *get-pip.py" | sha256sum -c -; \ | ||
\ | ||
python get-pip.py \ | ||
--disable-pip-version-check \ | ||
--no-cache-dir \ | ||
"pip==$PYTHON_PIP_VERSION" \ | ||
; \ | ||
pip --version; \ | ||
\ | ||
find /usr/local -depth \ | ||
\( \ | ||
\( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ | ||
-o \ | ||
\( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ | ||
\) -exec rm -rf '{}' +; \ | ||
rm -f get-pip.py | ||
|
||
# Serverless | ||
|
||
LABEL source = [email protected]:kyma-project/kyma.git | ||
|
||
COPY kubeless/requirements.txt /kubeless/requirements.txt | ||
RUN pip install -r /kubeless/requirements.txt | ||
|
||
COPY kubeless/ / | ||
|
||
WORKDIR / | ||
|
||
USER 1000 | ||
|
||
CMD ["python", "/kubeless.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
venv | ||
handler.py |
Oops, something went wrong.