Skip to main content

Infra Setup Guide

This guide helps you set up, run, and manage the infra app in your local development environment.

Folder Structure

The infra app is located at:


apps/infra
├── README.md
├── ansible
│   ├── agent
│   ├── createvm
│   ├── deletevm
│   ├── postgres
│   └── workspace
├── docker-compose.yml
├── dredd-hooks.js
├── dredd.yml
├── infra.md
├── logs
├── loki-config.dev.yml
├── loki-config.prod.yml
├── nest-cli.json
├── openapitools.json
├── package.json
├── prometheus.yml
├── promtail-config.yml
├── sdk-config.json
├── sdk-tsconfig.json
├── src
│   ├── ansible
│   ├── api
│   ├── app.module.ts
│   ├── background
│   ├── common
│   ├── config
│   ├── db
│   ├── interceptors
│   ├── logger
│   ├── main.ts
│   ├── middlewares
│   └── redis
├── test
│   ├── app.e2e-spec.ts
│   └── jest-e2e.json
├── tsconfig.build.json
└── tsconfig.json

Make sure you review the .env.example file and update the actual .env file as needed after setup.


Setup Instructions

To set up the infra app and its dependencies:

./setup.sh

This will:

  • Copy .env.example to .env for multiple apps including infra
  • Install all project dependencies via yarn install
  • Start global services (e.g. MySQL, Redis, etc.)
  • Run Prisma setup for infra and central apps

Start Infra (with PM2)

To start the infra app along with others using PM2:

./start.sh

This will:

  • Start all apps including infra in watch mode using PM2
  • Launch global services (if not already running)

You can access Infra at:

http://localhost:13001

Stop Infra and All Apps

To gracefully stop all running apps and services:

./stop.sh

This will:

  • Stop and delete PM2 processes for all apps
  • Bring down global services (Docker containers)

Viewing Logs

To view logs specifically for the infra app:

yarn infra:dev:logs

Notes

  • Ensure you have yarn and Docker installed locally.
  • The .env file is required to run the app. If missing, rerun ./setup.sh.

Environment Variables

Create a .env file inside the apps/infra directory by copying the provided .env.example file:

cp apps/infra/.env.example apps/infra/.env

Then update the variables as needed. Here's a reference of the important environment variables used by the Infra service:

# Development/Local Environment
AGENT_ENV=local
NODE_ENV=development

# GitLab Configuration
GITLAB_BASE_URL=https://builder-git.geekyants.com/api/v4
GITLAB_TOKEN=random-token
GITLAB_SOURCE_GROUP_ID=3
GITLAB_TARGET_GROUP_ID=5

# Server Port
PORT=13001

# Loki (Logging)
LOKI_PORT=13100
LOKI_HOST=http://localhost:13100
LOKI_API_TOKEN=admin

# Nexus Configuration
NEXUS_BASE_URL=https://nexus.blr0.geekydev.com
NEXUS_REGISTRY_URL=https://nexus-docker-hosted.blr0.geekydev.com
NEXUS_USERNAME=admin
NEXUS_PASSWORD=random-password

# Caddy Remote Access
CADDY_HOST=IP_ADDRESS
CADDY_PORT=10022
CADDY_USER=root

# API Token for Internal Use
API_TOKEN=your-super-secret-token

# SSH Configuration
WORKSPACE_PVT_SSH_KEY_PATH="/Users/user/.ssh/id_rsa"
MASTER_PUBLIC_SSH_KEY="ssh-rsa AAAAB3NzaC1..."

# VM Service
VM_API_TOKEN=random_token
VM_API_BASE_URL=http://IP_ADDRESS:3000/api/vms

# MySQL Configuration
MYSQL_DATABASE=infra_api
MYSQL_USER=root
MYSQL_PASSWORD=goldtree9
MYSQL_ROOT_PASSWORD=goldtree9
MYSQL_PORT=13306
MYSQL_HOST=127.0.0.1
DATABASE_URL="mysql://root:goldtree9@127.0.0.1:13306/infra_api"

# Redis Configuration
REDIS_HOST=127.0.0.1
REDIS_PORT=16379
REDIS_PASSWORD=goldtree9
REDIS_TLS_ENABLED=false

# Optional: SSH Keys for Agent
AGENT_CLONE_PVT_KEY1="-----BEGIN OPENSSH PRIVATE KEY-----\n...<snipped>...\n-----END OPENSSH PRIVATE KEY-----"
AGENT_CLONE_PVT_KEY=""

Note: Never commit .env files with secrets or tokens to version control. Keep them safe and secure.