diff --git a/.github/workflows/deploy_sap_model_lambda.yml b/.github/workflows/deploy_sap_model_lambda.yml index fd1e4210..24a8ee2a 100644 --- a/.github/workflows/deploy_sap_model_lambda.yml +++ b/.github/workflows/deploy_sap_model_lambda.yml @@ -54,9 +54,19 @@ jobs: - name: Setup Docker uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: Build Docker Image run: | - cd model_data/simulation_system && docker build -t lambda-sap-prediction-image:${{ github.sha }} -f Dockerfiles/Dockerfile.prediction.lambda . --load + cd model_data/simulation_system + docker buildx create --use + docker buildx build --push --cache-from=type=local,src=/tmp/.buildx-cache --cache-to=type=local,dest=/tmp/.buildx-cache --tag lambda-sap-prediction-image:${{ github.sha }} -f Dockerfiles/Dockerfile.prediction.lambda . - name: Login to ECR run: | diff --git a/model_data/simulation_system/Dockerfiles/Dockerfile.prediction.lambda b/model_data/simulation_system/Dockerfiles/Dockerfile.prediction.lambda index ccd80c4e..0c3db572 100644 --- a/model_data/simulation_system/Dockerfiles/Dockerfile.prediction.lambda +++ b/model_data/simulation_system/Dockerfiles/Dockerfile.prediction.lambda @@ -1,14 +1,17 @@ FROM public.ecr.aws/lambda/python:3.10 +# Set the working directory +WORKDIR ${LAMBDA_TASK_ROOT}/simulation_system + # Install python packages -COPY ../requirements/predictions/predictions.txt requirements.txt +COPY ../requirements/predictions/predictions.txt ./requirements.txt RUN pip install --no-cache-dir -r requirements.txt -# Copy the project code to user home directory -COPY ./core ${LAMBDA_TASK_ROOT}/simulation_system/core -COPY ./MLModel ${LAMBDA_TASK_ROOT}/simulation_system/MLModel -COPY ./predictions.py ${LAMBDA_TASK_ROOT}/simulation_system/predictions.py -COPY ./handlers/predictions_app.py ${LAMBDA_TASK_ROOT}/simulation_system/predictions_app.py +# Copy the project code to the working directory +COPY ./core ./core +COPY ./MLModel ./MLModel +COPY ./predictions.py ./predictions.py +COPY ./handlers/predictions_app.py ./predictions_app.py # Run off a lambda trigger CMD [ "predictions_app.handler" ] diff --git a/sapmodel.serverless.yml b/sapmodel.serverless.yml index a37e2df5..50567b36 100644 --- a/sapmodel.serverless.yml +++ b/sapmodel.serverless.yml @@ -19,7 +19,7 @@ plugins: custom: customDomain: domainName: api.${self:provider.environment.DOMAIN_NAME} - basePath: 'sapmodel' + basePath: 'v1/sapmodel' createRoute53Record: true certificateArn: ${ssm:/ssl_certificate_arn}