Skip to content

Add a multirun Dockerfile & Worflow to publish to AWS ECR Public Gallery #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -36,6 +44,7 @@ jobs:
- uses: docker/setup-buildx-action@v2
with:
install: true

- name: Docker Labels
id: meta
uses: docker/metadata-action@v4
Expand All @@ -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.multirun -t public.ecr.aws/$AWS_ALIAS/$REPOSITORY_NAME:latest .
# docker push public.ecr.aws/$AWS_ALIAS/$REPOSITORY_NAME:latest
57 changes: 57 additions & 0 deletions Dockerfile.multirun
Original file line number Diff line number Diff line change
@@ -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"]
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ services:
# retries: 2
# start_period: 5s
```
### Dockerfile for 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

Expand Down