Skip to content
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
118 changes: 118 additions & 0 deletions .github/workflows/ci-frontend-apps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Frontend Apps CI

on:
push:
branches:
- main
- develop
- 'feature/**'
- 'bugfix/**'
paths:
- 'frontend/**'
- 'packages/**'
- 'package.json'
- 'pnpm-lock.yaml'
- '.github/workflows/ci-frontend-apps.yml'
pull_request:
branches:
- main
- develop

permissions:
contents: read
pull-requests: write

jobs:
lint-and-test:
name: Lint and Test Frontend Apps
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 8

- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: 22
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run linting
run: pnpm lint

- name: Run tests
run: pnpm test:coverage

- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: coverage/

build-apps:
name: Build All Frontend Apps
runs-on: ubuntu-latest
needs: lint-and-test

strategy:
matrix:
app: [admin-app, account-manager-app, branchmanager-app, cashier-app]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 8

- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: 22
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build ${{ matrix.app }}
run: pnpm --filter ${{ matrix.app }} build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.app }}
path: frontend/${{ matrix.app }}/dist

summary:
name: CI Summary
runs-on: ubuntu-latest
needs: [lint-and-test, build-apps]
if: always()

steps:
- name: Generate summary
run: |
echo "# Frontend Apps CI Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ **Lint and Test**: ${{ needs.lint-and-test.result }}" >> $GITHUB_STEP_SUMMARY
echo "✅ **Build Apps**: ${{ needs.build-apps.result }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

if [ "${{ needs.lint-and-test.result }}" == "success" ] && [ "${{ needs.build-apps.result }}" == "success" ]; then
echo "## ✅ All checks passed! Ready to publish." >> $GITHUB_STEP_SUMMARY
else
echo "## ❌ Some checks failed. Review logs above." >> $GITHUB_STEP_SUMMARY
fi
145 changes: 145 additions & 0 deletions .github/workflows/publish-frontend-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: Publish Frontend Docker Images

on:
push:
branches:
- develop
- main
paths:
- 'frontend/**'
- 'packages/**'
- 'Dockerfile.*'
- '.github/workflows/publish-frontend-images.yml'
workflow_dispatch:
inputs:
apps:
description: 'Apps to build (comma-separated: admin,account-manager,branch-manager,cashier or "all")'
required: false
default: 'all'

permissions:
contents: read
packages: write

env:
REGISTRY: ghcr.io

jobs:
determine-apps:
name: Determine Apps to Build
runs-on: ubuntu-latest
outputs:
apps: ${{ steps.set-apps.outputs.apps }}

steps:
- name: Set apps matrix
id: set-apps
run: |
if [ "${{ github.event.inputs.apps }}" == "all" ] || [ "${{ github.event.inputs.apps }}" == "" ]; then
echo 'apps=["admin","account-manager","branch-manager","cashier"]' >> $GITHUB_OUTPUT
else
APPS=$(echo "${{ github.event.inputs.apps }}" | jq -R 'split(",") | map(. | gsub(" "; ""))')
echo "apps=$APPS" >> $GITHUB_OUTPUT
fi

build-and-push:
name: Build and Push ${{ matrix.app }}
runs-on: ubuntu-latest
needs: determine-apps

strategy:
matrix:
app: ${{ fromJson(needs.determine-apps.outputs.apps) }}
fail-fast: false

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
run: |
# Extract branch name
BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
echo "branch=$BRANCH" >> $GITHUB_OUTPUT

# Extract git hashes
SHORT_SHA=$(git rev-parse --short HEAD)
LONG_SHA=$(git rev-parse HEAD)
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
echo "long_sha=$LONG_SHA" >> $GITHUB_OUTPUT

# Determine image tags
if [ "$BRANCH" == "develop" ]; then
TAGS="develop,$SHORT_SHA,$LONG_SHA"
elif [ "$BRANCH" == "main" ]; then
TAGS="main,$SHORT_SHA,$LONG_SHA"
else
SAFE_BRANCH=$(echo "$BRANCH" | sed 's/[^a-zA-Z0-9._-]/-/g')
TAGS="$SAFE_BRANCH,$SHORT_SHA"
fi

echo "tags=$TAGS" >> $GITHUB_OUTPUT
echo "Image tags: $TAGS"

- name: Build and push ${{ matrix.app }} image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.${{ matrix.app }}
push: true
tags: |
${{ env.REGISTRY }}/adorsys-gis/fineract-${{ matrix.app }}-app:${{ steps.meta.outputs.short_sha }}
${{ env.REGISTRY }}/adorsys-gis/fineract-${{ matrix.app }}-app:${{ steps.meta.outputs.branch }}
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ steps.meta.outputs.long_sha }}
org.opencontainers.image.created=${{ github.event.repository.updated_at }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Generate build summary
run: |
echo "### ${{ matrix.app }} Image Built Successfully! 🎉" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Registry**: \`${{ env.REGISTRY }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Repository**: \`adorsys-gis/fineract-${{ matrix.app }}-app\`" >> $GITHUB_STEP_SUMMARY
echo "**Tags**: \`${{ steps.meta.outputs.tags }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Pull Command**:" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
echo "docker pull ${{ env.REGISTRY }}/adorsys-gis/fineract-${{ matrix.app }}-app:${{ steps.meta.outputs.short_sha }}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY

trigger-gitops-update:
name: Trigger GitOps Update
needs: build-and-push
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main'
runs-on: ubuntu-latest

steps:
- name: Trigger GitOps repo update
run: |
echo "🔄 GitOps update workflow would be triggered here"
echo "This requires implementing update-gitops-repo workflow"
echo "For now, update GitOps repo manually or implement automation"

echo "### GitOps Update Required" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Frontend images have been published. To deploy:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "1. Update image tags in \`fineract-gitops\` repository" >> $GITHUB_STEP_SUMMARY
echo "2. Commit changes to trigger ArgoCD sync" >> $GITHUB_STEP_SUMMARY
echo "3. Monitor deployment in ArgoCD UI" >> $GITHUB_STEP_SUMMARY
44 changes: 44 additions & 0 deletions Dockerfile.account-manager
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Multi-stage build for Fineract Account Manager App
# Stage 1: Build the application
FROM node:22-alpine AS builder

WORKDIR /app

# Copy workspace configuration files
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./

# Copy shared packages
COPY packages/ ./packages/

# Copy account manager app source
COPY frontend/account-manager-app/ ./frontend/account-manager-app/

# Install pnpm and dependencies
RUN corepack enable pnpm && \
pnpm install --frozen-lockfile

# Build the account manager app
RUN pnpm --filter account-manager-app build

# Stage 2: Serve with Nginx
FROM nginx:alpine

# Copy built assets from builder stage
COPY --from=builder /app/frontend/account-manager-app/dist /usr/share/nginx/html

# Nginx config and env-config.js will be mounted via ConfigMaps in Kubernetes
# For local development, create a basic nginx config
RUN echo 'server { listen 80; root /usr/share/nginx/html; index index.html; location / { try_files $uri $uri/ /index.html; } }' > /etc/nginx/conf.d/default.conf

# Create health check file
RUN echo "healthy" > /usr/share/nginx/html/health

# Expose port
EXPOSE 80

# Add health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost/health || exit 1

# Run nginx
CMD ["nginx", "-g", "daemon off;"]
44 changes: 44 additions & 0 deletions Dockerfile.admin
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Multi-stage build for Fineract Admin App
# Stage 1: Build the application
FROM node:22-alpine AS builder

WORKDIR /app

# Copy workspace configuration files
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./

# Copy shared packages
COPY packages/ ./packages/

# Copy admin app source
COPY frontend/admin-app/ ./frontend/admin-app/

# Install pnpm and dependencies
RUN corepack enable pnpm && \
pnpm install --frozen-lockfile

# Build the admin app
RUN pnpm --filter admin-app build

# Stage 2: Serve with Nginx
FROM nginx:alpine

# Copy built assets from builder stage
COPY --from=builder /app/frontend/admin-app/dist /usr/share/nginx/html

# Nginx config and env-config.js will be mounted via ConfigMaps in Kubernetes
# For local development, create a basic nginx config
RUN echo 'server { listen 80; root /usr/share/nginx/html; index index.html; location / { try_files $uri $uri/ /index.html; } }' > /etc/nginx/conf.d/default.conf

# Create health check file
RUN echo "healthy" > /usr/share/nginx/html/health

# Expose port
EXPOSE 80

# Add health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost/health || exit 1

# Run nginx
CMD ["nginx", "-g", "daemon off;"]
44 changes: 44 additions & 0 deletions Dockerfile.branch-manager
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Multi-stage build for Fineract Branch Manager App
# Stage 1: Build the application
FROM node:22-alpine AS builder

WORKDIR /app

# Copy workspace configuration files
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./

# Copy shared packages
COPY packages/ ./packages/

# Copy branch manager app source
COPY frontend/branchmanager-app/ ./frontend/branchmanager-app/

# Install pnpm and dependencies
RUN corepack enable pnpm && \
pnpm install --frozen-lockfile

# Build the branch manager app
RUN pnpm --filter branchmanager-app build

# Stage 2: Serve with Nginx
FROM nginx:alpine

# Copy built assets from builder stage
COPY --from=builder /app/frontend/branchmanager-app/dist /usr/share/nginx/html

# Nginx config and env-config.js will be mounted via ConfigMaps in Kubernetes
# For local development, create a basic nginx config
RUN echo 'server { listen 80; root /usr/share/nginx/html; index index.html; location / { try_files $uri $uri/ /index.html; } }' > /etc/nginx/conf.d/default.conf

# Create health check file
RUN echo "healthy" > /usr/share/nginx/html/health

# Expose port
EXPOSE 80

# Add health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost/health || exit 1

# Run nginx
CMD ["nginx", "-g", "daemon off;"]
Loading
Loading