| app | ||
| cake | ||
| conf | ||
| deploy | ||
| go-app | ||
| sql | ||
| vendors | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| .htaccess | ||
| CLAUDE.md | ||
| deploy-production.sh | ||
| deploy.sh | ||
| DEPLOYMENT-CADDY.md | ||
| DEPLOYMENT.md | ||
| docker-compose.caddy-production.yml | ||
| docker-compose.caddy-staging-ubuntu.yml | ||
| docker-compose.caddy-staging.yml | ||
| docker-compose.prod.yml | ||
| docker-compose.production.yml | ||
| docker-compose.proxy.yml | ||
| docker-compose.staging.yml | ||
| docker-compose.stg.yml | ||
| docker-compose.yml | ||
| Dockerfile | ||
| Dockerfile.go.production | ||
| Dockerfile.go.staging | ||
| Dockerfile.local.go | ||
| Dockerfile.prod.db | ||
| Dockerfile.prod.go | ||
| Dockerfile.prod.php | ||
| Dockerfile.stg.db | ||
| Dockerfile.stg.go | ||
| Dockerfile.stg.php | ||
| Dockerfile.ubuntu-php | ||
| enter_docker.sh | ||
| fetch_latest_sql.sh | ||
| index.php | ||
| Makefile | ||
| MIGRATION.md | ||
| README.md | ||
| refresh_data.sh | ||
| run_docker_local.sh | ||
| run_docker_prd.sh | ||
| run_docker_stg.sh | ||
| run_update_invoices.sh | ||
| run_vault.sh | ||
| stagingpasswd | ||
| start-development.sh | ||
| TESTING_DOCKER.md | ||
| userpasswd | ||
| vault_cron.sh | ||
cmc-sales
Development Setup
CMC Sales now runs both legacy CakePHP and modern Go applications side by side.
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: seeapp/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.legacywith Go 1.21 and sqlc v1.26.0
- Alternative: Use
Install a new server
(TODO this is all likely out of date)
Requirements
Debian or Ubuntu OS. These instructions written for Debian 9.9
Assumed pre-work:
Create a new VM with hostname newserver.cmctechnologies.com.au Configure DNS appropriately. cmctechnologies.com.au zones is currently managed in Google Cloud DNS on Karl's account: https://console.cloud.google.com/net-services/dns/zones/cmctechnologies?project=cmc-technologies&authuser=1&folder&organizationId
Will need to migrate that to CMC's GSuite account at some point.
- Install ansible on your workstation
apt-get install ansible
- Clone the playbooks
git clone git@gitlab.com:minimalist.software/cmc-playbooks.git
- Execute the playbooks
The nginx config expects the site to be available at sales.cmctechnologies.com.au.
You'll need to add the hostname to config/nginx-site, if this isn't sales.cmctechnologies.com.au
cd cmc-playbooks
# Add the hostname of your new server to the inventory.txt
ansible-playbook -i inventory.txt setup.yml
- SSH to the new server and configure gitlab-runner
ssh newserver.cmctechnologies.com.au
sudo gitlab-runner register
- SSH to the new server as cmc user
ssh cmc@newserver.cmctechnologies.com.au
- Add the SSH key to the cmc-sales repo on gitlab as a deploy key https://gitlab.com/minimalist.software/cmc-sales/-/settings/repository
cmc@cmc:~$ cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFIdoWVp2pGDb46ubW6jkfIpREMa/veD6xZVAtnj3WG1sX7NEUlQYq3RKbZ5CThlw6GKMSYoIsIqk7p6zSoJHGlJSLxoJ0edKflciMUFMTQrdm4T1USXsK+gd0C4DUCyVkYFOs37sy+JtziymnBTm7iOeVI3aMxwfoCOs6mNiD0ettjJT6WtVyy0ZTb6yU4uz7CHj1IGsvwsoKJWPGwJrZ/MfByNl6aJ8R/8zDwbtP06owKD4b3ZPgakM3nYRRoKzHZ/SClz50SXMKC4/nmFY9wLuuMhCWK+9x4/4VPSnxXESOlENMfUoa1IY4osAnZCtaFrWDyenJ+spZrNfgcscD ansible-generated on cmc
- Clone the cmc-sales repo
git clone git@gitlab.com:minimalist.software/cmc-sales.git
- As root on new server configure mySQL user cmc Note: get password from app/config/database.php (or set a new one and change it)
# mysql -u root
CREATE USER 'cmc'@'localhost' IDENTIFIED BY 'password';
CREATE USER 'cmc'@'172.17.0.2' IDENTIFIED BY 'password';
CREATE database cmc;
GRANT ALL PRIVILEGES ON cmc.* TO 'cmc'@'localhost';
GRANT ALL PRIVILEGES ON cmc.* TO 'cmc'@'172.17.0.2';
- Get the latest backup from Google Drive
In the shared google drive: eg. backups/database/backup_20191217_21001.sql.gz
Copy up to the new server:
rsync backup_*.gz root@newserver:~/
- Restore backup to cmc database
zcat backup_* | mysql -u cmc -p
-
Redeploy from Gitlab https://gitlab.com/minimalist.software/cmc-sales/pipelines/new
-
You should have a new installation of cmc-sales.
-
Seems new Linux kernels break the docker https://github.com/moby/moby/issues/28705
-
Mysql needs special args not to break
# /etc/mysql/my.cnf
sql_mode=ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION