A couple of updates
Signed-off-by: Nikolai Rodionov <allanger@badhouseplants.net>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
build/
|
||||
bin/
|
||||
|
||||
51
Taskfile.yml
51
Taskfile.yml
@@ -2,6 +2,11 @@
|
||||
|
||||
version: "3"
|
||||
|
||||
vars:
|
||||
LOCALBIN:
|
||||
sh: echo "$(pwd)/bin"
|
||||
MIGRATE: "{{.LOCALBIN}}/migrate"
|
||||
|
||||
tasks:
|
||||
build:
|
||||
desc: Build go code
|
||||
@@ -51,3 +56,49 @@ tasks:
|
||||
- go get gitea.badhouseplants.net/softplayer/softplayer-go-proto@$(git -C '{{ .WORKDIR }}' rev-parse HEAD)
|
||||
- rm -rf '{{ .WORKDIR }}'
|
||||
- go mod tidy
|
||||
|
||||
add-migration:
|
||||
desc: Add a new database migration
|
||||
silent: true
|
||||
cmd: "{{.MIGRATE}} create -dir migrations -ext sql {{.CLI_ARGS}}"
|
||||
|
||||
# Install required tools
|
||||
localbin:
|
||||
desc: Create local bin directory
|
||||
silent: true
|
||||
cmds:
|
||||
- mkdir -p "{{.LOCALBIN}}"
|
||||
|
||||
migrate:
|
||||
desc: Download migrate if necessary
|
||||
silent: true
|
||||
deps:
|
||||
- localbin
|
||||
cmds:
|
||||
- task: go-install-tool
|
||||
vars:
|
||||
TARGET: "{{.MIGRATE}}"
|
||||
PACKAGE: github.com/golang-migrate/migrate/v4/cmd/migrate
|
||||
VERSION: latest
|
||||
|
||||
go-install-tool:
|
||||
internal: true
|
||||
silent: true
|
||||
cmd: |-
|
||||
set -e
|
||||
TARGET="{{.TARGET}}"
|
||||
PACKAGE="{{.PACKAGE}}@{{.VERSION}}"
|
||||
VERSIONED="${TARGET}-{{.VERSION}}"
|
||||
|
||||
if [ -f "$VERSIONED" ] && [ "$(readlink -- "$TARGET" 2>/dev/null)" = "$VERSIONED" ]; then
|
||||
echo "$PACKAGE already installed"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Downloading $PACKAGE"
|
||||
rm -f "$TARGET"
|
||||
|
||||
GOBIN="{{.LOCALBIN}}" go install "$PACKAGE"
|
||||
|
||||
mv "{{.LOCALBIN}}/$(basename "$TARGET")" "$VERSIONED"
|
||||
ln -sf "$(realpath "$VERSIONED")" "$TARGET"
|
||||
|
||||
@@ -34,6 +34,12 @@ spec:
|
||||
{{- end }}
|
||||
initContainers:
|
||||
- name: {{ .Chart.Name }}-migrations
|
||||
env:
|
||||
- name: SOFTPLAYER_DB_CONNECTION_STRING
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "softplayer-backend.fullname" . }}-db-creds
|
||||
key: CONNECTION_STRING
|
||||
{{- with .Values.securityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
@@ -53,6 +59,12 @@ spec:
|
||||
{{- end }}
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
env:
|
||||
- name: SOFTPLAYER_DB_CONNECTION_STRING
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "softplayer-backend.fullname" . }}-db-creds
|
||||
key: CONNECTION_STRING
|
||||
args:
|
||||
- serve
|
||||
- --dev-mode
|
||||
|
||||
14
helm/softplayer-backend/templates/extra/database.yaml
Normal file
14
helm/softplayer-backend/templates/extra/database.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
apiVersion: kinda.rocks/v1beta1
|
||||
kind: Database
|
||||
metadata:
|
||||
name: {{ include "softplayer-backend.fullname" . }}
|
||||
labels:
|
||||
{{- include "softplayer-backend.labels" . | nindent 4 }}
|
||||
spec:
|
||||
backup:
|
||||
cron: 0 0 * * *
|
||||
enable: false
|
||||
deletionProtected: true
|
||||
instance: cloudnative-pg17-softplayer
|
||||
postgres: {}
|
||||
secretName: {{ include "softplayer-backend.fullname" . }}-db-creds
|
||||
@@ -1,7 +1,9 @@
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata:
|
||||
name: grpc-route
|
||||
name: {{ include "softplayer-backend.fullname" . }}
|
||||
labels:
|
||||
{{- include "softplayer-backend.labels" . | nindent 4 }}
|
||||
annotations:
|
||||
external-dns.alpha.kubernetes.io/target: {{ .Values.ingressRoute.target }}
|
||||
kubernetes.io/ingress.class: {{ .Values.ingressRoute.class }}
|
||||
@@ -15,7 +17,7 @@ spec:
|
||||
- name: {{ include "softplayer-backend.fullname" . | replace "-" "" }}
|
||||
services:
|
||||
- name: {{ include "softplayer-backend.fullname" . }}
|
||||
port: 4020
|
||||
port: {{ .Values.service.port }}
|
||||
scheme: h2c
|
||||
tls:
|
||||
secretName: {{ .Values.ingressRoute.url }}
|
||||
@@ -1 +0,0 @@
|
||||
DROP TABLE IF EXISTS users;
|
||||
1
migrations/20260506200734_accounts_init.down.sql
Normal file
1
migrations/20260506200734_accounts_init.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS accounts;
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
CREATE TABLE IF NOT EXISTS accounts (
|
||||
uuid UUID PRIMARY KEY,
|
||||
email VARCHAR(255) NOT NULL
|
||||
CHECK (email ~* '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$') UNIQUE,
|
||||
Reference in New Issue
Block a user