diff --git a/.github/workflows/build-docker-pr.yml b/.github/workflows/build-docker-pr.yml index d201eed33..c522f12c5 100644 --- a/.github/workflows/build-docker-pr.yml +++ b/.github/workflows/build-docker-pr.yml @@ -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 @@ -22,61 +19,26 @@ jobs: environment: dev steps: - uses: actions/checkout@v3 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 + #- name: Set up QEMU + # uses: docker/setup-qemu-action@v2 + #- name: Set up Docker Buildx + # id: buildx + # 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: | # Create a new builder, named container, that uses the Docker container driver - echo "Creating a new builder container..." - docker buildx create --name container --driver=docker-container + #echo "Creating a new builder container..." + #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 build --platform linux/amd64 --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 build --platform linux/amd64 --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 build --platform linux/amd64 --load --tag ${ECR_HOST}/${REPOSITORY}:${{github.sha}} . + docker build --platform linux/amd64 --load --tag ${ECR_HOST}/${REPOSITORY}:latest . diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index b95601294..93de73cd1 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -28,13 +28,13 @@ jobs: go-version: '1.20.1' - name: Go Version run: go version - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - name: Available Build Platforms - run: echo ${{ steps.buildx.outputs.platforms }} + #- name: Set up QEMU + # uses: docker/setup-qemu-action@v2 + #- name: Set up Docker Buildx + # id: buildx + # uses: docker/setup-buildx-action@v2 + #- name: Available Build Platforms + # run: echo ${{ steps.buildx.outputs.platforms }} - name: Setup Node uses: actions/setup-node@v3 with: @@ -122,18 +122,18 @@ jobs: working-directory: cla-backend run: | # Create a new builder, named container, that uses the Docker container driver - echo "Creating a new builder container..." - docker buildx create --name container --driver=docker-container + #echo "Creating a new builder container..." + #docker buildx create --name container --driver docker-container echo "Building image with tag: ${ECR_HOST}/${REPOSITORY}:${{github.sha}}" - docker buildx build --platform=linux/amd64 --builder=container --tag ${ECR_HOST}/${REPOSITORY}:${{github.sha}} . + docker build --platform=linux/amd64 --tag ${ECR_HOST}/${REPOSITORY}:${{github.sha}} . echo "Building image with tag: ${ECR_HOST}/${REPOSITORY}:latest" - docker buildx build --platform=linux/amd64 --builder=container --tag ${ECR_HOST}/${REPOSITORY}:latest . + docker build --platform=linux/amd64 --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/amd64 --builder=container --load --tag ${ECR_HOST}/${REPOSITORY}:${{github.sha}} . - docker buildx build --platform=linux/amd64 --builder=container --load --tag ${ECR_HOST}/${REPOSITORY}:latest . + docker build --platform=linux/amd64 --load --tag ${ECR_HOST}/${REPOSITORY}:${{github.sha}} . + docker build --platform=linux/amd64 --load --tag ${ECR_HOST}/${REPOSITORY}:latest . - name: Publish Docker Image run: | aws ecr get-login-password --region ${AWS_ECR_REGION} | docker login --username AWS --password-stdin ${ECR_HOST} diff --git a/cla-backend/Dockerfile b/cla-backend/Dockerfile index 9e95220d5..976d0b14e 100644 --- a/cla-backend/Dockerfile +++ b/cla-backend/Dockerfile @@ -4,14 +4,19 @@ 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} +COPY *.py ${LAMBDA_TASK_ROOT} +#COPY .serverless-wsgi ${LAMBDA_TASK_ROOT} +RUN echo '{"app":"cla.routes.__hug_wsgi__"}' > .serverless-wsgi +COPY serverless-authorizer.yml ${LAMBDA_TASK_ROOT} # Add the CLA library folder -ADD /cla ${LAMBDA_TASK_ROOT}/cla +COPY /cla/ ${LAMBDA_TASK_ROOT}/cla/ +COPY /helpers/ ${LAMBDA_TASK_ROOT}/helpers/ +COPY /auth/ ${LAMBDA_TASK_ROOT}/auth/ # Install the specified packages +# RUN pip install --upgrade pip && pip install -r requirements.txt RUN pip install -r requirements.txt # Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) diff --git a/cla-backend/Makefile b/cla-backend/Makefile index 5e20f01bf..fc4569d3f 100644 --- a/cla-backend/Makefile +++ b/cla-backend/Makefile @@ -118,8 +118,13 @@ deploy-dynamodb-backups: cd serverless-dynamodb-backups; \ ../node_modules/.bin/serverless deploy --region us-east-1; \ +#$(DOCKER_CMD) build --platform linux/arm64 -t easycla-python:latest . +build-docker-mac-dockertool: + docker build --platform linux/arm64 --tag 726224182707.dkr.ecr.us-east-1.amazonaws.com/lfx-easycla-dev:latest . +build-docker-mac-podmantool: + podman build --platform linux/arm64 --tag 726224182707.dkr.ecr.us-east-1.amazonaws.com/lfx-easycla-dev:latest . build-docker-mac: - $(DOCKER_CMD) build --platform linux/arm64 -t easycla-python:latest . + $(DOCKER_CMD) build --platform linux/arm64 --tag 726224182707.dkr.ecr.us-east-1.amazonaws.com/lfx-easycla-dev:latest . build-docker-linux: build-docker build-docker: $(DOCKER_CMD) build --platform linux/amd64 -t easycla-python:latest . diff --git a/cla-backend/run-docker-shell.sh b/cla-backend/run-docker-shell.sh new file mode 100755 index 000000000..8c5746460 --- /dev/null +++ b/cla-backend/run-docker-shell.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# Copyright The Linux Foundation and each contributor to CommunityBridge. +# SPDX-License-Identifier=MIT + +docker run \ + --rm \ + -it \ + --name easycla-python-bash \ + --entrypoint /bin/bash \ + 726224182707.dkr.ecr.us-east-1.amazonaws.com/lfx-easycla-dev:latest + + diff --git a/cla-backend/run-docker.sh b/cla-backend/run-docker.sh index 8869eb083..4b856d014 100755 --- a/cla-backend/run-docker.sh +++ b/cla-backend/run-docker.sh @@ -6,10 +6,10 @@ # In a separate terminal, you can then locally invoke the function using cURL: # curl -XPOST "http://localhost:8080/2015-03-31/functions/function/invocations" -d '{"payload":"hello world!"}' -podman run \ +docker run \ --rm \ - --name easycla-python \ -it \ + --name easycla-python \ -p 8080:8080 \ -e STAGE="${STAGE}" \ -e AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \ @@ -59,7 +59,4 @@ podman run \ -e PLATFORM_AUTH0_AUDIENCE="${PLATFORM_AUTH0_AUDIENCE}" \ -e PLATFORM_GATEWAY_URL="${PLATFORM_GATEWAY_URL}" \ -e PLATFORM_MAINTAINERS="${PLATFORM_MAINTAINERS}" \ - easycla-python:latest - # --entrypoint /bin/bash \ - - + 726224182707.dkr.ecr.us-east-1.amazonaws.com/lfx-easycla-dev:latest