Go to file
2026-02-09 20:44:30 +05:00
.github/workflows Fix EC2 deployment: use /home/ubuntu directory and add sudo for docker commands 2026-02-09 20:44:30 +05:00
Documents Set up JUNOHUB app and EC2 deployment 2026-02-09 20:12:52 +05:00
prisma Set up JUNOHUB app and EC2 deployment 2026-02-09 20:12:52 +05:00
public Set up JUNOHUB app and EC2 deployment 2026-02-09 20:12:52 +05:00
scripts Set up JUNOHUB app and EC2 deployment 2026-02-09 20:12:52 +05:00
src Fix Prisma type errors and TypeScript strict mode issues 2026-02-09 20:41:47 +05:00
.gitignore Set up JUNOHUB app and EC2 deployment 2026-02-09 20:12:52 +05:00
docker-compose.yml Refine Docker, docker-compose, and EC2 deploy 2026-02-09 20:17:26 +05:00
Dockerfile Exclude scripts from Next.js build and fix Dockerfile for proper build 2026-02-09 20:29:38 +05:00
eslint.config.mjs Set up JUNOHUB app and EC2 deployment 2026-02-09 20:12:52 +05:00
next.config.ts Set up JUNOHUB app and EC2 deployment 2026-02-09 20:12:52 +05:00
package-lock.json Fix build and Docker/EC2 deployment 2026-02-09 20:21:26 +05:00
package.json Fix build and Docker/EC2 deployment 2026-02-09 20:21:26 +05:00
postcss.config.mjs Set up JUNOHUB app and EC2 deployment 2026-02-09 20:12:52 +05:00
prisma.config.ts Set up JUNOHUB app and EC2 deployment 2026-02-09 20:12:52 +05:00
README.md Set up JUNOHUB app and EC2 deployment 2026-02-09 20:12:52 +05:00
tsconfig.json Exclude scripts from Next.js build and fix Dockerfile for proper build 2026-02-09 20:29:38 +05:00

JUNOHUB

JUNOHUB is a Next.js application that powers an admin and supplier portal with:

  • Authentication and multi-factor auth
  • Gmail integration for support tickets (Juno Engine)
  • Shopify integration for orders, products, and inventory
  • Knowledge base and FAQ management
  • Admin dashboards for stores, suppliers, and email events

The frontend and backend are implemented in a single Next.js App Router project.


Tech Stack

  • Framework: Next.js (App Router, TypeScript)
  • UI: React + modern Tailwind-style components
  • Auth: NextAuth
  • Database: PostgreSQL (Prisma ORM)
  • Background / Integrations:
    • Gmail APIs (via OAuth)
    • Shopify APIs
    • Gemini for embeddings and chat
  • Deployment: Docker + GitHub Actions → AWS EC2

Local Development

  1. Install dependencies
npm install
  1. Create .env

Copy .env.example (or the variables listed below) into a local .env file and fill in your own values:

  • DATABASE_URL
  • NEXTAUTH_SECRET
  • NEXTAUTH_URL
  • GOOGLE_CLIENT_ID
  • GOOGLE_CLIENT_SECRET
  • SMTP_HOST
  • SMTP_PORT
  • SMTP_SECURE
  • SMTP_USER
  • SMTP_PASSWORD
  • GEMINI_API_KEY
  • GEMINI_EMBEDDING_MODEL
  • GEMINI_CHAT_MODEL
  • ADMIN_EMAIL
  • ADMIN_PASSWORD

Never commit real secrets; .env* files are ignored by git.

  1. Run the dev server
npm run dev

Visit http://localhost:3000 in your browser.


Docker

The project can be run via Docker using the provided Dockerfile and docker-compose.yml.

Typical pattern:

docker compose up -d --build

Make sure your .env is present next to the app code so the container can read it.


CI/CD on AWS EC2

This repo includes a GitHub Actions workflow at .github/workflows/deploy-ec2.yml that:

  1. Runs on pushes to the main branch.
  2. Installs dependencies and builds the Next.js app.
  3. SSHes into an EC2 instance.
  4. Writes an .env file on the EC2 instance from a single GitHub secret EC2_ENV.
  5. Uses docker compose / docker-compose to build and run the app.
  6. Performs a health check and automatically rolls back to the previous commit if the deployment or health check fails.

Required GitHub Secrets

Set the following secrets in GitHub → Settings → Secrets and variables → Actions:

  • EC2_HOST – public IP or DNS of the EC2 instance.
  • EC2_USER – SSH user (e.g. ubuntu).
  • EC2_SSH_KEY – private SSH key for that user.
  • EC2_SSH_PORT – (optional) port, defaults to 22 if not set.
  • EC2_ENV – multi-line secret containing the full contents of the .env file used in production.
    This is written to .env on the server during deployment.

Deployment Flow

  • Push to main.
  • GitHub Actions:
    • Builds the app.
    • Connects to EC2.
    • Writes .env from EC2_ENV.
    • Runs docker compose up -d --build.
    • Hits the health check URL (by default http://localhost:3000/api/health).
  • If the health check fails, the workflow:
    • Resets the repo on EC2 to the previous commit.
    • Re-runs docker compose up -d --build.

This gives you a sharp deployment with an automatic rollback path.


License

Private / All rights reserved unless explicitly stated otherwise.