diff --git a/Makefile b/Makefile index a1dc6fc..9a466ab 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ HELM ?= helm HELM_CHART := deploy/helm/cms HELM_RELEASE ?= cms HELM_NAMESPACE ?= cms -KUBECONFIG ?= $(HOME)/.config/kubectl/rancher.urpi.local.yaml +KUBECONFIG ?= $(HOME)/.config/kubectl/rancher.urpi.be.yaml .PHONY: help ui frontend backend demo production run test check docker docker-push docker-run clean rancher-storage helm-lint helm-deploy-development helm-deploy-production diff --git a/README.md b/README.md index 4bcc605..4e41dcf 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ This repository contains a Go backend and React frontend for the CMS. ## Backend -The backend targets Go 1.27.1 and uses a layered design (`internal/web`, `service`, `repository`, `persistence`, `security`, and `domain`). A single PostgreSQL database stores content; Goose migrations run automatically at startup. +The backend targets Go 1.27.1 and uses a layered design (`internal/web`, +`service`, and `security`). Content is seeded in memory and can be mirrored to +a JSON file configured through `CMS_CONTENT_FILE`. ```sh go run ./cmd/server @@ -32,10 +34,33 @@ Content supports one reusable category per document plus any number of badges. T Editing requires the SSO identity: `PUT /api/content/:slug` returns `401` without it. `GET /api/content/:slug` and the taxonomy endpoints are public. ```sh -make up # start PostgreSQL -make migrate # apply the PostgreSQL migrations -make seed # load repeatable sample content make backend # run the Go server make frontend # run the React app -make dev # up + migrate + backend + frontend -``` \ No newline at end of file +make run # build the frontend, then run the server +``` + +## Rancher deployment + +The Helm chart at `deploy/helm/cms` provides two profiles: + +- `values-development.yaml` runs the demo profile on NodePort `30081` with + ephemeral content. +- `values-production.yaml` runs the seeded demo application on NodePort + `31373` with a persistent content volume. Host Nginx proxies `cms.urpi.be` + to this port. + +Validate or deploy either profile with: + +```sh +make helm-lint +make helm-deploy-development +make helm-deploy-production +``` + +The deploy workflow automatically deploys a successful `main` image build to +production and also supports manual development or production deployments. +Create GitHub environments named `development` and `production`. Each needs +the secrets `RANCHER_KUBE_CONFIG_BASE64`, `REGISTRY_USERNAME`, and +`REGISTRY_PASSWORD`. `CMS_SSO_TOKEN` is optional. Environment variables +`RANCHER_NAMESPACE`, `CMS_ALLOWED_ORIGINS`, `CMS_SSO_HEADER`, and +`CMS_SSO_COOKIE` can override the chart defaults. \ No newline at end of file diff --git a/deploy/helm/cms/templates/persistent-volume-claim.yaml b/deploy/helm/cms/templates/persistent-volume-claim.yaml new file mode 100644 index 0000000..6f04017 --- /dev/null +++ b/deploy/helm/cms/templates/persistent-volume-claim.yaml @@ -0,0 +1,17 @@ +{{- if .Values.persistence.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ include "cms.fullname" . }} + labels: + {{- include "cms.labels" . | nindent 4 }} +spec: + accessModes: + {{- toYaml .Values.persistence.accessModes | nindent 4 }} + {{- with .Values.persistence.storageClass }} + storageClassName: {{ . | quote }} + {{- end }} + resources: + requests: + storage: {{ .Values.persistence.size }} +{{- end }} diff --git a/deploy/helm/cms/values-development.yaml b/deploy/helm/cms/values-development.yaml index 16924ec..0e2fe0f 100644 --- a/deploy/helm/cms/values-development.yaml +++ b/deploy/helm/cms/values-development.yaml @@ -4,12 +4,12 @@ image: app: environment: demo - allowedOrigins: http://localhost:30081 + allowedOrigins: http://localhost:30010 contentFile: "" service: type: NodePort - nodePort: 30081 + nodePort: 30010 ingress: enabled: false diff --git a/deploy/helm/cms/values-production.yaml b/deploy/helm/cms/values-production.yaml index eb829b2..41baa39 100644 --- a/deploy/helm/cms/values-production.yaml +++ b/deploy/helm/cms/values-production.yaml @@ -3,7 +3,7 @@ image: pullPolicy: IfNotPresent app: - environment: production + environment: demo allowedOrigins: https://cms.urpi.be contentFile: /data/content.json