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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,6 @@ jobs:
- diagnostics
- lint
- test
strategy:
matrix:
# Python runtime versions supported by AWS
python-version:
- "3.7"
- "3.8"
- "3.9"
steps:
- name: Apply standard cisagov job preamble
uses: cisagov/action-job-preamble@v1
Expand Down Expand Up @@ -305,16 +298,13 @@ jobs:
echo "GH_SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Build the base Lambda Docker image
run: |
docker compose build \
--build-arg PY_VERSION=${{ matrix.python-version }} \
build_deployment_package
docker compose build build_deployment_package
- name: Generate the Lambda deployment package
run: docker compose up build_deployment_package
- name: Upload the generated Lambda deployment package as an artifact
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-py${{
matrix.python-version }}-${{ env.GH_SHORT_SHA }}
name: ${{ github.event.repository.name }}-${{ env.GH_SHORT_SHA }}
path: ${{ env.DEFAULT_ARTIFACT_NAME }}
- name: Setup tmate debug session
uses: mxschmitt/action-tmate@v3
Expand Down
19 changes: 5 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
ARG PY_VERSION=3.9

FROM amazon/aws-lambda-python:$PY_VERSION AS install-stage

# Declare it a second time so it's brought into this scope.
ARG PY_VERSION=3.9
# The runtime tag must match the version of Python specified in the Pipfile.
FROM amazon/aws-lambda-python:3.9 AS install-stage

# Install the Python packages necessary to install the Lambda dependencies.
RUN python3 -m pip install --no-cache-dir \
Expand All @@ -17,15 +13,16 @@ RUN python3 -m pip install --no-cache-dir \
WORKDIR /tmp

# Copy in the dependency files.
COPY src/py$PY_VERSION/ .
COPY build/Pipfile build/Pipfile.lock ./

# Install the Lambda dependencies.
#
# The --extra-pip-args option is used to pass necessary arguments to the
# underlying pip calls.
RUN pipenv sync --system --extra-pip-args="--no-cache-dir --target ${LAMBDA_TASK_ROOT}"

FROM amazon/aws-lambda-python:$PY_VERSION AS build-stage
# The runtime tag must match the version of Python specified in the Pipfile.
FROM amazon/aws-lambda-python:3.9 AS build-stage

###
# For a list of pre-defined annotation keys and value types see:
Expand All @@ -40,12 +37,6 @@ FROM amazon/aws-lambda-python:$PY_VERSION AS build-stage
LABEL org.opencontainers.image.authors="github@cisa.dhs.gov"
LABEL org.opencontainers.image.vendor="Cybersecurity and Infrastructure Security Agency"

# Declare it a third time so it's brought into this scope.
ARG PY_VERSION=3.9

# This must be present in the image to generate a deployment artifact.
ENV BUILD_PY_VERSION=$PY_VERSION

COPY --from=install-stage ${LAMBDA_TASK_ROOT} ${LAMBDA_TASK_ROOT}

WORKDIR ${LAMBDA_TASK_ROOT}
Expand Down
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,15 @@ docker compose down

## How to update Python dependencies ##

The Python dependencies are maintained using a
[Pipenv](https://github.com/pypa/pipenv) configuration for each
supported Python version. Changes to requirements should be made to
the respective `src/py<Python version>/Pipfile`. More information
about the `Pipfile` format can be found in the [`pipenv`
documentation](https://pipenv.pypa.io/en/latest/pipfile.html#example-pipfile).
The accompanying `Pipfile.lock` files contain the specific dependency
versions that will be installed. These files can be updated like so
(using the Python 3.9 configuration as an example):
The Lambda's Python dependencies are maintained using a [Pipenv](https://github.com/pypa/pipenv)
configuration. Changes to requirements should be made to the `Pipfile` located at
`build/Pipfile`. More information about the `Pipfile` format can be found in the
[`pipenv` documentation](https://pipenv.pypa.io/en/latest/pipfile.html#example-pipfile).
The accompanying `Pipfile.lock` file contains the specific dependency versions
that will be installed. This file is updated automatically like so:

```console
cd src/py3.9
cd build
pipenv lock
```

Expand Down
1 change: 1 addition & 0 deletions src/py3.9/Pipfile → build/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ verify_ssl = true
name = "pypi"

[requires]
# This must match the version of the Python runtime specified in the Dockerfile.
python_version = "3.9"

[packages]
Expand Down
22 changes: 7 additions & 15 deletions src/py3.9/Pipfile.lock → build/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
# from the invoking environment but falls back to a default value.
- BUILD_FILE_NAME=${BUILD_FILE_NAME:-lambda_build.zip}
volumes:
- ./src/build_artifact.sh:/opt/build_artifact.sh
- ./build/build_artifact.sh:/opt/build_artifact.sh
- .:/var/task/output
run_lambda_locally:
build: .
Expand Down
11 changes: 0 additions & 11 deletions src/py3.7/Pipfile

This file was deleted.

64 changes: 0 additions & 64 deletions src/py3.7/Pipfile.lock

This file was deleted.

11 changes: 0 additions & 11 deletions src/py3.8/Pipfile

This file was deleted.

61 changes: 0 additions & 61 deletions src/py3.8/Pipfile.lock

This file was deleted.

2 changes: 1 addition & 1 deletion src/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.2
0.0.3