feat: add Dockerfile, Helm chart, Gitea Actions workflow
Some checks failed
Build & Push / build (push) Failing after 5m41s

This commit is contained in:
Caesar2011
2026-05-17 20:36:29 +02:00
parent 20ed6ee9fb
commit e4e9ebd737
12 changed files with 356 additions and 30 deletions

View File

@@ -0,0 +1,6 @@
apiVersion: v2
name: factorio-dashboard
description: Factorio Signal Exporter — Next.js dashboard with TimescaleDB
type: application
version: 0.1.0
appVersion: "latest"

View File

@@ -0,0 +1,50 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "factorio-dashboard.name" -}}
{{- .Chart.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a fully qualified app name.
*/}}
{{- define "factorio-dashboard.fullname" -}}
{{- printf "%s" (include "factorio-dashboard.name" .) | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels.
*/}}
{{- define "factorio-dashboard.labels" -}}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/name: {{ include "factorio-dashboard.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels.
*/}}
{{- define "factorio-dashboard.selectorLabels" -}}
app.kubernetes.io/name: {{ include "factorio-dashboard.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Name of the secret that holds API_TOKEN and DATABASE_URL.
*/}}
{{- define "factorio-dashboard.secretName" -}}
{{- if .Values.app.existingSecret }}
{{- .Values.app.existingSecret }}
{{- else }}
{{- include "factorio-dashboard.fullname" . }}-secret
{{- end }}
{{- end }}
{{/*
Construct DATABASE_URL from db values.
*/}}
{{- define "factorio-dashboard.databaseUrl" -}}
{{- printf "postgresql://%s:%s@%s-db:%d/%s" .Values.db.user .Values.db.password (include "factorio-dashboard.fullname" .) (int .Values.db.port) .Values.db.name }}
{{- end }}

View File

@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "factorio-dashboard.fullname" . }}-db
labels:
{{- include "factorio-dashboard.labels" . | nindent 4 }}
app.kubernetes.io/component: db
spec:
clusterIP: None
selector:
{{- include "factorio-dashboard.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: db
ports:
- port: {{ .Values.db.port }}
targetPort: {{ .Values.db.port }}

View File

@@ -0,0 +1,57 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "factorio-dashboard.fullname" . }}-db
labels:
{{- include "factorio-dashboard.labels" . | nindent 4 }}
app.kubernetes.io/component: db
spec:
serviceName: {{ include "factorio-dashboard.fullname" . }}-db
replicas: 1
selector:
matchLabels:
{{- include "factorio-dashboard.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: db
template:
metadata:
labels:
{{- include "factorio-dashboard.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: db
spec:
containers:
- name: timescaledb
image: timescale/timescaledb:latest-pg16
ports:
- containerPort: {{ .Values.db.port }}
env:
- name: POSTGRES_USER
value: {{ .Values.db.user | quote }}
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "factorio-dashboard.secretName" . }}
key: DATABASE_URL
optional: false
- name: POSTGRES_PASSWORD
value: {{ .Values.db.password | quote }}
- name: POSTGRES_DB
value: {{ .Values.db.name | quote }}
volumeMounts:
- name: db-data
mountPath: /var/lib/postgresql/data
readinessProbe:
exec:
command: ["pg_isready", "-U", {{ .Values.db.user | quote }}]
initialDelaySeconds: 10
periodSeconds: 5
volumeClaimTemplates:
- metadata:
name: db-data
spec:
accessModes: ["ReadWriteOnce"]
{{- if .Values.db.storageClassName }}
storageClassName: {{ .Values.db.storageClassName | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.db.storage }}

View File

@@ -0,0 +1,70 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "factorio-dashboard.fullname" . }}
labels:
{{- include "factorio-dashboard.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.app.replicaCount }}
selector:
matchLabels:
{{- include "factorio-dashboard.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "factorio-dashboard.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
initContainers:
- name: migrate
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["npm", "run", "migrate"]
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: {{ include "factorio-dashboard.secretName" . }}
key: DATABASE_URL
containers:
- name: app
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 3000
env:
- name: API_TOKEN
valueFrom:
secretKeyRef:
name: {{ include "factorio-dashboard.secretName" . }}
key: API_TOKEN
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: {{ include "factorio-dashboard.secretName" . }}
key: DATABASE_URL
readinessProbe:
httpGet:
path: /
port: 3000
initialDelaySeconds: 5
periodSeconds: 10
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@@ -0,0 +1,33 @@
{{- if .Values.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "factorio-dashboard.fullname" . }}
labels:
{{- include "factorio-dashboard.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.className }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
- hosts:
- {{ .Values.ingress.host | quote }}
secretName: {{ .Values.ingress.tlsSecretName | default (printf "%s-tls" (include "factorio-dashboard.fullname" .)) | quote }}
{{- end }}
rules:
- host: {{ .Values.ingress.host | quote }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ include "factorio-dashboard.fullname" . }}
port:
number: {{ .Values.service.port }}
{{- end }}

View File

@@ -0,0 +1,12 @@
{{- if not .Values.app.existingSecret }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "factorio-dashboard.fullname" . }}-secret
labels:
{{- include "factorio-dashboard.labels" . | nindent 4 }}
type: Opaque
stringData:
API_TOKEN: {{ .Values.app.apiToken | required "app.apiToken is required" | quote }}
DATABASE_URL: {{ include "factorio-dashboard.databaseUrl" . | quote }}
{{- end }}

View File

@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "factorio-dashboard.fullname" . }}
labels:
{{- include "factorio-dashboard.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
selector:
{{- include "factorio-dashboard.selectorLabels" . | nindent 4 }}
ports:
- port: {{ .Values.service.port }}
targetPort: 3000

View File

@@ -0,0 +1,41 @@
image:
repository: git.sebse.de/sebse/factorio-signal-exporter
tag: latest
pullPolicy: IfNotPresent
imagePullSecrets: []
app:
replicaCount: 1
## API token for ingest POST and dashboard GET ?token=
apiToken: ""
## If set, use this existing K8s secret instead of creating one.
## Secret must contain keys: API_TOKEN, DATABASE_URL
existingSecret: ""
db:
## TimescaleDB credentials — used to build DATABASE_URL and configure the StatefulSet
user: factorio
password: factorio
name: factorio
port: 5432
storage: 10Gi
storageClassName: "" # leave empty for cluster default
service:
type: ClusterIP
port: 3000
ingress:
enabled: false
className: ""
host: factorio.example.com
tls: false
tlsSecretName: ""
annotations: {}
resources: {}
nodeSelector: {}
tolerations: []
affinity: {}