Skip to content

Commit 4327557

Browse files
Add asset size check and remove compiled c/c++ code in dockerfile
1 parent 65e1323 commit 4327557

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

.github/actions/cdk-deploy/action.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,24 @@ runs:
6969
shell: bash
7070
working-directory: ${{ inputs.dir }}
7171
run: uv run npm run cdk -- synth
72-
72+
73+
- name: Check Asset Sizes
74+
shell: bash
75+
working-directory: ${{ inputs.dir }}
76+
run: |
77+
MAX_SIZE_BYTES=262144000 # 262 MB in bytes
78+
for dir in cdk.out/asset.*; do
79+
if [ -d "$dir" ]; then
80+
size=$(du -sb "$dir" | cut -f1)
81+
if [ "$size" -gt $MAX_SIZE_BYTES ]; then
82+
echo "Directory $dir exceeds 262 MB with size $size bytes (max: $MAX_SIZE_BYTES bytes)."
83+
exit 1
84+
fi
85+
echo "Asset directory $dir size: $size bytes"
86+
fi
87+
done
88+
echo "All asset directories are within size limits."
89+
7390
- name: Deploy Test
7491
if: ${{ inputs.skip_deploy == 'false' }}
7592
id: deploy_titiler_cmr_stack

infrastructure/aws/lambda/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ RUN rm -rdf /asset/numpy/doc/ /asset/bin /asset/geos_license /asset/Misc
3030
RUN rm -rdf /asset/boto3*
3131
RUN rm -rdf /asset/botocore*
3232

33+
# Strip debug symbols from compiled C/C++ code (except for numpy.libs!)
34+
RUN cd /asset && \
35+
find . -type f -name '*.so*' \
36+
-not -path "./numpy.libs/*" \
37+
-exec strip --strip-unneeded {} \;
38+
3339
COPY infrastructure/aws/lambda/handler.py /asset/handler.py
3440

3541
CMD ["echo", "hello world"]

0 commit comments

Comments
 (0)