Skip to content

ivorscott/client-core

Repository files navigation

[Archived] Client Backend

Goal

Client is a project management tool for performing software development with clients.

Setup

Requirements

Note For Windows Users

Please Enable WSL
sha

frontend preview

Secrets

manifests/secrets.yaml is required for deployments.

core/{service}/.env is required for end to end testing of each service.

.gitpass is read in the Tiltfile and passed to Dockerfiles as build args. This allows services to pull private go modules but currently all repositories are public.

Developement

Run front and back ends simultaneously. For faster development we don't run the client-app in a container/pod. However, we use tilt.dev to manage kubernetes development in the backend.

# client-app
npm run dev

# client-core
make up

Build, Test, Linting and Formatting commands exist for each service. See core/{service}/Makefile

make test # short tests
make e2e # uses exported env vars
make fmt
make lint
make vet
make build

Debugging local databases

If you want autocompletion in the terminal, use pgcli:

kubectl run pgcli --rm -i -t --env=DB_URL="postgresql://postgres:postgres@nats-db-store-svc:5432/postgres" --image devpies/pgcli

If you prefer the old fashion way, use kubectl exec:

kubectl exec -it <pod> -- psql -h localhost -U postgres postgres

If you prefer having a UI to debug postgres, you use PgAdmin:

kubectl run pgadmin --env="PGADMIN_DEFAULT_EMAIL=test@example.com" --env="PGADMIN_DEFAULT_PASSWORD=SuperSecret" --image dpage/pgadmin4
kubectl port-forward pod/pgadmin 8888:80

Migrations

Migrations exist under the following paths:

  • ./nats/migrations
  • ./core/projects/schema/migrations
  • ./core/users/schema/migrations

Migration Flow

  1. create a migration
  2. add sql for up and down migration files
  3. tag an image containing the latest migrations
  4. push image to registry
View example
cd core/projects/schema

migrate create -ext sql -dir migrations -seq create_table

docker build -t ivorscott/mic-db-projects-migration:v000001 ./migrations

docker push ivorscott/mic-db-projects-migration:v000001

Then apply the latest migration with initContainers

Using init containers for migrations requires having a running database beforehand. Containers in a pod will start after init containers have executed.

View example
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mic-projects-depl
spec:
  selector:
    matchLabels:
      app: mic-projects
  template:
    metadata:
      labels:
        app: mic-projects
    spec:
      containers:
        - image: ivorscott/mic-projects:325b1c2
          name: mic-projects
          resources:
            requests:
              cpu: "100m"
              memory: "100Mi"
            limits:
              cpu: "250m"
              memory: "250Mi"
          env:
            - name: API_WEB_PORT
              value: ":4000"
            - name: API_WEB_CORS_ORIGINS
              value: "https://localhost:3000, https://client.local"
            - name: API_WEB_AUTH_DOMAIN
              valueFrom:
                secretKeyRef:
                  name: secrets
                  key: auth0-domain
            - name: API_WEB_AUTH_AUDIENCE
              valueFrom:
                secretKeyRef:
                  name: secrets
                  key: auth0-audience
            - name: API_DB_USER
              value: postgres
            - name: API_DB_NAME
              value: postgres
            - name: API_DB_PASSWORD
              value: postgres
            - name: API_DB_HOST
              value: mic-db-projects-svc
            - name: API_DB_DISABLE_TLS
              value: "true"
            - name: API_NATS_URL
              value: "nats://nats-svc:4222"
            - name: API_NATS_CLIENT_ID
              value: "mic-projects"
            - name: API_NATS_CLUSTER_ID
              value: "devpie-client"
      initContainers:
        - name: schema-migration
          image: ivorscott/mic-db-projects-migration:v000016
          env:
            - name: DB_URL
              value: postgresql://postgres:postgres@mic-db-projects-svc:5432/postgres?sslmode=disable
          command: ["migrate"]
          args:
            ["-path", "/migrations", "-verbose", "-database", "$(DB_URL)", "up"]

Learn more about migrate cli here.

Contribute

Reach out on twitter or email me if you have any questions about contributing.

Releases

No releases published

Packages

No packages published

Languages