Compare commits

...

2 Commits

Author SHA1 Message Date
52eb054277
add lambda-layer implementation based on AL2/Python 3.8
All checks were successful
continuous-integration/drone/push Build is passing
2021-01-06 10:23:15 -08:00
a669d9adac
document why we use find 2021-01-06 10:22:41 -08:00
3 changed files with 35 additions and 11 deletions

1
.gitignore vendored
View File

@ -139,3 +139,4 @@ cython_debug/
.container*
.dockerfile*
include/
lambda.zip

View File

@ -39,14 +39,21 @@ COPY etags.py /src/
WORKDIR /src
RUN true \
&& pip3 install -r requirements.txt \
&& pyinstaller -F etags.py \
&& staticx \
--strip \
--no-compress \
-l $(find /lib -name libgcc_s.so.1) \
dist/etags dist/app \
# We use find here because different architectures might be wildly different.
# The specific directory is named by the gcc toolchain, which doesn't really
# line up here with uname -m. As an example, 32 bit arm libraries can be the
# same across arm versions (arm7/arm8 32 bit)
# x86_64: /lib/x86_64-linux-gnu
# arm64: /lib/aarch64-linux-gnu
# arm7: /lib/arm-linux-gnueabihf
RUN true \
&& pip3 install -r requirements.txt \
&& pyinstaller -F etags.py \
&& staticx \
--strip \
--no-compress \
-l "$(find /lib -name libgcc_s.so.1 -print -quit)" \
dist/etags dist/app \
&& chmod 755 dist/app
FROM scratch

View File

@ -91,9 +91,25 @@ container containers: $(CONTAINER_DOTFILES)
echo "container: $(REGISTRY)/$$bin:$(TAG)"; \
done
lambda-layer: # @HELP creates a lambda layer zipfile "lambda.zip" suitable for uploading
lambda-layer: # Python - mostly not compiled, and deps that are, are linux/amd64
@echo "todo"
lambda-package: # @HELP creates a lambda package zipfile "lambda.zip" suitable for uploading
lambda-package: lambda.zip # Python - mostly not compiled, and deps that are, are linux/amd64
SOURCES = $(foreach bin,$(BINS),$(bin).py)
lambda.zip: requirements.txt $(SOURCES)
@cid=$$($(DKR) create amazonlinux:2 /bin/sh -c ' \
amazon-linux-extras enable python3.8; \
yum install -y python38 zip; \
alternatives --install /usr/bin/python python /usr/bin/python3.8 1; \
alternatives --install /usr/bin/pip pip /usr/bin/pip3.8 1; \
cd /src && pip install --target ./package -r requirements.txt; \
rm lambda.zip 2>/dev/null; \
zip -r -9 lambda.zip ./package; \
zip -g lambda.zip *.py; \
'); \
$(DKR) cp . $$cid:/src/; \
$(DKR) start -a $$cid; \
$(DKR) cp $$cid:/src/lambda.zip .; \
$(DKR) rm $$cid
# Each container-dotfile target can reference a $(BIN) variable.
# This is done in 2 steps to enable target-specific variables.