Untitled

 avatar
unknown
plain_text
2 years ago
1.6 kB
6
Indexable
FROM python:3.7.13

ARG STAGE
ARG REGION
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG AWS_SESSION_TOKEN

RUN echo "Installing pip dependencies"
RUN apt update -y ; apt install zip python3-pip -y
RUN apt install -y npm
RUN apt install sudo

RUN echo "Installing aws-cli"
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
RUN unzip awscliv2.zip
RUN sudo ./aws/install

RUN echo "Installing serverless"
RUN npm install -g serverless@3.18.1

RUN echo "Copy source code"
WORKDIR /app
COPY .  /app

RUN echo "Installing package.json dependencies"
RUN echo STAGE=$STAGE
RUN npm install

RUN echo "Configure credentials"
RUN serverless config credentials \
  --profile default \
  --provider aws \
  --key $AWS_ACCESS_KEY_ID \
  --secret $AWS_SECRET_ACCESS_KEY

RUN if [ -n "$AWS_SESSION_TOKEN" ]; then aws configure --profile default set aws_session_token $AWS_SESSION_TOKEN; fi

RUN echo "Installing layers dependencies"
RUN pip3 install -t layers/common/python/lib/python3.7/site-packages -r layers/common/aws_requirements.txt
RUN pip3 install -t layers/opencv/python/lib/python3.7/site-packages -r layers/opencv/aws_requirements.txt
RUN pip3 install -t layers/pandas/python/lib/python3.7/site-packages -r layers/pandas/aws_requirements.txt

RUN echo "Deploy..."
RUN SLS_DEBUG=* serverless deploy --force --verbose --aws-profile default --stage $STAGE --region $REGION
RUN serverless invoke -f update_parameters_automation --aws-profile default --stage $STAGE --region $REGION
Editor is loading...