-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests to ensure
Dockerfile
can be a path to a docker file via s…
…ubdirectories. This means images can share code more easily.
- Loading branch information
1 parent
a142c25
commit ec8d936
Showing
12 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
17 changes: 17 additions & 0 deletions
17
tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_phi/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
ARG BASE_RUNTIME | ||
|
||
FROM public.ecr.aws/lambda/python:$BASE_RUNTIME | ||
|
||
ARG FUNCTION_DIR="/var/task" | ||
|
||
RUN mkdir -p $FUNCTION_DIR | ||
|
||
COPY feature_phi/__init__.py $FUNCTION_DIR | ||
COPY feature_phi/main.py $FUNCTION_DIR | ||
|
||
COPY shared_code/ $FUNCTION_DIR/shared_code/ | ||
|
||
COPY requirements.txt $FUNCTION_DIR | ||
|
||
RUN python -m pip install -r $FUNCTION_DIR/requirements.txt -t $FUNCTION_DIR | ||
|
Empty file.
5 changes: 5 additions & 0 deletions
5
tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_phi/main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from shared_code import numbers | ||
|
||
|
||
def handler(event, context): | ||
return {"phi": numbers.get_phi_2dp()} |
17 changes: 17 additions & 0 deletions
17
tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_pi/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
ARG BASE_RUNTIME | ||
|
||
FROM public.ecr.aws/lambda/python:$BASE_RUNTIME | ||
|
||
ARG FUNCTION_DIR="/var/task" | ||
|
||
RUN mkdir -p $FUNCTION_DIR | ||
|
||
COPY feature_pi/__init__.py $FUNCTION_DIR | ||
COPY feature_pi/main.py $FUNCTION_DIR | ||
|
||
COPY shared_code/ $FUNCTION_DIR/shared_code/ | ||
|
||
COPY requirements.txt $FUNCTION_DIR | ||
|
||
RUN python -m pip install -r $FUNCTION_DIR/requirements.txt -t $FUNCTION_DIR | ||
|
Empty file.
5 changes: 5 additions & 0 deletions
5
tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_pi/main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from shared_code import numbers | ||
|
||
|
||
def handler(event, context): | ||
return {"pi": numbers.get_pi_2dp()} |
7 changes: 7 additions & 0 deletions
7
tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# These are some hard packages to build. Using them here helps us verify that building works on various platforms | ||
|
||
# NOTE: Fixing to <1.20.3 as numpy1.20.3 started to use a new wheel naming convention (PEP 600) | ||
numpy<1.20.3 | ||
# `cryptography` has a dependency on `pycparser` which, for some reason doesn't build inside a Docker container. | ||
# Turning this off until we resolve this issue: https://github.com/awslabs/aws-lambda-builders/issues/29 | ||
# cryptography~=2.4 |
Empty file.
14 changes: 14 additions & 0 deletions
14
tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/shared_code/numbers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import numpy | ||
|
||
|
||
def _format_2dp(number): | ||
return "{0:.2f}".format(number) | ||
|
||
|
||
def get_pi_2dp(): | ||
return _format_2dp(numpy.pi) | ||
|
||
|
||
def get_phi_2dp(): | ||
# Golden ratio | ||
return _format_2dp((1 + 5 ** 0.5) / 2) |
29 changes: 29 additions & 0 deletions
29
tests/integration/testdata/buildcmd/template_images_with_shared_code.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
AWSTemplateFormatVersion : '2010-09-09' | ||
Transform: AWS::Serverless-2016-10-31 | ||
|
||
Parameteres: | ||
Runtime: | ||
Type: String | ||
DockerFile: | ||
Type: String | ||
Handler: | ||
Type: String | ||
Tag: | ||
Type: String | ||
|
||
Resources: | ||
|
||
ImageFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
PackageType: Image | ||
ImageConfig: | ||
Command: | ||
- !Ref Handler | ||
Timeout: 600 | ||
Metadata: | ||
DockerTag: !Ref Tag | ||
DockerContext: ./PythonImagesWithSharedCode | ||
Dockerfile: !Ref DockerFile | ||
DockerBuildArgs: | ||
BASE_RUNTIME: !Ref Runtime |