Merge pull request 'migration/reorg' (#124) from migration/reorg into stg

Reviewed-on: cmc/cmc-sales#124
This commit is contained in:
finley 2025-11-22 17:36:31 -08:00
commit 352ee4cfcd
2725 changed files with 1330 additions and 60 deletions

3
.gitignore vendored
View file

@ -2,6 +2,8 @@ app/tmp/*
*.tar.gz *.tar.gz
*.swp *.swp
*.swo *.swo
.env.prod
.env.stg
app/vendors/tcpdf/cache/* app/vendors/tcpdf/cache/*
app/tests/* app/tests/*
app/emails/* app/emails/*
@ -11,3 +13,4 @@ app/vaultmsgs/*
app/cake_eclipse_helper.php app/cake_eclipse_helper.php
app/webroot/pdf/* app/webroot/pdf/*
app/webroot/attachments_files/* app/webroot/attachments_files/*
backups/*

View file

@ -6,8 +6,8 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
CMC Sales is a B2B sales management system for CMC Technologies. The codebase consists of: CMC Sales is a B2B sales management system for CMC Technologies. The codebase consists of:
- **Legacy CakePHP 1.2.5 application** (2008-era) - Primary business logic - **Legacy CakePHP 1.2.5 application** (in `/php/`) - Primary business logic
- **Modern Go API** (in `/go-app/`) - New development using sqlc and Gorilla Mux - **Modern Go API** (in `/go/`) - New development using sqlc and Gorilla Mux
**Note**: Documentation also references a Django application that is not present in the current codebase. **Note**: Documentation also references a Django application that is not present in the current codebase.
@ -42,7 +42,7 @@ gunzip < backups/backup_*.sql.gz | mariadb -h 127.0.0.1 -u cmc -p cmc
### Go Application Development ### Go Application Development
```bash ```bash
# Navigate to Go app directory # Navigate to Go app directory
cd go-app cd go
# Configure private module access (first time only) # Configure private module access (first time only)
go env -w GOPRIVATE=code.springupsoftware.com go env -w GOPRIVATE=code.springupsoftware.com
@ -80,7 +80,7 @@ make build
### Go Application (Modern) ### Go Application (Modern)
- **Framework**: Gorilla Mux (HTTP router) - **Framework**: Gorilla Mux (HTTP router)
- **Database**: sqlc for type-safe SQL queries - **Database**: sqlc for type-safe SQL queries
- **Location**: `/go-app/` - **Location**: `/go/`
- **Structure**: - **Structure**:
- `cmd/server/` - Main application entry point - `cmd/server/` - Main application entry point
- `internal/cmc/handlers/` - HTTP request handlers - `internal/cmc/handlers/` - HTTP request handlers

View file

@ -2,20 +2,22 @@ FROM golang:1.24-alpine AS builder
RUN apk add --no-cache git RUN apk add --no-cache git
WORKDIR /app WORKDIR /app
COPY go-app/go.mod go-app/go.sum ./ COPY go/go.mod go/go.sum ./
RUN go mod download RUN go mod download
COPY go-app/ . COPY go/ .
RUN go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest RUN go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
RUN sqlc generate RUN sqlc generate
RUN go mod tidy RUN go mod tidy
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o server cmd/server/main.go RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o server cmd/server/main.go
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o vault cmd/vault/main.go
FROM alpine:latest FROM alpine:latest
RUN apk --no-cache add ca-certificates tzdata RUN apk --no-cache add ca-certificates tzdata
WORKDIR /root/ WORKDIR /root/
COPY --from=builder /app/server . COPY --from=builder /app/server .
COPY go-app/templates ./templates COPY --from=builder /app/vault .
COPY go-app/static ./static COPY go/templates ./templates
COPY go-app/.env.example .env COPY go/static ./static
COPY go/.env.example .env
EXPOSE 8082 EXPOSE 8082
CMD ["./server"] CMD ["./server"]

View file

@ -35,12 +35,11 @@ RUN chmod +x /bin/ripmime \
&& a2enmod headers && a2enmod headers
# Copy site into place. # Copy site into place.
ADD . /var/www/cmc-sales ADD php/ /var/www/cmc-sales
ADD app/config/database.php /var/www/cmc-sales/app/config/database.php ADD php/app/config/database.php /var/www/cmc-sales/app/config/database.php
RUN mkdir /var/www/cmc-sales/app/tmp RUN mkdir /var/www/cmc-sales/app/tmp
RUN mkdir /var/www/cmc-sales/app/tmp/logs RUN mkdir /var/www/cmc-sales/app/tmp/logs
RUN chmod -R 755 /var/www/cmc-sales/app/tmp RUN chmod -R 755 /var/www/cmc-sales/app/tmp
RUN chmod +x /var/www/cmc-sales/run_vault.sh
# Ensure CakePHP tmp directory is writable by web server # Ensure CakePHP tmp directory is writable by web server
RUN chmod -R 777 /var/www/cmc-sales/app/tmp RUN chmod -R 777 /var/www/cmc-sales/app/tmp

View file

@ -2,9 +2,9 @@ FROM golang:1.24-alpine AS builder
RUN apk add --no-cache git RUN apk add --no-cache git
WORKDIR /app WORKDIR /app
COPY go-app/go.mod go-app/go.sum ./ COPY go/go.mod go/go.sum ./
RUN go mod download RUN go mod download
COPY go-app/ . COPY go/ .
RUN go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest RUN go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
RUN sqlc generate RUN sqlc generate
RUN go mod tidy RUN go mod tidy
@ -14,8 +14,8 @@ FROM alpine:latest
RUN apk --no-cache add ca-certificates tzdata RUN apk --no-cache add ca-certificates tzdata
WORKDIR /root/ WORKDIR /root/
COPY --from=builder /app/server . COPY --from=builder /app/server .
COPY go-app/templates ./templates COPY go/templates ./templates
COPY go-app/static ./static COPY go/static ./static
COPY go-app/.env.example .env COPY go/.env.example .env
EXPOSE 8082 EXPOSE 8082
CMD ["./server"] CMD ["./server"]

View file

@ -54,12 +54,11 @@ RUN chmod +x /bin/ripmime \
&& a2enmod headers && a2enmod headers
# Copy site into place. # Copy site into place.
ADD . /var/www/cmc-sales ADD php/ /var/www/cmc-sales
ADD app/config/database_stg.php /var/www/cmc-sales/app/config/database.php ADD php/app/config/database_stg.php /var/www/cmc-sales/app/config/database.php
RUN mkdir -p /var/www/cmc-sales/app/tmp RUN mkdir -p /var/www/cmc-sales/app/tmp
RUN mkdir -p /var/www/cmc-sales/app/tmp/logs RUN mkdir -p /var/www/cmc-sales/app/tmp/logs
RUN chmod -R 755 /var/www/cmc-sales/app/tmp RUN chmod -R 755 /var/www/cmc-sales/app/tmp
RUN chmod +x /var/www/cmc-sales/run_vault.sh
# Ensure CakePHP tmp directory is writable by web server # Ensure CakePHP tmp directory is writable by web server
RUN chmod -R 777 /var/www/cmc-sales/app/tmp RUN chmod -R 777 /var/www/cmc-sales/app/tmp

View file

@ -3,20 +3,20 @@ services:
image: boky/postfix image: boky/postfix
restart: unless-stopped restart: unless-stopped
container_name: cmc-prod-postfix container_name: cmc-prod-postfix
# Staging: relay to Mailpit (no authentication required) env_file:
- .env.prod
# Production: relay to Gmail SMTP
environment: environment:
- RELAYHOST=mailpit:1025
- ALLOWED_SENDER_DOMAINS=cmctechnologies.com.au - ALLOWED_SENDER_DOMAINS=cmctechnologies.com.au
# --- Gmail SMTP relay settings (uncomment for production) --- # Gmail SMTP relay settings
# - RELAYHOST=smtp-relay.gmail.com - RELAYHOST=smtp-relay.gmail.com
# - RELAYHOST_PORT=587 - RELAYHOST_PORT=587
# - SMTP_USERNAME=sales # SMTP_USERNAME and SMTP_PASSWORD are loaded from .env.prod via env_file
# - SMTP_PASSWORD=S%s'mMZ})MGsg$k!5N|mPSQ> - SMTP_TLS_SECURITY_LEVEL=encrypt
# - SMTP_TLS_SECURITY_LEVEL=encrypt - SMTP_USE_TLS=yes
# - SMTP_USE_TLS=yes - SMTP_USE_STARTTLS=yes
# - SMTP_USE_STARTTLS=yes # --- Mailpit relay (for testing only) ---
ports: # - RELAYHOST=mailpit:1025
- "25:25"
networks: networks:
- cmc-prod-network - cmc-prod-network
nginx: nginx:
@ -81,6 +81,9 @@ services:
- "8083:8082" - "8083:8082"
volumes: volumes:
- /home/cmc/files/pdf:/root/webroot/pdf:ro - /home/cmc/files/pdf:/root/webroot/pdf:ro
- /home/cmc/files/emails:/var/www/emails
- /home/cmc/files/vault:/var/www/vault
- /home/cmc/files/vaultmsgs:/var/www/vaultmsgs
networks: networks:
- cmc-prod-network - cmc-prod-network
restart: unless-stopped restart: unless-stopped

View file

@ -22,24 +22,24 @@ services:
depends_on: depends_on:
- db - db
volumes: volumes:
- ./app/webroot/pdf:/var/www/cmc-sales/app/webroot/pdf - ./php/app/webroot/pdf:/var/www/cmc-sales/app/webroot/pdf
- ./app/webroot/attachments_files:/var/www/cmc-sales/app/webroot/attachments_files - ./php/app/webroot/attachments_files:/var/www/cmc-sales/app/webroot/attachments_files
networks: networks:
- cmc-network - cmc-network
restart: unless-stopped restart: unless-stopped
develop: develop:
watch: watch:
- action: rebuild - action: rebuild
path: ./app path: ./php/app
ignore: ignore:
- ./app/webroot/pdf - ./php/app/webroot/pdf
- ./app/webroot/attachments_files - ./php/app/webroot/attachments_files
- ./app/tmp - ./php/app/tmp
- action: sync - action: sync
path: ./app/webroot/css path: ./php/app/webroot/css
target: /var/www/cmc-sales/app/webroot/css target: /var/www/cmc-sales/app/webroot/css
- action: sync - action: sync
path: ./app/webroot/js path: ./php/app/webroot/js
target: /var/www/cmc-sales/app/webroot/js target: /var/www/cmc-sales/app/webroot/js
db: db:
@ -75,9 +75,9 @@ services:
ports: ports:
- "8080:8080" - "8080:8080"
volumes: volumes:
- ./go-app:/app - ./go:/app
- ./go-app/.air.toml:/root/.air.toml - ./go/.air.toml:/root/.air.toml
- ./go-app/.env.example:/root/.env - ./go/.env.example:/root/.env
networks: networks:
- cmc-network - cmc-network
restart: unless-stopped restart: unless-stopped

View file

View file

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Some files were not shown because too many files have changed in this diff Show more