|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | 3 | # Pull the Amazon Linux image from Docker Hub |
4 | | -docker pull amazonlinux |
| 4 | +# aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws |
| 5 | +docker pull public.ecr.aws/lambda/python:3.13-x86_64 |
5 | 6 |
|
6 | 7 | # Run the Amazon Linux container in detached mode |
7 | | -docker run -d --name telemetry amazonlinux tail -f /dev/null |
| 8 | +docker run -d --name telemetry public.ecr.aws/lambda/python:3.13-x86_64 lambda_function.lambda_handler |
8 | 9 |
|
9 | | -# Install Python, pip, and other dependencies inside the container |
10 | | -docker exec -it telemetry /bin/bash -c "yum update -y && yum install -y python3-pip zip && python3 -m pip install virtualenv" |
| 10 | +# Install dependencies inside the container |
| 11 | +docker exec -it telemetry /bin/bash -c "dnf install -y zip" |
11 | 12 |
|
12 | 13 | # Create a virtual environment and install dependencies |
13 | 14 | docker exec -it telemetry /bin/bash -c "python3 -m venv temp-venv && source temp-venv/bin/activate && mkdir telemetry && cd telemetry && pip install crhelper sumologic-appclient-sdk future_fstrings setuptools -t ." |
14 | 15 |
|
15 | 16 | # Copy python file from host to container |
16 | | -docker cp ./lambda_function.py telemetry:/telemetry |
| 17 | +docker cp ./lambda_function.py telemetry:/var/task/telemetry |
| 18 | +docker cp ./metadata.yaml telemetry:/var/task/telemetry |
17 | 19 |
|
18 | 20 | # Zip the contents of the telemetry directory |
19 | 21 | docker exec -it telemetry /bin/bash -c "cd telemetry && ls -l && zip -r ../telemetry.zip ." |
20 | 22 |
|
21 | 23 | # Copy the telemetry.zip file from the container to the host |
22 | | -docker cp telemetry:/telemetry.zip ./telemetry.zip |
| 24 | +docker cp telemetry:/var/task/telemetry.zip ./telemetry.zip |
23 | 25 |
|
24 | 26 | # Stop and remove the container |
25 | 27 | docker stop telemetry |
|
0 commit comments