Go to file
2025-11-20 00:22:33 +11:00
app Merge branch 'master' into prod 2025-11-19 07:21:33 +11:00
cake Revert "Giant changes to make it work on php7" 2025-08-08 13:39:37 +10:00
conf Merge branch 'master' into prod 2025-11-19 07:21:33 +11:00
deploy moving to new server 2025-11-19 23:20:42 +11:00
go-app Merge branch 'master' into prod 2025-11-19 07:21:33 +11:00
sql Implement PO revisions 2025-06-23 08:19:11 +10:00
vendors Reworked repo structure. added cake 1.2 2013-03-23 16:25:52 +11:00
.gitignore Included config files in repos 2013-04-02 07:37:38 +11:00
.gitlab-ci.yml Restart prod container always. Remove staging from .gitlab-ci since it wasn't even running 2020-10-31 17:21:49 +11:00
.htaccess Turned off error reporting 2013-03-25 22:26:48 +11:00
CLAUDE.md Add the new go app 2025-06-24 20:32:28 +10:00
deploy-production.sh Change Tailscale auth header var name 2025-08-19 17:42:15 +10:00
deploy.sh Add scripts to make docker easier 2018-12-16 14:23:18 +11:00
DEPLOYMENT-CADDY.md Yolo changes to make this work 2025-08-08 11:24:48 +10:00
DEPLOYMENT.md Yolo changes to make this work 2025-08-08 11:24:48 +10:00
docker-compose.caddy-production.yml Add docker-compose.caddy and Makefile 2025-08-07 21:53:30 +10:00
docker-compose.caddy-staging-ubuntu.yml Revert "Giant changes to make it work on php7" 2025-08-08 13:39:37 +10:00
docker-compose.caddy-staging.yml Add docker-compose.caddy and Makefile 2025-08-07 21:53:30 +10:00
docker-compose.prod.yml Adding files mounts, adding go mod tidy in build 2025-11-20 00:10:42 +11:00
docker-compose.production.yml Yolo changes to make this work 2025-08-08 11:24:48 +10:00
docker-compose.proxy.yml Revert "Giant changes to make it work on php7" 2025-08-08 13:39:37 +10:00
docker-compose.staging.yml Yolo changes to make this work 2025-08-08 11:24:48 +10:00
docker-compose.stg.yml Fixing networks 2025-09-17 21:09:44 +10:00
docker-compose.yml Renaming / removing files for ease of deploying between all envs 2025-09-13 21:16:51 +10:00
Dockerfile Renaming / removing files for ease of deploying between all envs 2025-09-13 21:16:51 +10:00
Dockerfile.go.production Work on staging and vault 2025-08-05 07:50:12 +10:00
Dockerfile.go.staging Work on staging and vault 2025-08-05 07:50:12 +10:00
Dockerfile.local.go Renaming / removing files for ease of deploying between all envs 2025-09-13 21:16:51 +10:00
Dockerfile.prod.db Removing startup scripts from db 2025-11-20 00:22:33 +11:00
Dockerfile.prod.go Adding files mounts, adding go mod tidy in build 2025-11-20 00:10:42 +11:00
Dockerfile.prod.php Renaming / removing files for ease of deploying between all envs 2025-09-13 21:16:51 +10:00
Dockerfile.stg.db Removing startup scripts from db 2025-11-20 00:22:33 +11:00
Dockerfile.stg.go Adding install for tz info 2025-09-17 21:18:27 +10:00
Dockerfile.stg.php Renaming / removing files for ease of deploying between all envs 2025-09-13 21:16:51 +10:00
Dockerfile.ubuntu-php Revert "Giant changes to make it work on php7" 2025-08-08 13:39:37 +10:00
enter_docker.sh Add scripts to make docker easier 2018-12-16 14:23:18 +11:00
fetch_latest_sql.sh Add fetch_latest_sql.sh 2019-01-26 13:14:18 +11:00
index.php Revert "Giant changes to make it work on php7" 2025-08-08 13:39:37 +10:00
Makefile Various changes to make staging work 2025-08-08 11:22:06 +10:00
MIGRATION.md Bump PHP memory_limit to fix Quote edit page 2019-07-02 13:25:09 +10:00
README.md Add the new go app 2025-06-24 20:32:28 +10:00
refresh_data.sh Adding reminder cron job for email sending, adding ui to view expiring quotes, adding db refresh script 2025-07-17 23:35:30 +10:00
run_docker_local.sh Generate shipping instructions on PO views #73 2023-11-17 14:26:38 +11:00
run_docker_prd.sh Fix build and vault, hopefully 2022-01-05 14:29:01 +11:00
run_docker_stg.sh Trying --retart flag on staging 2020-10-31 17:17:17 +11:00
run_update_invoices.sh Add InvoiceShell to update old invoices for their invoiced_amount 2023-03-21 22:13:52 +11:00
run_vault.sh run vault as www-data user to fix permission problems 2019-07-04 21:13:28 +10:00
stagingpasswd Add staging passwords 2020-07-14 20:27:07 +10:00
start-development.sh Add Go app 2025-07-02 22:04:36 +10:00
TESTING_DOCKER.md Work on staging and vault 2025-08-05 07:50:12 +10:00
userpasswd Fix colleen passwd 2025-11-03 21:41:34 +11:00
vault_cron.sh Accounting for multiple containers on the one machine 2025-07-29 21:16:01 -07:00

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: 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

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.

  1. Install ansible on your workstation
apt-get install ansible
  1. Clone the playbooks
git clone git@gitlab.com:minimalist.software/cmc-playbooks.git
  1. 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
  1. SSH to the new server and configure gitlab-runner
ssh newserver.cmctechnologies.com.au
sudo gitlab-runner register
  1. SSH to the new server as cmc user
ssh cmc@newserver.cmctechnologies.com.au
  1. 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
  1. Clone the cmc-sales repo
git clone git@gitlab.com:minimalist.software/cmc-sales.git
  1. 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';
  1. 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:~/

  1. Restore backup to cmc database
zcat backup_* | mysql -u cmc -p
  1. Redeploy from Gitlab https://gitlab.com/minimalist.software/cmc-sales/pipelines/new

  2. You should have a new installation of cmc-sales.

  3. Seems new Linux kernels break the docker https://github.com/moby/moby/issues/28705

  4. 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