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 committed Jul 16, 2020
1 parent 6f0d848 commit 95d0b35
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 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 @@ -149,7 +149,7 @@ For more details on this signature type, check out the Google Cloud Functions do

# Advanced Examples

More advanced guides can be found in the [`examples/`](./examples/) directory.
More advanced guides can be found in the [`examples/`](https://github.com/GoogleCloudPlatform/functions-framework-python/blob/master/examples/) directory.

# 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 95d0b35

Please sign in to comment.