forked from CoinHippo-Labs/axelarscan-api
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfc8f2b
commit bc1817e
Showing
3 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
terraform | ||
.gitignore | ||
README.md | ||
LICENSE | ||
yarn.lock | ||
.env.example | ||
.env | ||
.git | ||
test | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Build and push latest docker image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- feat/dockerize-build | ||
workflow_dispatch: | ||
jobs: | ||
build-and-push-latest-docker-image: | ||
strategy: | ||
matrix: | ||
os: | ||
- ubuntu-20.04 | ||
runs-on: ${{ matrix.os }} | ||
permissions: | ||
id-token: write | ||
contents: read | ||
env: | ||
REPOSITORY: axelarscan-api | ||
IMAGE_TAG: ${{ github.sha }} | ||
AWS_ACCOUNT_ID: 499786161782 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: fetch tags | ||
run: | | ||
git fetch --unshallow | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-region: us-east-2 | ||
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/ghwf-${{ github.event.repository.name }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
- name: check if an image already build on same commit hash | ||
id: image-tag-check | ||
run: | | ||
app_version="v$(jq -r .version package.json)" | ||
if [ ${{ github.ref }} != 'refs/heads/main' ]; then | ||
app_version="${app_version}-dev_${GITHUB_RUN_NUMBER}.${GITHUB_RUN_ATTEMPT}" | ||
fi | ||
image_tag_exists=$(aws ecr batch-get-image --repository-name ${REPOSITORY} --image-ids "imageTag=${app_version}" | jq '.images | length') | ||
echo "image_tag_exists=${image_tag_exists}" >> $GITHUB_OUTPUT | ||
echo "IMAGE_TAG=${app_version}" >> $GITHUB_ENV | ||
- name: Build docker image | ||
if: steps.image-tag-check.outputs.image_tag_exists == 0 | ||
run: | | ||
docker build --platform linux/amd64 -t axelarscan/axelarscan-api . | ||
- name: Push to ECR | ||
if: steps.image-tag-check.outputs.image_tag_exists == 0 | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
run: | | ||
docker image tag axelarscan/axelarscan-api "${ECR_REGISTRY}/${REPOSITORY}:${IMAGE_TAG}" | ||
docker push "${ECR_REGISTRY}/${REPOSITORY}:${IMAGE_TAG}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM public.ecr.aws/lambda/nodejs:20 | ||
|
||
COPY --from=public.ecr.aws/datadog/lambda-extension:55 /opt/extensions/ /opt/extensions | ||
|
||
COPY . ${LAMBDA_TASK_ROOT} | ||
|
||
RUN npm install yarn --global | ||
RUN npm install datadog-lambda-js dd-trace | ||
|
||
RUN yarn | ||
|
||
CMD [ "index.handler" ] |