Skip to content

Commit

Permalink
Improve documentation around Dockerfiles (#70)
Browse files Browse the repository at this point in the history
* Add a link to an example Dockerfile in the top README.md

* Update the inline Dockerfile to match file

* Remove explicit gunicorn installation

* make readme links absolute, useful

Useful for when this readme appears on both github and pypi
  • Loading branch information
glasnt authored and di committed Aug 11, 2020
1 parent f2471b4 commit b029055
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ After you've written your function, you can simply deploy it from your local mac

## Cloud Run/Cloud Run on GKE

Once you've written your function and added the Functions Framework to your `requirements.txt` file, all that's left is to create a container image. [Check out the Cloud Run quickstart](https://cloud.google.com/run/docs/quickstarts/build-and-deploy) for Python to create a container image and deploy it to Cloud Run. You'll write a `Dockerfile` when you build your container. This `Dockerfile` allows you to specify exactly what goes into your container (including custom binaries, a specific operating system, and more).
Once you've written your function and added the Functions Framework to your `requirements.txt` file, all that's left is to create a container image. [Check out the Cloud Run quickstart](https://cloud.google.com/run/docs/quickstarts/build-and-deploy) for Python to create a container image and deploy it to Cloud Run. You'll write a `Dockerfile` when you build your container. This `Dockerfile` allows you to specify exactly what goes into your container (including custom binaries, a specific operating system, and more). [Here is an example `Dockerfile` that calls Functions Framework.](https://github.com/GoogleCloudPlatform/functions-framework-python/blob/master/examples/cloud_run_http)

If you want even more control over the environment, you can [deploy your container image to Cloud Run on GKE](https://cloud.google.com/run/docs/quickstarts/prebuilt-deploy-gke). With Cloud Run on GKE, you can run your function on a GKE cluster, which gives you additional control over the environment (including use of GPU-based instances, longer timeouts and more).

Expand Down Expand Up @@ -178,8 +178,8 @@ See the [running example](examples/cloud_run_cloudevents).

# Advanced Examples

More advanced guides can be found in the [`examples/`](./examples/) directory. You can also find examples
on using the CloudEvent Python SDK [here](https://github.com/cloudevents/sdk-python).
More advanced guides can be found in the [`examples/`](https://github.com/GoogleCloudPlatform/functions-framework-python/blob/master/examples/) directory.
You can also find examples on using the CloudEvent Python SDK [here](https://github.com/cloudevents/sdk-python).

# Contributing

Expand Down
2 changes: 1 addition & 1 deletion examples/cloud_run_http/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WORKDIR $APP_HOME
COPY . .

# Install production dependencies.
RUN pip install gunicorn functions-framework
RUN pip install functions-framework
RUN pip install -r requirements.txt

# Run the web service on container startup.
Expand Down
9 changes: 3 additions & 6 deletions examples/cloud_run_http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ WORKDIR $APP_HOME
COPY . .

# Install production dependencies.
RUN pip install gunicorn functions-framework
RUN pip install functions-framework
RUN pip install -r requirements.txt

# Run the web service on container startup. Here we use the gunicorn
# webserver, with one worker process and 8 threads.
# For environments with multiple CPU cores, increase the number of workers
# to be equal to the cores available.
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 -e FUNCTION_TARGET=hello functions_framework:app
# Run the web service on container startup.
CMD exec functions-framework --target=hello
```

Start the container locally by running `docker build` and `docker run`:
Expand Down

0 comments on commit b029055

Please sign in to comment.