diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 0b679f8f7..b95601294 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -126,14 +126,14 @@ 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 . - 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 65e69bedb..49437bd2b 100644 --- a/cla-backend/Dockerfile +++ b/cla-backend/Dockerfile @@ -4,10 +4,11 @@ FROM public.ecr.aws/lambda/python:3.7 # Copy requirements.txt -COPY requirements.txt ${LAMBDA_TASK_ROOT} +ADD requirements.txt requirements-test.txt ${LAMBDA_TASK_ROOT} # Copy function code -COPY *.py cla ${LAMBDA_TASK_ROOT} +ADD *.py .serverless-wsgi serverless-authorizer.yml ${LAMBDA_TASK_ROOT} +ADD /cla ${LAMBDA_TASK_ROOT}/cla # Install the specified packages RUN pip install -r requirements.txt diff --git a/cla-backend/Makefile b/cla-backend/Makefile index a37ff56d3..5e20f01bf 100644 --- a/cla-backend/Makefile +++ b/cla-backend/Makefile @@ -1,6 +1,12 @@ # Copyright The Linux Foundation and each contributor to CommunityBridge. # SPDX-License-Identifier: MIT +ifeq ($(shell command -v podman 2> /dev/null),) + DOCKER_CMD=docker +else + DOCKER_CMD=podman +endif + .PHONY: setup setup: npm install; @@ -15,7 +21,7 @@ setup_circle: sudo pip install -r requirements.txt; \ # username: LFID username -# projects: quoted list of SFDC project IDs. e.g. '\"abcd\",\"1234\"' +# projects: quoted list of SFDC project IDs. e.g. '\"abcd\",\"1234\"' .PHONY: add_project_manager add_project_manager: aws dynamodb put-item \ @@ -111,3 +117,9 @@ deploy-dynamodb-backups: source ~/.env/lf-cla/bin/activate; \ cd serverless-dynamodb-backups; \ ../node_modules/.bin/serverless deploy --region us-east-1; \ + +build-docker-mac: + $(DOCKER_CMD) build --platform linux/arm64 -t easycla-python: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.sh b/cla-backend/run-docker.sh new file mode 100755 index 000000000..8869eb083 --- /dev/null +++ b/cla-backend/run-docker.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +# Copyright The Linux Foundation and each contributor to CommunityBridge. +# SPDX-License-Identifier=MIT + +# 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 \ + --rm \ + --name easycla-python \ + -it \ + -p 8080:8080 \ + -e STAGE="${STAGE}" \ + -e AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \ + -e AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \ + -e AWS_SESSION_TOKEN="${AWS_SESSION_TOKEN}" \ + -e REGION="us-east-1" \ + -e DYNAMODB_AWS_REGION="us-east-1" \ + -e GH_APP_WEBHOOK_SECRET="${GH_APP_WEBHOOK_SECRET}" \ + -e GH_APP_ID="${GH_APP_ID}" \ + -e GH_OAUTH_CLIENT_ID="${GH_OAUTH_CLIENT_ID}" \ + -e GH_OAUTH_SECRET="${GH_OAUTH_SECRET}" \ + -e GITHUB_OAUTH_TOKEN="${GITHUB_OAUTH_TOKEN}" \ + -e GITHUB_APP_WEBHOOK_SECRET="${GITHUB_APP_WEBHOOK_SECRET}" \ + -e GH_STATUS_CTX_NAME="EasyCLA" \ + -e AUTH0_DOMAIN="${AUTH0_DOMAIN}" \ + -e AUTH0_CLIENT_ID="${AUTH0_CLIENT_ID}" \ + -e AUTH0_USERNAME_CLAIM="${AUTH0_USERNAME_CLAIM}" \ + -e AUTH0_ALGORITHM="${AUTH0_ALGORITHM}" \ + -e SF_INSTANCE_URL="${SF_INSTANCE_URL}" \ + -e SF_CLIENT_ID="${SF_CLIENT_ID}" \ + -e SF_CLIENT_SECRET="${SF_CLIENT_SECRET}" \ + -e SF_USERNAME="${SF_USERNAME}" \ + -e SF_PASSWORD="${SF_PASSWORD}" \ + -e DOCRAPTOR_API_KEY="${DOCRAPTOR_API_KEY}" \ + -e DOCUSIGN_ROOT_URL="${DOCUSIGN_ROOT_URL}" \ + -e DOCUSIGN_USERNAME="${DOCUSIGN_USERNAME}" \ + -e DOCUSIGN_PASSWORD="${DOCUSIGN_PASSWORD}" \ + -e DOCUSIGN_AUTH_SERVER="${DOCUSIGN_AUTH_SERVER}" \ + -e CLA_API_BASE="${CLA_API_BASE}" \ + -e CLA_CONTRIBUTOR_BASE="${CLA_CONTRIBUTOR_BASE}" \ + -e CLA_CONTRIBUTOR_V2_BASE="${CLA_CONTRIBUTOR_V2_BASE}" \ + -e CLA_CORPORATE_BASE="${CLA_CORPORATE_BASE}" \ + -e CLA_CORPORATE_V2_BASE="${CLA_CORPORATE_V2_BASE}" \ + -e CLA_LANDING_PAGE="${CLA_LANDING_PAGE}" \ + -e CLA_SIGNATURE_FILES_BUCKET="${CLA_SIGNATURE_FILES_BUCKET}" \ + -e CLA_BUCKET_LOGO_URL="${CLA_BUCKET_LOGO_URL}" \ + -e SES_SENDER_EMAIL_ADDRESS="${SES_SENDER_EMAIL_ADDRESS}" \ + -e SMTP_SENDER_EMAIL_ADDRESS="${SMTP_SENDER_EMAIL_ADDRESS}" \ + -e LF_GROUP_CLIENT_ID="${LF_GROUP_CLIENT_ID}" \ + -e LF_GROUP_CLIENT_SECRET="${LF_GROUP_CLIENT_SECRET}" \ + -e LF_GROUP_REFRESH_TOKEN="${LF_GROUP_REFRESH_TOKEN}" \ + -e LF_GROUP_CLIENT_URL="${LF_GROUP_CLIENT_URL}" \ + -e SNS_EVENT_TOPIC_ARN="${SNS_EVENT_TOPIC_ARN}" \ + -e PLATFORM_AUTH0_URL="${PLATFORM_AUTH0_URL}" \ + -e PLATFORM_AUTH0_CLIENT_ID="${PLATFORM_AUTH0_CLIENT_ID}" \ + -e PLATFORM_AUTH0_CLIENT_SECRET="${PLATFORM_AUTH0_CLIENT_SECRET}" \ + -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 \ + + diff --git a/cla-backend/serverless.yml b/cla-backend/serverless.yml index 64320c3cd..4b517e42e 100644 --- a/cla-backend/serverless.yml +++ b/cla-backend/serverless.yml @@ -125,7 +125,7 @@ provider: # In this section you can define images that will be built locally and uploaded to ECR # Ref: https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml#docker-image-deployments-in-ecr images: - easyclaPythonAppImage: + easycla_python_app_image: uri: ${self:custom.ecr_img.${sls:stage}} apiGateway: @@ -604,7 +604,7 @@ functions: handler: wsgi_handler.handler description: "EasyCLA Python API handler for the /v1 endpoints" image: - name: easyclaPythonAppImage + name: easycla_python_app_image command: - 'wsgi_handler.handler' #entryPoint: @@ -619,7 +619,7 @@ functions: handler: wsgi_handler.handler description: "EasyCLA Python API handler for the /v2 endpoints" image: - name: easyclaPythonAppImage + name: easycla_python_app_image command: - 'wsgi_handler.handler' # layers: @@ -634,7 +634,7 @@ functions: handler: cla.salesforce.get_projects description: "EasyCLA API Callback Handler for fetching all SalesForce projects" image: - name: easyclaPythonAppImage + name: easycla_python_app_image command: - 'cla.salesforce.get_projects' # layers: @@ -649,7 +649,7 @@ functions: handler: cla.salesforce.get_project description: "EasyCLA API Callback Handler for fetching SalesForce projects by ID" image: - name: easyclaPythonAppImage + name: easycla_python_app_image command: - 'cla.salesforce.get_project' # layers: @@ -665,7 +665,7 @@ functions: handler: wsgi_handler.handler description: "EasyCLA API Callback Handler for GitHub bot installations" image: - name: easyclaPythonAppImage + name: easycla_python_app_image command: - 'wsgi_handler.handler' # layers: @@ -680,7 +680,7 @@ functions: handler: wsgi_handler.handler description: "EasyCLA API Callback Handler for GitHub activity" image: - name: easyclaPythonAppImage + name: easycla_python_app_image command: - 'wsgi_handler.handler' # layers: