Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tutorials/local_build.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ cd openwhisk-runtime-python
2. Build docker

Build using Python 3.7 (recommended). This tutorial assumes you're building with python 3.7.

Run local_build.sh with the correct parameters to build docker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hoping that you could help out and make this markdown more readable?

  • Reduce the use of numbered lists (and do not start at zero 0.)
  • Create more subsection headings to break up the numbered lists
    • e.g., "Build the iamge", "Run the image", "Test the image" (with Curl) etc.
  • Create subsections that show case "Testing with Helloworld" and explain init/run entry points into image.

May wish to align with work in the nodejs runtime's README and docker build/run/test README:
apache/openwhisk-runtime-nodejs#227

Please know further updates to the files there are expected.

```
docker build -t action-python-v3.7:1.0-SNAPSHOT $(pwd)/core/python3Action
cd /tutorials
chmod 755 local_build.sh
cd ..
./tutorials/local_build.sh -r python3Action -t action-python-v3.7:1.0-SNAPSHOT
```

2.1. Check docker `IMAGE ID` (3rd column) for repository `action-python-v3.7`
Expand Down
81 changes: 81 additions & 0 deletions tutorials/local_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

helperInstructions()
{
echo ""
echo "Usage: $0 -r runtimeParameter -t dockerImageTag"
echo -e "\t-r Specific runtime image folder name to be built, it can be one of python3Action, python36AiAction, python39Action or python310Action"
echo -e "\t-t The name for docker image and tag used for building the docker image. Example: action-python-v3.7:1.0-SNAPSHOT"
exit 1 #Exit script
}

while getopts "r:t:" opt
do
case "$opt" in
r) runtimeParameter="$OPTARG" ;;
t) dockerImageTag="$OPTARG" ;;
[?]) helperInstructions ;; # Print helperInstructions in case parameter is not found
esac
done

# Print helperInstructions in case parameters are empty
if [ -z "$runtimeParameter" ] || [ -z "$dockerImageTag" ] || ( [[ "$runtimeParameter" != "python3Action" ]] && [[ "$runtimeParameter" != "python36AiAction" ]] && [[ "$runtimeParameter" != "python39Action" ]] && [[ "$runtimeParameter" != "python310Action" ]] )
then
echo "Runtime parameter is empty or not supported";
helperInstructions
fi

# For every runtime 1. copy the required dependent folders 2. build the docker image 3. delete the copied folder
if [[ "$runtimeParameter" == "python3Action" ]]
then
echo "Building docker for python3Action."
cp $(pwd)/core/requirements_common.txt $(pwd)/core/python3Action/requirements_common.txt
docker build -t "$dockerImageTag" $(pwd)/core/python3Action
rm $(pwd)/core/python3Action/requirements_common.txt
elif [[ "$runtimeParameter" == "python36AiAction" ]]
then
echo "Building docker for python36AiAction."
cp $(pwd)/core/requirements_common.txt $(pwd)/core/python36AiAction/requirements_common.txt
cp -r $(pwd)/core/python3Action/bin $(pwd)/core/python36AiAction/bin
cp -r $(pwd)/core/python3Action/lib $(pwd)/core/python36AiAction/lib
docker build -t "$dockerImageTag" $(pwd)/core/python36AiAction
rm $(pwd)/core/python36AiAction/requirements_common.txt
rm -r $(pwd)/core/python36AiAction/bin
rm -r $(pwd)/core/python36AiAction/lib
elif [[ "$runtimeParameter" == "python39Action" ]]
then
echo "Building docker for python39Action."
cp $(pwd)/core/requirements_common.txt $(pwd)/core/python39Action/requirements_common.txt
cp -r $(pwd)/core/python3Action/bin $(pwd)/core/python39Action/bin
cp -r $(pwd)/core/python3Action/lib $(pwd)/core/python39Action/lib
docker build -t "$dockerImageTag" $(pwd)/core/python39Action
rm $(pwd)/core/python39Action/requirements_common.txt
rm -r $(pwd)/core/python39Action/bin
rm -r $(pwd)/core/python39Action/lib
elif [[ "$runtimeParameter" == "python310Action" ]]
then
echo "Building docker for python310Action."
cp $(pwd)/core/requirements_common.txt $(pwd)/core/python310Action/requirements_common.txt
cp -r $(pwd)/core/python3Action/bin $(pwd)/core/python310Action/bin
cp -r $(pwd)/core/python3Action/lib $(pwd)/core/python310Action/lib
docker build -t "$dockerImageTag" $(pwd)/core/python310Action
rm $(pwd)/core/python310Action/requirements_common.txt
rm -r $(pwd)/core/python310Action/bin
rm -r $(pwd)/core/python310Action/lib
fi