Skip to content

Commit

Permalink
Merge branch 'develop' into remove_py37
Browse files Browse the repository at this point in the history
  • Loading branch information
mndeveci authored Feb 21, 2024
2 parents c785ecb + 89d902c commit 5a06cc6
Show file tree
Hide file tree
Showing 21 changed files with 412 additions and 574 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
use-installer: true
- run: make init
- run: SAM_CLI_VERSION=${{needs.get-sam-cli-version.outputs.sam_cli_version}} RUNTIME=${{matrix.runtime}} make build-single-arch
- run: SAM_CLI_VERSION=${{needs.get-sam-cli-version.outputs.sam_cli_version}} RUNTIME=${{matrix.runtime}} make test
- run: SAM_CLI_VERSION=${{needs.get-sam-cli-version.outputs.sam_cli_version}} RUNTIME=${{matrix.runtime}} ARCH=x86_64 make test

build-multi-arch:
strategy:
Expand All @@ -67,6 +67,7 @@ jobs:
runtime:
- "dotnet6"
- "dotnet7"
- "dotnet8"
- "java8_al2"
- "java11"
- "java17"
Expand All @@ -81,7 +82,6 @@ jobs:
- "python310"
- "python311"
- "python312"
- "ruby27"
- "ruby32"
runs-on: ubuntu-latest
needs: [get-sam-cli-version]
Expand All @@ -95,4 +95,5 @@ jobs:
use-installer: true
- run: make init
- run: SAM_CLI_VERSION=${{needs.get-sam-cli-version.outputs.sam_cli_version}} RUNTIME=${{matrix.runtime}} make build-multi-arch
- run: SAM_CLI_VERSION=${{needs.get-sam-cli-version.outputs.sam_cli_version}} RUNTIME=${{matrix.runtime}} make test
- run: SAM_CLI_VERSION=${{needs.get-sam-cli-version.outputs.sam_cli_version}} RUNTIME=${{matrix.runtime}} ARCH=x86_64 make test
- run: SAM_CLI_VERSION=${{needs.get-sam-cli-version.outputs.sam_cli_version}} RUNTIME=${{matrix.runtime}} ARCH=arm64 make test
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ IS_provided := provided
IS_go1x := go1.x
IS_dotnet6 := dotnet6
IS_dotnet7 := dotnet7
IS_dotnet8 := dotnet8
IS_java8_al2 := java8.al2
IS_java11 := java11
IS_java17 := java17
Expand All @@ -23,7 +24,6 @@ IS_python39 := python3.9
IS_python310 := python3.10
IS_python311 := python3.11
IS_python312 := python3.12
IS_ruby27 := ruby2.7
IS_ruby32 := ruby3.2

init:
Expand Down Expand Up @@ -55,8 +55,18 @@ build-multi-arch: pre-build
docker run --privileged --rm tonistiigi/binfmt --install arm64
docker build -f build-image-src/Dockerfile-$(RUNTIME) -t amazon/aws-sam-cli-build-image-$(IS_$(RUNTIME)):arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$(SAM_CLI_VERSION) --build-arg AWS_CLI_ARCH=aarch64 --build-arg GO_ARCH=arm64 --build-arg IMAGE_ARCH=arm64 ./build-image-src

build-x86_64-arch: pre-build
ifeq ($(strip $(RUNTIME)), $(IS_java8)) || ($(strip $(RUNTIME)), $(IS_provided)) || ($(strip $(RUNTIME)), $(IS_go1x))
docker build -f build-image-src/Dockerfile-$(RUNTIME) -t amazon/aws-sam-cli-build-image-$(IS_$(RUNTIME)):x86_64 --build-arg SAM_CLI_VERSION=$(SAM_CLI_VERSION) ./build-image-src
else
docker build -f build-image-src/Dockerfile-$(RUNTIME) -t amazon/aws-sam-cli-build-image-$(IS_$(RUNTIME)):x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$(SAM_CLI_VERSION) --build-arg AWS_CLI_ARCH=x86_64 --build-arg GO_ARCH=amd64 --build-arg IMAGE_ARCH=x86_64 ./build-image-src
endif

build-arm64-arch: pre-build
docker build -f build-image-src/Dockerfile-$(RUNTIME) -t amazon/aws-sam-cli-build-image-$(IS_$(RUNTIME)):arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$(SAM_CLI_VERSION) --build-arg AWS_CLI_ARCH=aarch64 --build-arg GO_ARCH=arm64 --build-arg IMAGE_ARCH=arm64 ./build-image-src

test: pre-build
pytest tests -vv -m $(RUNTIME)
pytest tests -vv -m "$(RUNTIME)$(ARCH)"

lint:
# Linter performs static analysis to catch latent bugs
Expand Down
3 changes: 3 additions & 0 deletions build-image-src/ATTRIBUTION.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,9 @@ SOFTWARE.

------

** dotnet; version 8.0 -- https://github.com/dotnet/core
Copyright (c) .NET Foundation and Contributors

** dotnet; version 7.0 -- https://github.com/dotnet/core
Copyright (c) .NET Foundation and Contributors

Expand Down
108 changes: 108 additions & 0 deletions build-image-src/Dockerfile-dotnet8
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
ARG IMAGE_ARCH
FROM public.ecr.aws/lambda/dotnet:8-$IMAGE_ARCH

RUN dnf remove -y microdnf-dnf && \
microdnf install -y dnf

RUN dnf groupinstall -y development && \
dnf install -y --allowerasing \
tar \
gzip \
unzip \
python3 \
jq \
grep \
curl \
make \
rsync \
binutils \
gcc-c++ \
procps \
libmpc-devel \
gmp-devel \
zlib-devel \
python3-devel \
clang krb5-devel \
openssl-devel \
llvm \
libicu \
tzdata \
&& dnf clean all

# Install AWS CLI
ARG AWS_CLI_ARCH
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-$AWS_CLI_ARCH.zip" -o "awscliv2.zip" && unzip awscliv2.zip && ./aws/install && rm awscliv2.zip && rm -rf ./aws

# Install SAM CLI from native installer
ARG SAM_CLI_VERSION
# need to redefine since ARG is not available after FROM tag: https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG IMAGE_ARCH
RUN curl -L "https://github.com/aws/aws-sam-cli/releases/download/v$SAM_CLI_VERSION/aws-sam-cli-linux-$IMAGE_ARCH.zip" -o "samcli.zip" && \
unzip samcli.zip -d sam-installation && ./sam-installation/install && \
rm samcli.zip && rm -rf sam-installation && sam --version

# Prepare virtualenv for lambda builders
RUN python3 -m venv --without-pip /usr/local/opt/lambda-builders
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
RUN /usr/local/opt/lambda-builders/bin/python3 get-pip.py
# Install lambda builders in a dedicated Python virtualenv
RUN AWS_LB_VERSION=$(curl -sSL https://raw.githubusercontent.com/aws/aws-sam-cli/v$SAM_CLI_VERSION/requirements/base.txt | grep aws_lambda_builders | cut -d= -f3) && \
/usr/local/opt/lambda-builders/bin/pip3 --no-cache-dir install "aws-lambda-builders==$AWS_LB_VERSION"

ENV PATH=$PATH:/usr/local/opt/lambda-builders/bin

ENV LANG=en_US.UTF-8

# Wheel is required by SAM CLI to build libraries like cryptography. It needs to be installed in the system
# Python for it to be picked up during `sam build`
RUN pip3 install wheel

# Set up .NET root

ENV DOTNET_ROOT=/var/lang/bin

# Install .NET build tools

ENV AWS_EXECUTION_ENV=AWS_Lambda_dotnet8 \
DOTNET_CLI_TELEMETRY_OPTOUT=1 \
DOTNET_NOLOGO=1 \
NUGET_XMLDOC_MODE=skip

# Warm up the nuget cache once now for faster startup on each use.
RUN curl -L https://dot.net/v1/dotnet-install.sh | bash -s -- -c 8.0 -i "${DOTNET_ROOT}" && \
mkdir /tmp/warmup && \
cd /tmp/warmup && \
dotnet new > /dev/null && \
cd / && \
rm -rf /tmp/warmup /tmp/NuGetScratch /tmp/.dotnet

# Now we do something tricky. Installing Amazon.Lambda.Tools here as a --global tool will
# make it impossible to upgrade – either directly or by running `sam build`. Not so great.
# But .NET tools *can* obey the path. By installing the Lambda tools to the .NET root and
# putting the Global Tools install directory ahead of it in the path, we enable this:
#
# - `dotnet lambda` works out of the box because it's found on the path at the .NET root.
# - Installing or upgrading Amazon.Lambda.Tools as a global tool succeeds because it will
# write to the same layer. No cross-mount writes.
# - Running `dotnet lambda` after installing or upgrading (either directly or via running
# `sam build`) will pick up the newly installed, globally installed version of the tool.
ENV PATH=~/.dotnet/tools:$PATH

# We're using the -v diag argument to output extra logs because in the past we've seen intermittent failures
# and want to be able to better understand them if they happen again
RUN dotnet tool install --tool-path "${DOTNET_ROOT}" Amazon.Lambda.Tools -v diag

COPY ATTRIBUTION.txt /

# Runtime environment variables need to be defined after installation of all dotnet tools.
# These variables define the tmp home directory for .NET CLI and the migration directory for NuGet in container.
# .NET `sam build` requires tmp diretories being set for current user because it runs docker
# as current/non-root user (unless current user is root) on posix systems.
# That user will make/own these directory in container during the runtime.
# They work the same as using docker arguments `-e DOTNET_CLI_HOME=/tmp/dotnet XDG_DATA_HOME=/tmp/xdg`
ENV DOTNET_CLI_HOME=/tmp/dotnet
ENV XDG_DATA_HOME=/tmp/xdg

# Compatible with initial base image
ENTRYPOINT []
CMD ["/bin/bash"]
68 changes: 0 additions & 68 deletions build-image-src/Dockerfile-ruby27

This file was deleted.

7 changes: 4 additions & 3 deletions build-image-src/build_all_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ docker build -f Dockerfile-go1x -t amazon/aws-sam-cli-build-image-go1.x:x86_64 -
wait

# Multi arch images
# First build all x86docker build -f Dockerfile-dotnet6 -t amazon/aws-sam-cli-build-image-dotnet6:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . &
# First build all x86
docker build -f Dockerfile-dotnet6 -t amazon/aws-sam-cli-build-image-dotnet6:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . &
docker build -f Dockerfile-dotnet7 -t amazon/aws-sam-cli-build-image-dotnet7:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . &
docker build -f Dockerfile-dotnet8 -t amazon/aws-sam-cli-build-image-dotnet8:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . &
docker build -f Dockerfile-java8_al2 -t amazon/aws-sam-cli-build-image-java8.al2:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . &
docker build -f Dockerfile-java11 -t amazon/aws-sam-cli-build-image-java11:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . &
docker build -f Dockerfile-java17 -t amazon/aws-sam-cli-build-image-java17:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . &
Expand All @@ -39,14 +41,14 @@ docker build -f Dockerfile-python39 -t amazon/aws-sam-cli-build-image-python3.9:
docker build -f Dockerfile-python310 -t amazon/aws-sam-cli-build-image-python3.10:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . &
docker build -f Dockerfile-python311 -t amazon/aws-sam-cli-build-image-python3.11:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . &
docker build -f Dockerfile-python312 -t amazon/aws-sam-cli-build-image-python3.12:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . &
docker build -f Dockerfile-ruby27 -t amazon/aws-sam-cli-build-image-ruby2.7:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . &
docker build -f Dockerfile-ruby32 -t amazon/aws-sam-cli-build-image-ruby3.2:x86_64 --platform linux/amd64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=x86_64 --build-arg IMAGE_ARCH=x86_64 . &
wait

# Build arm64 images
docker run --privileged --rm tonistiigi/binfmt --install arm64
docker build -f Dockerfile-dotnet6 -t amazon/aws-sam-cli-build-image-dotnet6:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . &
docker build -f Dockerfile-dotnet7 -t amazon/aws-sam-cli-build-image-dotnet7:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . &
docker build -f Dockerfile-dotnet8 -t amazon/aws-sam-cli-build-image-dotnet8:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . &
docker build -f Dockerfile-java8_al2 -t amazon/aws-sam-cli-build-image-java8.al2:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . &
docker build -f Dockerfile-java11 -t amazon/aws-sam-cli-build-image-java11:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . &
docker build -f Dockerfile-java17 -t amazon/aws-sam-cli-build-image-java17:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . &
Expand All @@ -61,6 +63,5 @@ docker build -f Dockerfile-python39 -t amazon/aws-sam-cli-build-image-python3.9:
docker build -f Dockerfile-python310 -t amazon/aws-sam-cli-build-image-python3.10:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . &
docker build -f Dockerfile-python311 -t amazon/aws-sam-cli-build-image-python3.11:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . &
docker build -f Dockerfile-python312 -t amazon/aws-sam-cli-build-image-python3.12:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . &
docker build -f Dockerfile-ruby27 -t amazon/aws-sam-cli-build-image-ruby2.7:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . &
docker build -f Dockerfile-ruby32 -t amazon/aws-sam-cli-build-image-ruby3.2:arm64 --platform linux/arm64 --build-arg SAM_CLI_VERSION=$SAM_CLI_VERSION --build-arg AWS_CLI_ARCH=aarch64 --build-arg IMAGE_ARCH=arm64 . &
wait
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ markers =
go1x
dotnet6
dotnet7
dotnet8
java8_al2
java11
java17
Expand All @@ -19,5 +20,4 @@ markers =
python310
python311
python312
ruby27
ruby32
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pylint~=2.6.0
urllib3<2

# Test requirements
pytest==6.1.1
pytest==7.3.1

# formatter
black==20.8b1
84 changes: 84 additions & 0 deletions tests/apps/dotnet8/sam-test-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

# Created by https://www.toptal.com/developers/gitignore/api/osx,linux,windows,dotnetcore
# Edit at https://www.toptal.com/developers/gitignore?templates=osx,linux,windows,dotnetcore

### DotnetCore ###
# .NET Core build folders
bin/
obj/

# Common node modules locations
/node_modules
/wwwroot/node_modules

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### OSX ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/osx,linux,windows,dotnetcore
Loading

0 comments on commit 5a06cc6

Please sign in to comment.