Skip to content

Commit

Permalink
Dockerfile Updates
Browse files Browse the repository at this point in the history
- fixed import/copy/add
- resolved architecture in CI/CD GitHub action

Signed-off-by: David Deal <ddeal@linuxfoundation.org>
  • Loading branch information
dealako committed Aug 31, 2023
1 parent f02c3f7 commit 3e83628
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 45 deletions.
46 changes: 4 additions & 42 deletions .github/workflows/build-docker-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ on:
- main

env:
AWS_REGION: us-east-1
AWS_ECR_REGION: us-east-1
AWS_PROFILE: lf-cla
STAGE: dev
REPOSITORY: lfx-easycla-dev
ECR_HOST: ${{secrets.AWS_ACCOUNT_ID}}.dkr.ecr.us-east-1.amazonaws.com
Expand All @@ -29,41 +26,6 @@ jobs:
uses: docker/setup-buildx-action@v2
- name: Available Build Platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: us-east-1
role-duration-seconds: 900
- name: Setup AWS Profile
run: |
echo "Installing Profile '${AWS_PROFILE}'..."
mkdir -p ~/.aws
touch ~/.aws/config
if ! grep -q AWS_PROFILE ~/.aws/config; then
printf "[profile ${AWS_PROFILE}]\nregion=${AWS_REGION}\noutput=json" > ~/.aws/config
echo "Added ${AWS_PROFILE} profile to ~/.aws/config"
else
echo "Skipped adding ${AWS_PROFILE} to ~/.aws/config - already there"
fi
touch ~/.aws/credentials
if ! grep -q AWS_PROFILE ~/.aws/credentials; then
printf "[${AWS_PROFILE}]\naws_access_key_id=${{ secrets.AWS_ACCESS_KEY }}\naws_secret_access_key=${{ secrets.AWS_SECRET_KEY }}" > ~/.aws/credentials
echo "Added ${AWS_PROFILE} profile to ~/.aws/credentials"
else
echo "Skipped adding ${AWS_PROFILE} to ~/.aws/credentials - already there"
fi
if ! grep -q AWS_PROFILE ${HOME}/.bashrc; then
echo "export AWS_PROFILE=${AWS_PROFILE}" >> ${HOME}/.bashrc
echo "Added ${AWS_PROFILE} profile to ${HOME}/.bashrc"
else
echo "Skipped adding ${AWS_PROFILE} to ${HOME}/.bashrc - already there"
fi
- name: Build Docker Image
working-directory: cla-backend
run: |
Expand All @@ -72,11 +34,11 @@ jobs:
docker buildx create --name container --driver=docker-container
echo "Building image with tag: ${ECR_HOST}/${REPOSITORY}:${{github.sha}}"
docker buildx build --platform=linux/arm64 --builder=container --tag ${ECR_HOST}/${REPOSITORY}:${{github.sha}} .
docker buildx build --platform=linux/amd64 --builder=container --tag ${ECR_HOST}/${REPOSITORY}:${{github.sha}} .
echo "Building image with tag: ${ECR_HOST}/${REPOSITORY}:latest"
docker buildx build --platform=linux/arm64 --builder=container --tag ${ECR_HOST}/${REPOSITORY}:latest .
docker buildx build --platform=linux/amd64 --builder=container --tag ${ECR_HOST}/${REPOSITORY}:latest .
# Note, unlike when using the default docker driver, images built with the docker-container driver must be explicitly loaded into the local image store. Use the --load flag
echo "Loading the image into the image store..."
docker buildx build --platform=linux/arm64 --builder=container --load --tag ${ECR_HOST}/${REPOSITORY}:${{github.sha}} .
docker buildx build --platform=linux/arm64 --builder=container --load --tag ${ECR_HOST}/${REPOSITORY}:latest .
docker buildx build --platform=linux/amd64 --builder=container --load --tag ${ECR_HOST}/${REPOSITORY}:${{github.sha}} .
docker buildx build --platform=linux/amd64 --builder=container --load --tag ${ECR_HOST}/${REPOSITORY}:latest .
7 changes: 4 additions & 3 deletions cla-backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
FROM public.ecr.aws/lambda/python:3.7

# Copy requirements.txt
COPY requirements.txt requirements-test.txt ${LAMBDA_TASK_ROOT}

COPY requirements.txt ${LAMBDA_TASK_ROOT}
# Copy function code
COPY *.py .serverless-wsgi serverless-authorizer.yml ${LAMBDA_TASK_ROOT}
# Add the CLA library folder
ADD /cla ${LAMBDA_TASK_ROOT}/cla
ADD /helpers ${LAMBDA_TASK_ROOT}/helpers
ADD /auth ${LAMBDA_TASK_ROOT}/auth

# Install the specified packages
RUN pip install -r requirements.txt
RUN pip install --upgrade pip && pip install -r requirements.txt

# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "wsgi_handler.handler" ]

0 comments on commit 3e83628

Please sign in to comment.