Initial commit for iiEasy: all files included

This commit is contained in:
2026-02-03 23:16:16 +05:00
commit 3b3d29e21c
158 changed files with 32962 additions and 0 deletions

81
nomad/README.md Normal file
View File

@@ -0,0 +1,81 @@
# iiEasy Nomad Deployment
## Prerequisites
1. **Nomad cluster** at 192.168.1.16 (or your host)
2. **Nomad client** with Docker driver and host volumes configured
3. **SSH access** to the Nomad node for image transfer
## Setup
### 1. Configure host volumes on Nomad client
Add to your Nomad client config (e.g. `/etc/nomad.d/nomad.hcl`):
```hcl
host_volume "iieasy-postgres-data" {
path = "/opt/nomad/iieasy/postgres-data"
read_only = false
}
host_volume "iieasy-strapi-uploads" {
path = "/opt/nomad/iieasy/uploads"
read_only = false
}
```
Create directories and restart Nomad client:
```bash
sudo mkdir -p /opt/nomad/iieasy/postgres-data /opt/nomad/iieasy/uploads
sudo chmod -R 755 /opt/nomad/iieasy
# Restart Nomad client
```
### 2. Environment variables
```bash
export NOMAD_ADDR=http://192.168.1.16:4646
export NOMAD_HOST=192.168.1.16
export NOMAD_USER=its
export STRAPI_PUBLIC_URL=http://192.168.1.16:1337 # URL for browser API calls
```
Use SSH key authentication or enter password when `scp`/`ssh` prompts.
### 3. Deploy
```bash
chmod +x deploy-nomad.sh
./deploy-nomad.sh
```
## Manual steps
If the deploy script fails or you prefer manual control:
```bash
# Build images
docker build --build-arg VITE_STRAPI_URL=http://192.168.1.16:1337 -t iieasy-frontend:latest .
docker build -t iieasy-strapi:latest ./iiEasy
# Copy to Nomad node
docker save iieasy-frontend:latest iieasy-strapi:latest -o /tmp/iieasy-images.tar
scp /tmp/iieasy-images.tar its@192.168.1.16:/tmp/
# On Nomad node
ssh its@192.168.1.16
docker load -i /tmp/iieasy-images.tar
# From your machine (with Nomad CLI)
export NOMAD_ADDR=http://192.168.1.16:4646
nomad job run nomad/iieasy.nomad.hcl
```
## Access
- Frontend: http://192.168.1.16:3000
- Strapi Admin: http://192.168.1.16:1337/admin
- PostgreSQL: 192.168.1.16:5432 (internal use)
Check status: `nomad job status iieasy`

View File

@@ -0,0 +1,12 @@
# Add this to your Nomad client config (e.g. /etc/nomad.d/nomad.hcl)
# or create a separate file in /etc/nomad.d/conf.d/
host_volume "iieasy-postgres-data" {
path = "/opt/nomad/iieasy/postgres-data"
read_only = false
}
host_volume "iieasy-strapi-uploads" {
path = "/opt/nomad/iieasy/uploads"
read_only = false
}

170
nomad/iieasy.nomad.hcl Normal file
View File

@@ -0,0 +1,170 @@
# iiEasy Nomad Job
# Deploy: nomad job run -var "nomad_host=192.168.1.16" nomad/iieasy.nomad.hcl
variables {
# Docker image names (must exist on Nomad node - build via deploy-nomad.sh)
frontend_image = "iieasy-frontend:latest"
strapi_image = "iieasy-strapi:latest"
datacenter = "dc1"
}
job "iieasy" {
datacenters = [var.datacenter]
type = "service"
group "postgres" {
count = 1
volume "postgres_data" {
type = "host"
source = "iieasy-postgres-data"
read_only = false
}
network {
port "db" {
static = 5432
}
}
service {
name = "iieasy-postgres"
port = "db"
provider = "nomad"
check {
type = "script"
name = "postgres-ready"
command = "pg_isready"
args = ["-U", "strapi"]
interval = "5s"
timeout = "5s"
}
}
task "postgres" {
driver = "docker"
config {
image = "postgres:16-alpine"
ports = ["db"]
}
env {
POSTGRES_USER = "strapi"
POSTGRES_PASSWORD = "strapi"
POSTGRES_DB = "strapi"
}
volume_mount {
volume = "postgres_data"
destination = "/var/lib/postgresql/data"
read_only = false
}
resources {
cpu = 256
memory = 512
}
}
}
group "strapi" {
count = 1
volume "strapi_uploads" {
type = "host"
source = "iieasy-strapi-uploads"
read_only = false
}
network {
port "http" {
static = 1337
}
}
service {
name = "iieasy-strapi"
port = "http"
provider = "nomad"
}
task "strapi" {
driver = "docker"
config {
image = var.strapi_image
ports = ["http"]
}
template {
data = <<EOF
{{- with index (nomadService "iieasy-postgres") 0 }}
DATABASE_HOST={{ .Address }}
DATABASE_PORT={{ .Port }}
{{- end }}
EOF
destination = "local/db.env"
env = true
}
env {
HOST = "0.0.0.0"
PORT = "1337"
DATABASE_CLIENT = "postgres"
DATABASE_NAME = "strapi"
DATABASE_USERNAME = "strapi"
DATABASE_PASSWORD = "strapi"
APP_KEYS = "toBeModified1,toBeModified2"
API_TOKEN_SALT = "tobemodified"
ADMIN_JWT_SECRET = "tobemodified"
TRANSFER_TOKEN_SALT = "tobemodified"
JWT_SECRET = "tobemodified"
ENCRYPTION_KEY = "tobemodified"
}
volume_mount {
volume = "strapi_uploads"
destination = "/app/public/uploads"
read_only = false
}
resources {
cpu = 512
memory = 1024
}
}
}
group "frontend" {
count = 1
network {
port "http" {
static = 3000
to = 80
}
}
service {
name = "iieasy-frontend"
port = "http"
provider = "nomad"
}
task "frontend" {
driver = "docker"
config {
image = var.frontend_image
ports = ["http"]
}
resources {
cpu = 128
memory = 64
}
}
}
}