testing streamlined approach to pushing and caching in github actions

This commit is contained in:
Khalim Conn-Kowlessar 2023-09-01 14:51:13 +01:00
parent 17b5464acf
commit 118fec54f6

View file

@ -22,10 +22,6 @@ jobs:
npm install -g serverless
npm install -g serverless-domain-manager
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: AWS credentials for dev
if: github.ref == 'refs/heads/dev'
uses: aws-actions/configure-aws-credentials@v1
@ -54,28 +50,15 @@ jobs:
- name: Setup Docker
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
# Building and pushing Docker image with caching
- name: Build and push Docker image
uses: docker/build-push-action@v4
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 buildx create --use
docker buildx build --load --cache-from=type=local,src=/tmp/.buildx-cache --cache-to=type=local,dest=/tmp/.buildx-cache --build-arg BUILDKIT_INLINE_CACHE=1 --tag lambda-sap-prediction-image:${{ github.sha }} -f Dockerfiles/Dockerfile.prediction.lambda .
- name: Login to ECR
run: |
aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin ${{ steps.set_ecr_credentials.outputs.ecr_uri }}
- name: Tag and Push Docker Image to ECR
run: |
docker tag lambda-sap-prediction-image:${{ github.sha }} ${{ steps.set_ecr_credentials.outputs.ecr_uri }}:${{ github.sha }}
docker push ${{ steps.set_ecr_credentials.outputs.ecr_uri }}:${{ github.sha }}
context: ./model_data/simulation_system
push: true
tags: ${{ steps.set_ecr_credentials.outputs.ecr_uri }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Deploy to AWS Lambda via Serverless
env: