A couple of updates

Signed-off-by: Nikolai Rodionov <allanger@badhouseplants.net>
This commit is contained in:
2026-05-06 22:18:08 +02:00
parent c52c3d1046
commit e5465f08ea
9 changed files with 84 additions and 4 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
build/
bin/

View File

@@ -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"

View File

@@ -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

View 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

View File

@@ -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 }}

View File

@@ -1 +0,0 @@
DROP TABLE IF EXISTS users;

View File

@@ -0,0 +1 @@
DROP TABLE IF EXISTS accounts;

View File

@@ -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,