move ai python server into seperate repo
This commit is contained in:
17
Dockerfile
17
Dockerfile
@@ -1,4 +1,4 @@
|
||||
# Stage 1: Build the Go application
|
||||
# --- Stage 1: Build the Go application ---
|
||||
FROM golang:1.23 AS builder
|
||||
|
||||
ENV CGO_ENABLED=0
|
||||
@@ -8,18 +8,19 @@ ENV GOARCH=amd64
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the Go modules and dependencies
|
||||
COPY ./golang/go.mod ./golang/go.sum ./
|
||||
COPY ./src/go.mod ./src/go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Copy the source code
|
||||
COPY ./golang/cmd ./cmd
|
||||
COPY ./golang/assets ./assets
|
||||
COPY ./golang/internal ./internal
|
||||
COPY ./src/cmd ./cmd
|
||||
COPY ./src/assets ./assets
|
||||
COPY ./src/internal ./internal
|
||||
|
||||
# Build the application
|
||||
RUN go build -o main cmd/frontend/*
|
||||
|
||||
# Stage 2: Run the application
|
||||
|
||||
# --- Stage 2: Run the application ---
|
||||
FROM alpine:latest
|
||||
|
||||
ENV DB_HOST="10.99.0.3"
|
||||
@@ -28,14 +29,12 @@ ENV DB_NAME="crowsnest"
|
||||
ENV DB_USER="crow"
|
||||
ENV DB_PASS=""
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the built binary from the builder stage
|
||||
COPY --from=builder /app/main .
|
||||
COPY ./golang/assets ./assets
|
||||
COPY ./src/assets ./assets
|
||||
|
||||
# Expose the desired port (e.g., 8080)
|
||||
EXPOSE 8080
|
||||
|
||||
# Command to run the application
|
||||
|
||||
9
Makefile
Normal file
9
Makefile
Normal file
@@ -0,0 +1,9 @@
|
||||
go-run:
|
||||
cd src; DB_USER=crow DB_PASS=4LlKpnQ2RZPzL13BSpkW4k DB_NAME=crowsnest DB_HOST=10.99.0.3 go run cmd/frontend/*
|
||||
|
||||
docker-run: docker-build
|
||||
docker run --rm -p 8080:8080 --env DB_PASS="4LlKpnQ2RZPzL13BSpkW4k" git.kohout-dev.de/crowsnest/crowsnest:latest
|
||||
|
||||
docker-build:
|
||||
docker build --platform linux/amd64 -t git.kohout-dev.de/crowsnest/crowsnest:latest . \
|
||||
&& docker push git.kohout-dev.de/crowsnest/crowsnest:latest
|
||||
@@ -1,6 +0,0 @@
|
||||
serv:
|
||||
DB_USER=crow DB_PASS=4LlKpnQ2RZPzL13BSpkW4k DB_NAME=crowsnest DB_HOST=10.99.0.3 go run cmd/frontend/*
|
||||
crawl:
|
||||
DB_USER=crow DB_PASS=4LlKpnQ2RZPzL13BSpkW4k DB_NAME=crowsnest DB_HOST=192.168.0.2 go run cmd/crawler/main.go
|
||||
summ:
|
||||
DB_USER=crow DB_PASS=4LlKpnQ2RZPzL13BSpkW4k DB_NAME=crowsnest DB_HOST=192.168.0.2 go run cmd/summarizer/main.go
|
||||
@@ -1,51 +0,0 @@
|
||||
from transformers import pipeline
|
||||
import psycopg2
|
||||
|
||||
# Connect to the School database
|
||||
|
||||
def summarize_articles(summfunc):
|
||||
""" Connect to the PostgreSQL database server """
|
||||
|
||||
conn = psycopg2.connect(
|
||||
dbname="crowsnest",
|
||||
user="crow",
|
||||
password="4LlKpnQ2RZPzL13BSpkW4k",
|
||||
host="192.168.0.2"
|
||||
)
|
||||
|
||||
try:
|
||||
# create a cursor
|
||||
cur = conn.cursor()
|
||||
|
||||
for i in range(20):
|
||||
print(i)
|
||||
# execute a statement
|
||||
cur.execute("""
|
||||
SELECT id, content
|
||||
FROM articles
|
||||
WHERE aisummary = ''
|
||||
ORDER BY publishDate DESC
|
||||
LIMIT 20
|
||||
""")
|
||||
|
||||
# display the PostgreSQL database server version
|
||||
keys, contents = list(zip(*cur.fetchall()))
|
||||
|
||||
for key, summary in zip(keys, summfunc(list(contents))):
|
||||
cur.execute("UPDATE articles SET aisummary = %s WHERE id = %s", (summary, key))
|
||||
|
||||
conn.commit()
|
||||
|
||||
# close the communication with the PostgreSQL
|
||||
cur.close()
|
||||
except (Exception, psycopg2.DatabaseError) as error:
|
||||
raise error
|
||||
finally:
|
||||
if conn is not None:
|
||||
conn.close()
|
||||
print('Database connection closed.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pipe = pipeline("summarization", model="Shahm/bart-german")
|
||||
summarize_articles(lambda x: [str(e["summary_text"]) for e in pipe(x)])
|
||||
Reference in New Issue
Block a user