Compare commits
2 Commits
529a5466f1
...
90ac9490f4
Author | SHA1 | Date |
---|---|---|
|
90ac9490f4 | |
|
ed8cba13a7 |
|
@ -0,0 +1,24 @@
|
|||
name: Gitea Actions Demo
|
||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
Explore-Gitea-Actions:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
||||
- name: List files in the repository
|
||||
run: |
|
||||
ls ${{ gitea.workspace }}
|
||||
- name: Build Docker
|
||||
run: |
|
||||
set -x
|
||||
export
|
||||
docker build -t logingest:0.1 .
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
|
@ -0,0 +1,27 @@
|
|||
FROM node:20-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install --production
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
|
||||
# Environment variables with defaults
|
||||
ENV PORT=3000 \
|
||||
DB_HOST=postgres-svc \
|
||||
DB_PORT=5432 \
|
||||
DB_NAME=logapp \
|
||||
DB_USER=postgres \
|
||||
DB_PASSWORD=postgrespass \
|
||||
DB_SSL=false \
|
||||
AUTH_USERNAME=admin \
|
||||
AUTH_PASSWORD=password123
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["node", "server.js"]
|
|
@ -0,0 +1,5 @@
|
|||
apiVersion: v2
|
||||
name: logingest
|
||||
description: Log ingestion microservice
|
||||
version: 0.1.0
|
||||
appVersion: "1.0.0"
|
|
@ -0,0 +1,44 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "logingest.fullname" . }}
|
||||
labels:
|
||||
{{- include "logingest.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "logingest.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "logingest.selectorLabels" . | nindent 8 }}
|
||||
spec:
|
||||
serviceAccountName: {{ include "logingest.serviceAccountName" . }}
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
ports:
|
||||
- name: logport
|
||||
containerPort: {{ .values.app.port }}
|
||||
protocol: TCP
|
||||
env:
|
||||
- name: DB_HOST
|
||||
value: "{{ .Values.db.host }}"
|
||||
- name: DB_PORT
|
||||
value: "{{ .Values.db.port }}"
|
||||
- name: DB_NAME
|
||||
value: {{ .Values.db.database }}
|
||||
- name: DB_USER
|
||||
value: {{ .Values.db.user }}
|
||||
- name: DB_SSL
|
||||
value: {{ .Values.db.ssl | quote }}
|
||||
- name: DB_PASSWORD
|
||||
value: {{ .Values.db.password | quote }}
|
||||
{{- range $key, $value := .Values.env }}
|
||||
- name: {{ $key }}
|
||||
value: {{ $value | quote }}
|
||||
{{- end }}
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
|
@ -0,0 +1,39 @@
|
|||
{{- if .Values.ingress.enabled -}}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ include "logingest.fullname" . }}
|
||||
labels:
|
||||
{{- include "logingest.labels" . | nindent 4 }}
|
||||
{{- with .Values.ingress.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
ingressClassName: {{ .Values.ingress.className }}
|
||||
{{- if .Values.ingress.tls }}
|
||||
tls:
|
||||
{{- range .Values.ingress.tls }}
|
||||
- hosts:
|
||||
{{- range .hosts }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
secretName: {{ .secretName }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- range .Values.ingress.hosts }}
|
||||
- host: {{ .host | quote }}
|
||||
http:
|
||||
paths:
|
||||
{{- range .paths }}
|
||||
- path: {{ .path }}
|
||||
pathType: {{ .pathType }}
|
||||
backend:
|
||||
service:
|
||||
name: {{ include "logingest.fullname" $ }}
|
||||
port:
|
||||
number: {{ $.Values.service.port }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,15 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "logingest.fullname" . }}
|
||||
labels:
|
||||
{{- include "logingest.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: {{ .values.app.port }}
|
||||
protocol: TCP
|
||||
name: logport
|
||||
selector:
|
||||
{{- include "logingest.selectorLabels" . | nindent 4 }}
|
|
@ -0,0 +1,54 @@
|
|||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: logingest
|
||||
pullPolicy: IfNotPresent
|
||||
tag: "latest"
|
||||
|
||||
nameOverride: ""
|
||||
fullnameOverride: ""
|
||||
|
||||
app:
|
||||
port: 3000
|
||||
|
||||
serviceAccount:
|
||||
create: true
|
||||
name: ""
|
||||
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 3000
|
||||
|
||||
ingress:
|
||||
enabled: false
|
||||
className: "nginx"
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: nginx
|
||||
# nginx.ingress.kubernetes.io/rewrite-target: /
|
||||
hosts:
|
||||
- host: chart-example.local
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
|
||||
resources:
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 512Mi
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 128Mi
|
||||
|
||||
db:
|
||||
host: localhost
|
||||
database: logapp
|
||||
user: postgres
|
||||
password: postgrespass
|
||||
port: 5432
|
||||
ssl: false
|
||||
persistence:
|
||||
enabled: false
|
||||
|
||||
env:
|
||||
AUTH_USERNAME: admin
|
||||
AUTH_PASSWORD: password123
|
|
@ -29,11 +29,11 @@ try {
|
|||
// Create logs table if it doesn't exist
|
||||
await client.query(`
|
||||
CREATE TABLE IF NOT EXISTS logs (
|
||||
id bigint PRIMARY KEY,
|
||||
id varchar(20) PRIMARY KEY,
|
||||
body text NOT NULL,
|
||||
project text NOT NULL DEFAULT 'Project 1',
|
||||
type text NOT NULL DEFAULT 'Info',
|
||||
date date NOT NULL,
|
||||
date text NOT NULL,
|
||||
avatar_src text NOT NULL DEFAULT '/rectangle-15.png',
|
||||
owner text NOT NULL DEFAULT 'N/A',
|
||||
description text NOT NULL,
|
||||
|
|
|
@ -4,8 +4,8 @@ export async function createLogEntry(client, data) {
|
|||
|
||||
// Create log entry with defaults
|
||||
const logEntry = {
|
||||
id: epochTime,
|
||||
body: data.message.substring(0, 200), // First 200 characters
|
||||
id: epochTime.toString(),
|
||||
body: data.body, // Changed from body to message
|
||||
project: data.project || 'Project 1',
|
||||
type: data.type || 'Info',
|
||||
date: now.toISOString().split('T')[0], // YYYY-MM-DD format
|
||||
|
@ -37,6 +37,10 @@ export async function createLogEntry(client, data) {
|
|||
];
|
||||
|
||||
try {
|
||||
// Log the query and values before execution
|
||||
console.log('Executing SQL:', query);
|
||||
console.log('With values:', values);
|
||||
|
||||
const result = await client.query(query, values);
|
||||
const insertedData = result.rows[0];
|
||||
|
||||
|
@ -52,4 +56,5 @@ export async function createLogEntry(client, data) {
|
|||
console.error('Database error:', error);
|
||||
throw new Error(`Failed to insert log entry: ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,10 +8,10 @@ export function validateLogData(data) {
|
|||
}
|
||||
|
||||
// Validate required message field
|
||||
if (!data.message || typeof data.message !== 'string') {
|
||||
errors.push('message field is required and must be a string');
|
||||
} else if (data.message.trim().length === 0) {
|
||||
errors.push('message field cannot be empty');
|
||||
if (!data.body || typeof data.body !== 'string') {
|
||||
errors.push('body field is required and must be a string');
|
||||
} else if (data.body.trim().length === 0) {
|
||||
errors.push('body field cannot be empty');
|
||||
}
|
||||
|
||||
// Validate optional fields if provided
|
||||
|
|
Loading…
Reference in New Issue