Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions samples/imagedims-python/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
FROM fnproject/python:3.6-dev as build-stage
FROM fnproject/python:3.6-dev
WORKDIR /function
ADD requirements.txt /function/
RUN pip3 install --target /python/ --no-cache --no-cache-dir -r requirements.txt &&\
rm -fr ~/.cache/pip /tmp* requirements.txt func.yaml Dockerfile .venv
RUN pip3 install --no-cache --no-cache-dir --upgrade pip && \
pip3 install --target /python/ --no-cache --no-cache-dir -r requirements.txt && \
rm -fr ~/.cache/pip /tmp* requirements.txt func.yaml Dockerfile .venv && \
chmod -R o+r /function
ADD . /function/
RUN rm -fr /function/.pip_cache

FROM fnproject/python:3.6
RUN apt-get update && apt-get install -y imagemagick
RUN microdnf install oracle-epel-release-el8 &&\
microdnf install ImageMagick &&\
microdnf remove oracle-epel-release-el8 &&\
microdnf clean all
WORKDIR /function
COPY --from=build-stage /function /function
COPY --from=build-stage /python /python
ENV PYTHONPATH=/python
ENV PYTHONPATH=/python:/function
ENTRYPOINT ["/python/bin/fdk", "/function/func.py", "handler"]
33 changes: 21 additions & 12 deletions samples/imagedims-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,38 +58,47 @@ The Dockerfile that "fn build" would automatically generate to build a
Python 3.6 function container image looks like this:

```Dockerfile
FROM fnproject/python:3.6-dev as build-stage
FROM fnproject/python:3.6-dev
WORKDIR /function
ADD requirements.txt /function/
RUN pip3 install --target /python/ --no-cache --no-cache-dir -r requirements.txt &&\
rm -fr ~/.cache/pip /tmp* requirements.txt func.yaml Dockerfile .venv
RUN pip3 install --no-cache --no-cache-dir --upgrade pip && \
pip3 install --target /python/ --no-cache --no-cache-dir -r requirements.txt && \
rm -fr ~/.cache/pip /tmp* requirements.txt func.yaml Dockerfile .venv && \
chmod -R o+r /function
ADD . /function/
RUN rm -fr /function/.pip_cache

FROM fnproject/python:3.6
RUN microdnf install oracle-epel-release-el8 &&\
microdnf install ImageMagick &&\
microdnf remove oracle-epel-release-el8 &&\
microdnf clean all
WORKDIR /function
COPY --from=build-stage /function /function
COPY --from=build-stage /python /python
ENV PYTHONPATH=/python
ENV PYTHONPATH=/python:/function
ENTRYPOINT ["/python/bin/fdk", "/function/func.py", "handler"]
```

It's a two stage build with the *fnproject/python:3.6-dev* image containing *pip* and
other build tools, and the *fnproject/python:3.6* image containing just the Python
runtime. This approach is designed to ensure that deployable function container
It's a two stage build with the first stage containing python with build tools
and the second stage with only the python runtime and minimum required dependencies.
This approach is designed to ensure that deployable function container
images are as small as possible, which is beneficial for a number of reasons
including the time it takes to transfer the image from a Docker respository to
the compute node where the function is to be run.

The *fnproject/python* container image is built on Debian so we'll need to install
The *fnproject/python:3.6* container image needs ImageMagick from the EPEL repo, so we'll need to install
the
[ImageMagick Debian package](https://packages.debian.org/buster/imagemagick)
using the *apt-get* package management utility.
[ImageMagick package](https://yum.oracle.com/repo/OracleLinux/OL8/developer/EPEL/x86_64/index.html)
using the *microdnf* package management utility.
```Dockerfile
RUN apt-get update && apt-get install -y imagemagick
RUN microdnf install oracle-epel-release-el8 &&\
microdnf install ImageMagick &&\
microdnf remove oracle-epel-release-el8 &&\
microdnf clean all
```
We want to install ImageMagick into the runtime image, not the build image,
so we need to add the *RUN* command after the *FROM fnproject/python:3.6* line.
so we need to add line in the second stage.


## Deploy the function
Expand Down
4 changes: 4 additions & 0 deletions samples/oci-objectstorage-custom-cert-put-object-go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This function uses Resource Principals to securely authorize a function to make
API calls to OCI services using the [OCI Go SDK](hhttps://docs.oracle.com/en-us/iaas/tools/go/46.1.0/).
It creates an object in a bucket in Object Storage and returns a message with a status.

Some OCI realms uses self signed certificates. Certificate being used can be specified in client we create
in function to connect to OCI services. In this function, certificate to be trusted is specified in the
client we are creating to interact with Object Storage.

The function calls the following OCI Go SDK classes:
* [ResourcePrincipalConfigurationProvider](https://docs.oracle.com/en-us/iaas/tools/go/47.1.0/common/auth/index.html#ResourcePrincipalConfigurationProvider) to authenticate
* [NewObjectStorageClientWithConfigurationProvider](https://docs.oracle.com/en-us/iaas/tools/go/47.1.0/objectstorage/index.html#NewObjectStorageClientWithConfigurationProvider) to interact with Object Storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This function uses Resource Principals to securely authorize a function to make
API calls to OCI services using the [OCI Java SDK](https://docs.cloud.oracle.com/iaas/tools/java/latest/).
It creates an object in a bucket in Object Storage and returns a message with a status.

Some OCI realms uses self signed certificates. Certificate being used can be specified in client we create
in function to connect to OCI services. In this function, certificate to be trusted is specified in the
client we are creating to interact with Object Storage.

The function calls the following OCI Java SDK classes:
* [ResourcePrincipalAuthenticationDetailsProvider](https://docs.cloud.oracle.com/en-us/iaas/tools/java/latest/com/oracle/bmc/auth/ResourcePrincipalAuthenticationDetailsProvider.html) to authenticate
* [ObjectStorageClient](https://docs.cloud.oracle.com/iaas/tools/java/latest/com/oracle/bmc/objectstorage/ObjectStorageClient.html) to interact with Object Storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This function uses Resource Principals to securely authorize a function to make
API calls to OCI services using the [OCI Python SDK](https://oracle-cloud-infrastructure-python-sdk.readthedocs.io/en/latest/index.html).
It creates an object in a bucket in Object Storage and returns a message with a status.

Some OCI realms uses self signed certificates. Certificate being used can be specified in client we create
in function to connect to OCI services. In this function, certificate to be trusted is specified in the
client we are creating to interact with Object Storage.

The function calls the following OCI Python SDK classes:
* [Resource Principals Signer](https://oracle-cloud-infrastructure-python-sdk.readthedocs.io/en/latest/api/signing.html#resource-principals-signer) to authenticate
* [Object Storage Client](https://oracle-cloud-infrastructure-python-sdk.readthedocs.io/en/latest/api/object_storage/client/oci.object_storage.ObjectStorageClient.html) to interact with Object Storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This function uses Resource Principals to securely authorize a function to make
API calls to OCI services using the [OCI Ruby SDK](https://docs.cloud.oracle.com/iaas/tools/ruby/latest/).
It creates an object in a bucket in Object Storage and returns a message with a status.

Some OCI realms uses self signed certificates. Certificate being used can be specified in client we create
in function to connect to OCI services. In this function, certificate to be trusted is specified in the
client we are creating to interact with Object Storage.

The function calls the following OCI Ruby SDK classes:
* [resource_principals_signer](https://docs.oracle.com/en-us/iaas/tools/ruby/2.14.0/OCI/Auth/Signers/ResourcePrincipalsFederationSigner.html) to authenticate
* [ObjectStorageClient](https://docs.oracle.com/en-us/iaas/tools/ruby/2.15.0/OCI/ObjectStorage/ObjectStorageClient.html) to interact with Object Storage
Expand Down