Brijesh's Git Server — argus-core @ 590f666c334fbab570964e0ef9a06c3161efb729

Logging service

chore: cleanup

replace unused functions in makefile with new ones
remove unused cassandra related files
create k8s directory
use no base image for prod stage in dockerfile and use vendor to make builds faster
update gitignore and dockerignore
Brijesh Wawdhane ops@brijesh.dev
Tue, 31 Dec 2024 05:24:03 +0530
commit

590f666c334fbab570964e0ef9a06c3161efb729

parent

ad14ae9ef6df214964267107a8b29d85545baddb

M .dockerignore.dockerignore

@@ -1,33 +1,12 @@

-# Binaries for programs and plugins -**/*.exe -**/*.exe~ -**/*.dll -**/*.so -**/*.dylib - -# Test binary, built with "go test -c" -**/*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -**/*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - # Go workspace file -**/go.work -**/tmp - -# IDE specific files -**/.vscode -**/.idea +go.work +tmp/ # .env file -**/.env +.env # Project build -**/main -**/*templ.go +main # OS X generated file -**/.DS_Store +.DS_Store
M .gitignore.gitignore

@@ -1,34 +1,15 @@

-# Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib - -# Test binary, built with "go test -c" -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ +# Dependency directories +vendor/ # Go workspace file go.work tmp/ -# IDE specific files -.vscode -.idea - # .env file .env # Project build main -*templ.go # OS X generated file .DS_Store -
M DockerfileDockerfile

@@ -3,17 +3,17 @@

WORKDIR /app COPY go.mod go.sum ./ -RUN go mod download +COPY vendor/ ./vendor/ COPY . . RUN go build -o main cmd/api/main.go -FROM alpine:3.20.1 AS prod +FROM scratch AS prod WORKDIR /app COPY --from=build /app/main /app/main -COPY ./sf-class2-root.crt /app/sf-class2-root.crt +COPY ./cassandra_ca.crt /app/cassandra_ca.crt EXPOSE ${PORT} CMD ["./main"]
M MakefileMakefile

@@ -1,30 +1,20 @@

-build: - @go build -o main cmd/api/main.go +docker-build: + docker build -t brijeshwawdhane/argus-core:0.1.1-alpha.1 . -run: - @go run cmd/api/main.go +docker-push: + docker push brijeshwawdhane/argus-core:0.1.1-alpha.1 -docker-run: - @if docker compose up --build 2>/dev/null; then \ - : ; \ - else \ - echo "Falling back to Docker Compose V1"; \ - docker-compose up --build; \ - fi - - -docker-down: - @if docker compose down 2>/dev/null; then \ - : ; \ - else \ - echo "Falling back to Docker Compose V1"; \ - docker-compose down; \ - fi +k-deployment-reapply: + kubectl delete -f k8s/deployment.yaml + kubectl apply -f k8s/deployment.yaml +k-rbac-reapply: + kubectl delete -f k8s/rbac.yaml + kubectl apply -f k8s/rbac.yaml -clean: - @echo "Cleaning..." - @rm -f main +k-service-reapply: + kubectl delete -f k8s/service.yaml + kubectl apply -f k8s/service.yaml watch: @if command -v air > /dev/null; then \

@@ -42,4 +32,4 @@ exit 1; \

fi; \ fi -.PHONY: build run clean watch docker-run docker-down +.PHONY: docker-build docker-push k-deployment-reapply k-rbac-reapply k-service-reapply watch
M db.cqlinternal/database/schema.cql

@@ -42,8 +42,8 @@ ) WITH CLUSTERING ORDER BY (timestamp DESC);

CREATE TABLE IF NOT EXISTS argus.log_frequencies ( application_id uuid, - interval_start timestamp, -- The start time of the interval - interval_end timestamp, -- The end time of the interval - log_count int, -- Count of logs in that time interval + interval_start timestamp, + interval_end timestamp, + log_count int, PRIMARY KEY ((application_id), interval_start) ) WITH CLUSTERING ORDER BY (interval_start DESC);
M internal/database/database.gointernal/database/database.go

@@ -16,8 +16,6 @@ cassandraUsername := os.Getenv("CASSANDRA_USERNAME")

cassandraPassword := os.Getenv("CASSANDRA_PASSWORD") cassandraKeyspace := os.Getenv("CASSANDRA_KEYSPACE") - certFileName := "sf-class2-root.crt" - cluster := gocql.NewCluster(cassandraHost) cluster.Port = 9142 cluster.SslOpts = nil

@@ -26,7 +24,7 @@ Username: cassandraUsername,

Password: cassandraPassword, } cluster.SslOpts = &gocql.SslOptions{ - CaPath: certFileName, + CaPath: "cassandra_ca.crt", EnableHostVerification: false, } cluster.Consistency = gocql.LocalQuorum