Initial commit

main
Adib Pratama 1 year ago
commit 215f68903b
  1. 1
      .gitignore
  2. 11
      Dockerfile
  3. 3
      requirements.txt
  4. 20
      run.sh

1
.gitignore vendored

@ -0,0 +1 @@
python.zip

@ -0,0 +1,11 @@
FROM amd64/python:3.7.17-bookworm
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN apt update
RUN apt install -y zip
RUN mkdir -p ./python
RUN pip install --no-cache-dir -r requirements.txt -t python/
RUN zip -r python_layer.zip python
# ENTRYPOINT ["tail", "-f", "/dev/null"]

@ -0,0 +1,3 @@
pandas
scikit-learn
numpy

@ -0,0 +1,20 @@
#!/bin/bash
IMAGE_NAME=python_aws_layer.image
CONTAINER_NAME=python_aws_layer.container
docker buildx build . -t $IMAGE_NAME:latest
# check if container exists
if [ ! "$(docker ps -a -q -f name=$CONTAINER_NAME)" ]; then
# check if it exited
if [ "$(docker ps -aq -f status=exited -f name=$CONTAINER_NAME)" ]; then
# cleanup
docker rm $CONTAINER_NAME
fi
# run your container
docker run --name $CONTAINER_NAME $IMAGE_NAME
fi
docker cp $CONTAINER_NAME:/usr/src/app/python.zip .
docker stop $CONTAINER_NAME
docker rm $CONTAINER_NAME
Loading…
Cancel
Save