Skip to content

Commit

Permalink
feature/resolve serverless variable (#4117)
Browse files Browse the repository at this point in the history
  • Loading branch information
dealako authored Aug 31, 2023
1 parent 899f722 commit a20f1c1
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 14 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
5 changes: 3 additions & 2 deletions cla-backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion cla-backend/Makefile
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 \
Expand Down Expand Up @@ -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 .
65 changes: 65 additions & 0 deletions cla-backend/run-docker.sh
Original file line number Diff line number Diff line change
@@ -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 \


14 changes: 7 additions & 7 deletions cla-backend/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit a20f1c1

Please sign in to comment.