From 37a0006a3127e1bdb4eda8be899a21283a765784 Mon Sep 17 00:00:00 2001 From: Matthias Thomas Lamotte Date: Mon, 17 Jun 2024 17:45:57 -0400 Subject: [PATCH] squash --- .../docker-compose.yml | 18 +----------------- ai/boilerplate/goapp/.env | 7 +++++++ ai/boilerplate/goapp/go.mod | 8 ++++++++ ai/boilerplate/goapp/go.sum | 4 ++++ ai/{boilterplate => boilerplate}/goapp/main.go | 7 +++++++ ai/boilterplate/goapp/Dockerfile | 13 ------------- ai/boilterplate/goapp/go.mod | 5 ----- ai/boilterplate/goapp/go.sum | 2 -- 8 files changed, 27 insertions(+), 37 deletions(-) rename ai/{boilterplate => boilerplate}/docker-compose.yml (53%) create mode 100644 ai/boilerplate/goapp/.env create mode 100644 ai/boilerplate/goapp/go.mod create mode 100644 ai/boilerplate/goapp/go.sum rename ai/{boilterplate => boilerplate}/goapp/main.go (87%) delete mode 100644 ai/boilterplate/goapp/Dockerfile delete mode 100644 ai/boilterplate/goapp/go.mod delete mode 100644 ai/boilterplate/goapp/go.sum diff --git a/ai/boilterplate/docker-compose.yml b/ai/boilerplate/docker-compose.yml similarity index 53% rename from ai/boilterplate/docker-compose.yml rename to ai/boilerplate/docker-compose.yml index d77f77c..8e6e1a2 100644 --- a/ai/boilterplate/docker-compose.yml +++ b/ai/boilerplate/docker-compose.yml @@ -13,28 +13,12 @@ services: - postgres-data:/var/lib/postgresql/data qdrant: - image: generall/qdrant + image: qdrant/qdrant ports: - "6333:6333" volumes: - qdrant-data:/qdrant/storage - goapp: - build: ./goapp - ports: - - "8080:8080" - depends_on: - - postgres - - qdrant - environment: - POSTGRES_HOST: postgres - POSTGRES_PORT: 5432 - POSTGRES_USER: youruser - POSTGRES_PASSWORD: yourpassword - POSTGRES_DB: yourdbname - QDRANT_HOST: qdrant - QDRANT_PORT: 6333 - volumes: postgres-data: qdrant-data: \ No newline at end of file diff --git a/ai/boilerplate/goapp/.env b/ai/boilerplate/goapp/.env new file mode 100644 index 0000000..fe3953b --- /dev/null +++ b/ai/boilerplate/goapp/.env @@ -0,0 +1,7 @@ +POSTGRES_HOST=localhost +POSTGRES_PORT=5432 +POSTGRES_USER=youruser +POSTGRES_PASSWORD=yourpassword +POSTGRES_DB=yourdbname +QDRANT_HOST=localhost +QDRANT_PORT=6333 \ No newline at end of file diff --git a/ai/boilerplate/goapp/go.mod b/ai/boilerplate/goapp/go.mod new file mode 100644 index 0000000..523dede --- /dev/null +++ b/ai/boilerplate/goapp/go.mod @@ -0,0 +1,8 @@ +module goapp + +go 1.22.3 + +require ( + github.com/joho/godotenv v1.5.1 + github.com/lib/pq v1.10.9 +) diff --git a/ai/boilerplate/goapp/go.sum b/ai/boilerplate/goapp/go.sum new file mode 100644 index 0000000..ecb9035 --- /dev/null +++ b/ai/boilerplate/goapp/go.sum @@ -0,0 +1,4 @@ +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= diff --git a/ai/boilterplate/goapp/main.go b/ai/boilerplate/goapp/main.go similarity index 87% rename from ai/boilterplate/goapp/main.go rename to ai/boilerplate/goapp/main.go index 0921428..5b28abc 100644 --- a/ai/boilterplate/goapp/main.go +++ b/ai/boilerplate/goapp/main.go @@ -7,10 +7,17 @@ import ( "net/http" "os" + "github.com/joho/godotenv" _ "github.com/lib/pq" ) func main() { + // Load .env file + err := godotenv.Load() + if err != nil { + log.Fatalf("Error loading .env file: %v", err) + } + // Connect to PostgreSQL pgConnStr := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=disable", os.Getenv("POSTGRES_HOST"), os.Getenv("POSTGRES_PORT"), os.Getenv("POSTGRES_USER"), os.Getenv("POSTGRES_PASSWORD"), os.Getenv("POSTGRES_DB")) diff --git a/ai/boilterplate/goapp/Dockerfile b/ai/boilterplate/goapp/Dockerfile deleted file mode 100644 index eb423ef..0000000 --- a/ai/boilterplate/goapp/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM golang:1.22.4-alpine3.19 as builder - -WORKDIR /app - -COPY go.mod ./ -COPY go.sum ./ -RUN go mod download - -COPY *.go ./ - -RUN go build -o /goapp - -CMD ["/goapp"] \ No newline at end of file diff --git a/ai/boilterplate/goapp/go.mod b/ai/boilterplate/goapp/go.mod deleted file mode 100644 index 9ed9ce4..0000000 --- a/ai/boilterplate/goapp/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module goapp - -go 1.22.3 - -require github.com/lib/pq v1.10.9 diff --git a/ai/boilterplate/goapp/go.sum b/ai/boilterplate/goapp/go.sum deleted file mode 100644 index aeddeae..0000000 --- a/ai/boilterplate/goapp/go.sum +++ /dev/null @@ -1,2 +0,0 @@ -github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= -github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=