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
*.swp
*.swo
.env.prod
.env.stg
app/vendors/tcpdf/cache/*
app/tests/*
app/emails/*
@ -11,3 +13,4 @@ app/vaultmsgs/*
app/cake_eclipse_helper.php
app/webroot/pdf/*
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:
- **Legacy CakePHP 1.2.5 application** (2008-era) - Primary business logic
- **Modern Go API** (in `/go-app/`) - New development using sqlc and Gorilla Mux
- **Legacy CakePHP 1.2.5 application** (in `/php/`) - Primary business logic
- **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.
@ -42,7 +42,7 @@ gunzip < backups/backup_*.sql.gz | mariadb -h 127.0.0.1 -u cmc -p cmc
### Go Application Development
```bash
# Navigate to Go app directory
cd go-app
cd go
# Configure private module access (first time only)
go env -w GOPRIVATE=code.springupsoftware.com
@ -80,7 +80,7 @@ make build
### Go Application (Modern)
- **Framework**: Gorilla Mux (HTTP router)
- **Database**: sqlc for type-safe SQL queries
- **Location**: `/go-app/`
- **Location**: `/go/`
- **Structure**:
- `cmd/server/` - Main application entry point
- `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
WORKDIR /app
COPY go-app/go.mod go-app/go.sum ./
COPY go/go.mod go/go.sum ./
RUN go mod download
COPY go-app/ .
COPY go/ .
RUN go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
RUN sqlc generate
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 vault cmd/vault/main.go
FROM alpine:latest
RUN apk --no-cache add ca-certificates tzdata
WORKDIR /root/
COPY --from=builder /app/server .
COPY go-app/templates ./templates
COPY go-app/static ./static
COPY go-app/.env.example .env
COPY --from=builder /app/vault .
COPY go/templates ./templates
COPY go/static ./static
COPY go/.env.example .env
EXPOSE 8082
CMD ["./server"]

View file

@ -35,12 +35,11 @@ RUN chmod +x /bin/ripmime \
&& a2enmod headers
# Copy site into place.
ADD . /var/www/cmc-sales
ADD app/config/database.php /var/www/cmc-sales/app/config/database.php
ADD php/ /var/www/cmc-sales
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/logs
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
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
WORKDIR /app
COPY go-app/go.mod go-app/go.sum ./
COPY go/go.mod go/go.sum ./
RUN go mod download
COPY go-app/ .
COPY go/ .
RUN go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
RUN sqlc generate
RUN go mod tidy
@ -14,8 +14,8 @@ FROM alpine:latest
RUN apk --no-cache add ca-certificates tzdata
WORKDIR /root/
COPY --from=builder /app/server .
COPY go-app/templates ./templates
COPY go-app/static ./static
COPY go-app/.env.example .env
COPY go/templates ./templates
COPY go/static ./static
COPY go/.env.example .env
EXPOSE 8082
CMD ["./server"]

View file

@ -54,12 +54,11 @@ RUN chmod +x /bin/ripmime \
&& a2enmod headers
# Copy site into place.
ADD . /var/www/cmc-sales
ADD app/config/database_stg.php /var/www/cmc-sales/app/config/database.php
ADD php/ /var/www/cmc-sales
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/logs
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
RUN chmod -R 777 /var/www/cmc-sales/app/tmp

View file

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

View file

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