Go to file
2025-11-23 16:09:25 +11:00
conf Adding apache vhost config change 2025-11-20 01:04:54 +11:00
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
php Hopefully fix attachments directory misconfig 2025-11-23 16:09:25 +11:00
scripts Merge branch 'prod' 2025-11-23 13:52:48 +11:00
sql Implement PO revisions 2025-06-23 08:19:11 +10:00
.gitignore Enabling rclone for db backup, changing to master branch for prod deploy, archiving migration scripts, adding backups/ to gitignore 2025-11-23 12:08:10 +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 Fix vault attachments filepath 2025-11-23 13:51:11 +11:00
docker-compose.stg.yml Fixing emails mounts 2025-11-20 21:32:52 +11:00
docker-compose.yml 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.db Removing startup scripts from db 2025-11-20 00:22:33 +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 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
userpasswd Add Jonathan to userpasswd 2025-11-19 18:26:22 +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