Skip to content

Commit 3170256

Browse files
committed
Documentation updates
1 parent bdc8a73 commit 3170256

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

README.md

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,35 @@ In order to use this, you will have your project derive its own Dockerfile based
2222

2323
## Usage
2424

25-
An example of a usable project can be found in the [example/](./example/) directory. This lambda function in [service.py](./example/service.py) takes a JSON input file like the one provided in [event.json](./example/event.json) and returns an ASCII-art version of the text described in it. The provided [Dockerfile](./example/Dockerfile) derives from this image and loads the current workspace into the image at the path _/lambda_, then installs dependencies from the [requirements.txt](./example/requirements.txt) file.
25+
An example of a usable project can be found in the [example/](./example/) directory. The lambda function in [service.py](./example/service.py) takes a JSON input file like the one provided in [event.json](./example/event.json) and returns an ASCII-art version of the text described in it. The [Dockerfile](./example/Dockerfile) derives from python-lambda as a base image, and loading the example directory contents into the image at the path _/lambda_, then installs dependencies from the [requirements.txt](./example/requirements.txt) file.
2626

27-
To build a docker image called _example-lambda-image_ with the example lambda function in it, run:
27+
### Building a Derived Docker Image
28+
29+
To build a docker image from the provided [exmaple/](./exmaple) called _example-lambda-image_ with the ASCII-art lambda function in it, run:
2830

2931
```
3032
$ cd example/
3133
$ docker build --tag example-lambda-image .
3234
```
3335

36+
Any time you make changes to the example project, you'll need to re-run the `docker build` command above, or you can investigate using docker volumes to sync local filesystem changes into the container.
37+
38+
#### Switching Python Versions
39+
40+
The example [Dockerfile](./example/Dockerfile) uses a _:latest_ docker tag in the FROM line, which is currently the same as _:3.6_, but if you wish to use a different Python version you can change this. Supported Python versions are 2.7, 3.3, 3.4, 3.5, 3.6. To use Python version 2.7 change the first line of the example [Dockerfile](./example/Dockerfile) to:
41+
42+
```
43+
FROM kilna/python-lambda:2.7
44+
```
45+
46+
You will also need to change the following line in [config.yaml](./example/config.yaml)
47+
48+
```
49+
runtime: python2.7
50+
```
51+
52+
### Executing the Lambda Function
53+
3454
If you want to execute the lambda function against the [event.json](./example/event.json) input file:
3555

3656
```
@@ -42,15 +62,17 @@ $ docker run example-lambda-image lambda invoke
4262
|/
4363
```
4464

45-
If you would like to see if your lambda function build (which will package the lambda and all dependencies within the container into a zip file), run:
65+
### Building and Testing the Lambda Function
66+
67+
If you would like to builf the lambda function (which will package the function and all its dependencies), run:
4668

4769
```
4870
$ docker run example-lambda-image lambda build
4971
```
5072

51-
### Build and Test
73+
The result will be a zip file created in the /lambda/dist directory inside the container.
5274

53-
If you would like to build and test the lambda function and gather up the results, you can run:
75+
If you would like to build and _test_ the lambda function and gather up the results, you can run:
5476

5577
```
5678
$ docker run example-lambda-image lambda_build_tar | tar -x -v
@@ -60,26 +82,16 @@ dist/
6082
dist/2017-09-01-003647-example-lambda.zip
6183
```
6284

63-
Behind the scenes, what this script does is:
85+
Behind the scenes, what this does is:
6486

6587
* Removes any log and dist files from prior runs
66-
* Runs 'lambda build' and stores the log in _/lambda/build.log_ in the container
67-
* If present and executable, run _/lambda/run_tests_ and stores the log in /lambda/test.log in the container
88+
* Executes 'lambda build' and stores the log in _/lambda/build.log_ in the container
89+
* If present and executable, runs _/lambda/run_tests_ and stores the log in /lambda/test.log in the container
6890
* Tars the log files, and the contents of the dist directory in /lambda on the container and pipes it to standard output
69-
* Untars the contents bundled up within the container, and extracts them into your current directory
70-
71-
### Python Version
72-
73-
The example Dockerfile uses _:latest_ in the FROM line, which is currently the same as _:python-3.6_, but if you wish to use different python versions you can change this.
91+
* Untars the contents bundled up within the container, and extracts them into your current directory
7492

75-
For instance, if you want to use Python version 2.7 change the first line of your Dockerfile from:
93+
### Deploying the Lambda Function
7694

77-
```
78-
FROM kilna/python-lambda:latest
79-
```
95+
You can deploy your lambda function to Amazon's infrastructure... firstly you'll want to add values to the
8096

81-
To:
8297

83-
```
84-
FROM kilna/python-lambda:2.7
85-
```

0 commit comments

Comments
 (0)