From 0a78158c17d3331ddcc494887d20cf543cfd5662 Mon Sep 17 00:00:00 2001 From: "aynic.os" Date: Sun, 8 Jan 2023 16:37:51 +0000 Subject: [PATCH] add Dockerfile --- Makefile | 8 ++++++++ README.md | 8 +++++++- docker/bogui.mk | 3 +++ docker/bogui/Dockerfile | 24 ++++++++++++++++++++++++ docker/docker-compose.app.yml | 19 +++++++++++++++++++ docker/docker-compose.yml | 14 ++++++++++++++ lib/riverpods/openai.dart | 4 ++-- web/manifest.json | 2 +- 8 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 Makefile create mode 100644 docker/bogui.mk create mode 100644 docker/bogui/Dockerfile create mode 100644 docker/docker-compose.app.yml create mode 100644 docker/docker-compose.yml diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7189e0d --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +MYOS ?= ../myos +MYOS_REPOSITORY ?= $(patsubst %/$(APP),%/myos,$(APP_REPOSITORY)) +APP ?= $(lastword $(subst /, ,$(APP_REPOSITORY))) +APP_REPOSITORY ?= $(shell git config --get remote.origin.url 2>/dev/null) +-include $(MYOS)/make/include.mk +$(MYOS): + -@git clone $(MYOS_REPOSITORY) $(MYOS) + diff --git a/README.md b/README.md index 762f51b..1406223 100644 --- a/README.md +++ b/README.md @@ -2,5 +2,11 @@ Bogui est une app Flutter clone Libre et open source du playground de OpenAI, capable d'utiliser le model text-davinci-003, mais aussi le model gpt2 en local, sans frais donc. -Qu'ils aillent tous se faire enculer. +Qu'ils aillent tous se faire enculer. Et gratos pour le coup. +## Install + +``` +make && make build SECRET_KEY=sk-... +make up logs +``` diff --git a/docker/bogui.mk b/docker/bogui.mk new file mode 100644 index 0000000..d4210fe --- /dev/null +++ b/docker/bogui.mk @@ -0,0 +1,3 @@ +ENV_VARS += BOGUI_SERVICE_80_TAGS +BOGUI_SERVICE_NAME ?= bogui +BOGUI_SERVICE_80_TAGS ?= $(call urlprefix) diff --git a/docker/bogui/Dockerfile b/docker/bogui/Dockerfile new file mode 100644 index 0000000..62073da --- /dev/null +++ b/docker/bogui/Dockerfile @@ -0,0 +1,24 @@ +# link: https://github.com/PlugFox/docker_flutter/blob/master/dockerfiles/flutter_web.dockerfile +ARG FLUTTER_VERSION=stable +FROM plugfox/flutter:${FLUTTER_VERSION} as build + +# Setup flutter tools for web developement +RUN set -eux; flutter config --no-analytics --enable-web \ + && flutter precache --universal --web + +# Add lables +LABEL name="librezo/bogui:${FLUTTER_VERSION}-web" \ + description="Free GPT" \ + flutter.channel="${FLUTTER_VERSION}" \ + flutter.version="${FLUTTER_VERSION}" + +COPY . /app +WORKDIR /app + +ARG OPENAI_SECRET_KEY + +RUN flutter build web --dart-define=OPENAPI_SECRET_KEY=${OPENAI_SECRET_KEY} +RUN flutter doctor + +FROM nginx:alpine as master +COPY --from=build /app/build/web /usr/share/nginx/html diff --git a/docker/docker-compose.app.yml b/docker/docker-compose.app.yml new file mode 100644 index 0000000..28fb7a4 --- /dev/null +++ b/docker/docker-compose.app.yml @@ -0,0 +1,19 @@ +version: '3.6' + +services: + bogui: + build: + args: + - DOCKER_REPOSITORY=${DOCKER_REPOSITORY} + image: ${DOCKER_REPOSITORY}/bogui:${DOCKER_IMAGE_TAG} + labels: + - SERVICE_80_CHECK_HTTP=/ + - SERVICE_80_NAME=${COMPOSE_SERVICE_NAME}-bogui-80 + - SERVICE_80_TAGS=${BOGUI_SERVICE_80_TAGS:-} + networks: + - public + +networks: + public: + external: true + name: ${DOCKER_NETWORK_PUBLIC} diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..26218ce --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3.6' + +services: + bogui: + build: + args: + - OPENAI_SECRET_KEY=${BOGUI_OPENAI_SECRET_KEY:-${OPENAI_SECRET_KEY:-${SECRET_KEY}}} + - DOCKER_BUILD_DIR=docker/bogui + - FLUTTER_VERSION=${BOGUI_FLUTTER_VERSION:-stable} + context: ../ + dockerfile: docker/bogui/Dockerfile + ports: + - 80/tcp + restart: always diff --git a/lib/riverpods/openai.dart b/lib/riverpods/openai.dart index a74bb64..12a5b4d 100644 --- a/lib/riverpods/openai.dart +++ b/lib/riverpods/openai.dart @@ -3,7 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:openai_gpt3_api/openai_gpt3_api.dart'; class OpenAI extends GPT3 { - OpenAI() : super('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'); + OpenAI() : super(String.fromEnvironment('OPENAPI_SECRET_KEY')); // final prompt = TextEditingController(); final prompt = StateProvider((ref) => TextEditingController()); @@ -46,4 +46,4 @@ double truncateDouble(double val, int decimals) { valString = valString.substring(0, dotIndex + decimals + 1); return double.parse(valString); -} \ No newline at end of file +} diff --git a/web/manifest.json b/web/manifest.json index 00b39d1..9d81353 100644 --- a/web/manifest.json +++ b/web/manifest.json @@ -5,7 +5,7 @@ "display": "standalone", "background_color": "#0175C2", "theme_color": "#0175C2", - "description": "A new Flutter project.", + "description": "free GPT", "orientation": "portrait-primary", "prefer_related_applications": false, "icons": [