From a619d0cd617a0c93a45886a39462cab704c805bf Mon Sep 17 00:00:00 2001 From: "[Mufeth7]" Date: Mon, 26 May 2025 14:45:18 +0530 Subject: [PATCH 1/8] Add workflow to push image in ECR Public Repository --- .github/workflows/release.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b837c9c..12a55ac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,14 @@ on: tags: - 'v*.*.*' +permissions: + id-token: write + contents: read + +env: + REPOSITORY_NAME: cryptgeon + AWS_ALIAS: #Add your AWS Custom Alias + jobs: cli: runs-on: ubuntu-latest @@ -36,6 +44,7 @@ jobs: - uses: docker/setup-buildx-action@v2 with: install: true + - name: Docker Labels id: meta uses: docker/metadata-action@v4 @@ -45,14 +54,39 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} + - name: Login to DockerHub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push uses: docker/build-push-action@v4 with: platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} + + AWS: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ secrets.AWS_ARN }} + aws-region: ap-south-1 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, tag, and push the image to Amazon ECR + id: build-image + run: | + aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/r9h8b0z6 + docker build -f cryptgeon/Dockerfile.apprunner -t public.ecr.aws/$AWS_ALIAS/$REPOSITORY_NAME:latest . + docker push public.ecr.aws/$AWS_ALIAS/$REPOSITORY_NAME:latest \ No newline at end of file From 31d84c799f85fb8118075d5e5d343caaffa3acb8 Mon Sep 17 00:00:00 2001 From: "[Mufeth7]" Date: Mon, 26 May 2025 18:24:39 +0530 Subject: [PATCH 2/8] Add Dockerfile to run Cryptgeon on AWS App Runner --- Dockerfile.apprunner | 57 ++++++++++++++++++++++++++++++++++++++++++++ README.md | 3 +++ 2 files changed, 60 insertions(+) create mode 100644 Dockerfile.apprunner diff --git a/Dockerfile.apprunner b/Dockerfile.apprunner new file mode 100644 index 0000000..61e6580 --- /dev/null +++ b/Dockerfile.apprunner @@ -0,0 +1,57 @@ +# FRONTEND +FROM public.ecr.aws/docker/library/node:22-alpine as client +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +RUN corepack enable + +WORKDIR /tmp +COPY . . +RUN pnpm install --frozen-lockfile +RUN pnpm run build + +# BACKEND +FROM public.ecr.aws/docker/library/rust:1.85-alpine as backend +WORKDIR /tmp +RUN apk add --no-cache libc-dev openssl-dev alpine-sdk +COPY ./packages/backend ./ +RUN RUSTFLAGS="-Ctarget-feature=-crt-static" cargo build --release + +# RUNNER +FROM public.ecr.aws/docker/library/alpine:3.19 +WORKDIR /app + +RUN apk add --no-cache curl libgcc redis supervisor && \ + rm -rf /var/cache/apk/* && \ + mkdir -p /etc/supervisor/conf.d /data && \ + chmod 777 /data + +COPY --from=backend /tmp/target/release/cryptgeon . +COPY --from=client /tmp/packages/frontend/build ./frontend + +RUN echo '[supervisord]' > /etc/supervisor/conf.d/supervisord.conf && \ + echo 'nodaemon=true' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo '' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo '[program:redis]' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo 'command=/usr/bin/redis-server --save "" --appendonly no --maxmemory 1gb --maxmemory-policy allkeys-lru --dir /data' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo 'autostart=true' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo 'autorestart=true' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo 'stdout_logfile=/dev/stdout' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo 'stdout_logfile_maxbytes=0' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo 'stderr_logfile=/dev/stderr' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo 'stderr_logfile_maxbytes=0' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo '' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo '[program:cryptgeon]' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo 'command=/app/cryptgeon' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo 'autostart=true' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo 'autorestart=true' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo 'environment=FRONTEND_PATH="./frontend",REDIS="redis://localhost:6379/",SIZE_LIMIT="4MiB"' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo 'stdout_logfile=/dev/stdout' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo 'stdout_logfile_maxbytes=0' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo 'stderr_logfile=/dev/stderr' >> /etc/supervisor/conf.d/supervisord.conf && \ + echo 'stderr_logfile_maxbytes=0' >> /etc/supervisor/conf.d/supervisord.conf + +VOLUME ["/data"] + +EXPOSE 8000 + +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] \ No newline at end of file diff --git a/README.md b/README.md index 263ddb3..0579448 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,9 @@ services: # retries: 2 # start_period: 5s ``` +### Dockerfile for AWS App Runner + +This Dockerfile[Dockerfile.apprunner](cryptgeon/Dockerfile.apprunner) used to run Cryptgeon on AWS App Runner. [Deploy Crpytgeon on AWS App Runner](https://dev.to/mufeth7/deploy-cryptgeon-on-aws-apprunner-5hj8). This guide will help you to run Cryptgeon on AWS App Runner. ### NGINX Proxy From 9eaf81f9764b494c1b98697c561356eb047c08c1 Mon Sep 17 00:00:00 2001 From: Syed Mufeth <117529070+Mufeth7@users.noreply.github.com> Date: Mon, 26 May 2025 18:30:44 +0530 Subject: [PATCH 3/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0579448..a5f94f1 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ services: ``` ### Dockerfile for AWS App Runner -This Dockerfile[Dockerfile.apprunner](cryptgeon/Dockerfile.apprunner) used to run Cryptgeon on AWS App Runner. [Deploy Crpytgeon on AWS App Runner](https://dev.to/mufeth7/deploy-cryptgeon-on-aws-apprunner-5hj8). This guide will help you to run Cryptgeon on AWS App Runner. +This Dockerfile [Dockerfile.apprunner](cryptgeon/Dockerfile.apprunner) used to run Cryptgeon on AWS App Runner. [Deploy Crpytgeon on AWS App Runner](https://dev.to/mufeth7/deploy-cryptgeon-on-aws-apprunner-5hj8). This guide will help you to run Cryptgeon on AWS App Runner. ### NGINX Proxy From 4342e1864728ab20e6c342f53eed885bba2a32de Mon Sep 17 00:00:00 2001 From: Syed Mufeth <117529070+Mufeth7@users.noreply.github.com> Date: Mon, 26 May 2025 19:47:45 +0530 Subject: [PATCH 4/8] Rename Dockerfile.apprunner to Dockerfile.multirun --- Dockerfile.apprunner => Dockerfile.multirun | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Dockerfile.apprunner => Dockerfile.multirun (99%) diff --git a/Dockerfile.apprunner b/Dockerfile.multirun similarity index 99% rename from Dockerfile.apprunner rename to Dockerfile.multirun index 61e6580..dd08c4b 100644 --- a/Dockerfile.apprunner +++ b/Dockerfile.multirun @@ -54,4 +54,4 @@ VOLUME ["/data"] EXPOSE 8000 -CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] \ No newline at end of file +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] From d1a2fb66c405d1b95eaa0ba9aca32299cb560188 Mon Sep 17 00:00:00 2001 From: Syed Mufeth <117529070+Mufeth7@users.noreply.github.com> Date: Mon, 26 May 2025 19:49:02 +0530 Subject: [PATCH 5/8] Update release.yml --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 12a55ac..8e22a2a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -88,5 +88,5 @@ jobs: id: build-image run: | aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/r9h8b0z6 - docker build -f cryptgeon/Dockerfile.apprunner -t public.ecr.aws/$AWS_ALIAS/$REPOSITORY_NAME:latest . - docker push public.ecr.aws/$AWS_ALIAS/$REPOSITORY_NAME:latest \ No newline at end of file + docker build -f cryptgeon/Dockerfile.multirun -t public.ecr.aws/$AWS_ALIAS/$REPOSITORY_NAME:latest . + docker push public.ecr.aws/$AWS_ALIAS/$REPOSITORY_NAME:latest From 7d36a657762b2167677d69a446c684cdcd680a59 Mon Sep 17 00:00:00 2001 From: Syed Mufeth <117529070+Mufeth7@users.noreply.github.com> Date: Mon, 26 May 2025 19:50:38 +0530 Subject: [PATCH 6/8] Update release.yml --- .github/workflows/release.yml | 38 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8e22a2a..3375e94 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -68,25 +68,25 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} - AWS: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 + # AWS: + # runs-on: ubuntu-latest + # steps: + # - name: Checkout + # uses: actions/checkout@v3 - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - role-to-assume: ${{ secrets.AWS_ARN }} - aws-region: ap-south-1 + # - name: Configure AWS credentials + # uses: aws-actions/configure-aws-credentials@v1 + # with: + # role-to-assume: ${{ secrets.AWS_ARN }} + # aws-region: ap-south-1 - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 + # - name: Login to Amazon ECR + # id: login-ecr + # uses: aws-actions/amazon-ecr-login@v1 - - name: Build, tag, and push the image to Amazon ECR - id: build-image - run: | - aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/r9h8b0z6 - docker build -f cryptgeon/Dockerfile.multirun -t public.ecr.aws/$AWS_ALIAS/$REPOSITORY_NAME:latest . - docker push public.ecr.aws/$AWS_ALIAS/$REPOSITORY_NAME:latest + # - name: Build, tag, and push the image to Amazon ECR + # id: build-image + # run: | + # aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/r9h8b0z6 + # docker build -f cryptgeon/Dockerfile.multirun -t public.ecr.aws/$AWS_ALIAS/$REPOSITORY_NAME:latest . + # docker push public.ecr.aws/$AWS_ALIAS/$REPOSITORY_NAME:latest From e15df014553b438d863c84d28b7faf491052f1ad Mon Sep 17 00:00:00 2001 From: Syed Mufeth <117529070+Mufeth7@users.noreply.github.com> Date: Mon, 26 May 2025 20:01:15 +0530 Subject: [PATCH 7/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a5f94f1..5f3393a 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ services: ``` ### Dockerfile for AWS App Runner -This Dockerfile [Dockerfile.apprunner](cryptgeon/Dockerfile.apprunner) used to run Cryptgeon on AWS App Runner. [Deploy Crpytgeon on AWS App Runner](https://dev.to/mufeth7/deploy-cryptgeon-on-aws-apprunner-5hj8). This guide will help you to run Cryptgeon on AWS App Runner. +This Dockerfile [Dockerfile.multirun](cryptgeon/Dockerfile.multirun) Deploys Cryptgeon on multiple serverless platforms, GCP Cloud Run, Azure Container Instances, AWS AppRunner, etc.. [Deploy Crpytgeon on AWS App Runner](https://dev.to/mufeth7/deploy-cryptgeon-on-aws-apprunner-5hj8). This guide will help you to run Cryptgeon on AWS App Runner. ### NGINX Proxy From 623f48da2dd07f4e3f4b436933f4395d96bdf0f5 Mon Sep 17 00:00:00 2001 From: Syed Mufeth <117529070+Mufeth7@users.noreply.github.com> Date: Mon, 26 May 2025 20:05:15 +0530 Subject: [PATCH 8/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5f3393a..ad7c6ee 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ services: ``` ### Dockerfile for AWS App Runner -This Dockerfile [Dockerfile.multirun](cryptgeon/Dockerfile.multirun) Deploys Cryptgeon on multiple serverless platforms, GCP Cloud Run, Azure Container Instances, AWS AppRunner, etc.. [Deploy Crpytgeon on AWS App Runner](https://dev.to/mufeth7/deploy-cryptgeon-on-aws-apprunner-5hj8). This guide will help you to run Cryptgeon on AWS App Runner. +This Dockerfile [Dockerfile.multirun](Dockerfile.multirun) Deploys Cryptgeon on multiple serverless platforms, GCP Cloud Run, Azure Container Instances, AWS AppRunner, etc.. [Deploy Crpytgeon on AWS App Runner](https://dev.to/mufeth7/deploy-cryptgeon-on-aws-apprunner-5hj8). This guide will help you to run Cryptgeon on AWS App Runner. ### NGINX Proxy