Go to file
2025-12-08 21:31:11 +11:00
conf Reworking attachment logic in Go, bumping Nginx max file upload size, fixing local dev env, changes to .gitignore 2025-12-08 20:39:45 +11:00
go Reworking attachment logic in Go, bumping Nginx max file upload size, fixing local dev env, changes to .gitignore 2025-12-08 20:39:45 +11:00
php Reworking attachment logic in Go, bumping Nginx max file upload size, fixing local dev env, changes to .gitignore 2025-12-08 20:39:45 +11:00
scripts Adding prune to deploy scripts to prevent docker resource overflowing 2025-12-07 18:10:33 +11:00
sql Implement PO revisions 2025-06-23 08:19:11 +10:00
.gitignore Reworking attachment logic in Go, bumping Nginx max file upload size, fixing local dev env, changes to .gitignore 2025-12-08 20:39:45 +11:00
CLAUDE.md Moving php and go into separate dirs, moving scripts into a central dir, updating files as necessary 2025-11-23 12:30:24 +11:00
docker-compose.prod.yml Adding new file mounts 2025-12-08 21:31:11 +11:00
docker-compose.stg.yml Adding new file mounts 2025-12-08 21:31:11 +11:00
docker-compose.yml Reworking attachment logic in Go, bumping Nginx max file upload size, fixing local dev env, changes to .gitignore 2025-12-08 20:39:45 +11:00
Dockerfile.local.go Getting local development running again 2025-12-03 22:21:12 +11:00
Dockerfile.local.php Reworking attachment logic in Go, bumping Nginx max file upload size, fixing local dev env, changes to .gitignore 2025-12-08 20:39:45 +11:00
Dockerfile.prod.db Set mariadb sql_mode for CakePHP compatibility 2025-11-24 10:28:07 +11:00
Dockerfile.prod.go Moving php and go into separate dirs, moving scripts into a central dir, updating files as necessary 2025-11-23 12:30:24 +11:00
Dockerfile.prod.php Adding -p flag to mkdir 2025-11-23 13:08:20 +11:00
Dockerfile.stg.db Removing startup scripts from db 2025-11-20 00:22:33 +11:00
Dockerfile.stg.go Moving php and go into separate dirs, moving scripts into a central dir, updating files as necessary 2025-11-23 12:30:24 +11:00
Dockerfile.stg.php Moving php and go into separate dirs, moving scripts into a central dir, updating files as necessary 2025-11-23 12:30:24 +11:00
README.md Adding README 2025-11-23 13:03:06 +11:00
stagingpasswd Add staging passwords 2020-07-14 20:27:07 +10:00
start-development.sh Getting local development running again 2025-12-03 22:21:12 +11:00
userpasswd Fix Jonathan password 2025-11-24 13:35:16 +11:00

cmc-sales

CMC Sales is a business management system with two applications:

  • PHP Application: CakePHP 1.2.5 (currently the primary application)
  • Go Application: Go + HTMX (used for select features, growing)

Future development should be done in the Go application wherever possible.

Architecture

Both applications:

  • Share the same MariaDB database
  • Run behind a shared Caddy reverse proxy with basic authentication
  • Support staging and production environments on the same server

The PHP application currently handles most functionality, while the Go application is used for select screens and new features as they're developed.

Development Setup

Quick Start

git clone git@code.springupsoftware.com:cmc/cmc-sales.git
cd cmc-sales

# Easy way - use the setup script
./start-development.sh

# Manual way
rsync -avz --progress cmc@sales.cmctechnologies.com.au:~/backups .
docker compose up --build
gunzip < backups/backup_*.sql.gz | mariadb -h 127.0.0.1 -u cmc -p cmc

Access Applications

Add to /etc/hosts:

127.0.0.1	cmclocal

Application URLs:

  • CakePHP (Legacy): http://cmclocal - Original CakePHP 1.2.5 application
  • Go (Modern): http://localhost:8080 - New Go application with HTMX frontend
  • Database: localhost:3306 (user: cmc, password: see app/config/database.php)

Architecture

  • cmc-php: Legacy CakePHP application (nginx proxied)
  • cmc-go: Modern Go application (direct access on port 8080)
  • db: Shared MariaDB database
  • nginx: Reverse proxy for CakePHP app

Both applications share the same database, allowing for gradual migration.

Requirements

  • Go Application: Requires Go 1.23+ (for latest sqlc)
    • Alternative: Use Dockerfile.go.legacy with Go 1.21 and sqlc v1.26.0

Deployment

Prerequisites

The deployment scripts use SSH to connect to the server. Configure your SSH config (~/.ssh/config) with a host entry named cmc pointing to the correct server:

Host cmc
    HostName node0.prd.springupsoftware.com
    User cmc
    IdentityFile ~/.ssh/cmc

Deployment Procedures

Deploy to staging or production using the scripts in the deploy/ directory:

Deploy to Staging:

./scripts/deploy/deploy-stg.sh

Deploy to Production:

./deploy/deploy-prod.sh

Rebuild without cache (useful after dependency changes):

./scripts/deploy/deploy-prod.sh --no-cache
./scripts/deploy/deploy-stg.sh --no-cache

How Deployment Works

  1. The deploy script connects to the server via the cmc SSH host
  2. Clones or updates the appropriate git branch (stg or prod)
  3. Creates environment configuration for the Go application
  4. Builds and starts Docker containers using the appropriate compose file
  5. Applications are accessible through Caddy reverse proxy with basic auth

Deployment Environments

Both environments run on the same server and share:

  • A single Caddy reverse proxy (handles HTTPS and basic authentication for both environments)
  • Separate Docker containers for each environment's PHP and Go applications
  • Separate MariaDB database instances