SUSE Skyscraper
Development Environment
Prerequisites
Local Environment:
- PostgresSQL
- nats
- make
- nodejs 14+
- golang 1.18+
- sqlc
go install github.com/kyleconroy/sqlc/cmd/sqlc@latest
Minikube Environment:
- skaffold
- minikube (with ingress-dns)
- kubectl
- cfssl
go install github.com/cloudflare/cfssl/cmd/...@latest
- helm
openSUSE Tumbleweed:
sudo zypper in skaffold minikube kubernetes-client helm nodejs16 npm16 go1.18 make
API Specification
The api specification is located at api/skyscraper.yaml
Database Migrations
The database migration files are at cmd/app/migrate/migrations. They're embedded into the binary, and we read them in the migrate
command.
Migrate Up:
go run ./cmd/main.go migrate up
Migrate Down:
go run ./cmd/main.go migrate down
Generate Database files
Notes:
- The queries are located in the
queries.sql
file.
- The config file for
sqlc
is located at sqlc.yaml
.
- The database files are generated at
cli/db
.
Run the following command to generate the database files:
sqlc generate
Deploy Locally
- Ensure that you have a PostgresSQL server that you can connect to locally.
- Ensure that you have a NATS server that you can connect to locally:
docker run -p 4222:4222 --name nats nats:latest -js
- Copy
config.yaml.example
to config.yaml
and fill in the values.
- Copy
web/src/environments/environment.ts
to web/src/environments/environment.local.ts
and fill in its values.
- Build the golang backend:
go build ./cmd/main.go
- Run database migrations:
go run ./cmd/main.go migrate up
- Run the sync job:
go run ./cmd/main.go cloud-sync
- Run the server:
go run ./cmd/main.go server
- While the server is running, start the web frontend:
cd web
npm start
- The frontend should be live at http://localhost:4200.
Deployment on Minikube
- Generate the development TLS CA certificates:
make dev_ca
- Add helm repos:
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
helm repo add skyscraper https://suse-skyscraper.github.io/skyscraper-helm-charts
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
- Copy helm configuration values from
kubernetes/helm/*-values.yaml.example
to respective *-values.yaml
and make changes to customize your environment.
- (optional) Add
kubernetes/ca/keys/ca.pem
to your browser.
- Build the backend configuration file
kubernetes/config/config.yaml
with kubernetes/config/config.yaml.example
as an example.
- Build the frontend configuration file
kubernetes/config/environmnent.local.ts
with kubernetes/config/environmnent.local.ts.example
as an example.
- Generate the Kubernetes configuration files:
make dev_config
- Start minikube:
minikube start
- Start skaffold:
skaffold dev
- If everything is set up properly (including ingress-dns), you should now be able to reach Skyscraper at https://skyscraper-web.test.