From 7d5a08ac511bf4cdfb8986149b286cb92bfcd45e Mon Sep 17 00:00:00 2001 From: mike dupont Date: Wed, 11 Oct 2023 16:24:16 -0400 Subject: [PATCH] now building and running locally --- docker-compose.yml | 25 ++++++++++--- dockerbuild/.gitignore | 1 - dockerbuild/Readme.md | 1 - dockerbuild/__init__.py | 0 dockerbuild/baseimage.py | 71 ------------------------------------ dockerbuild/constants.py | 30 --------------- dockerbuild/images.py | 57 ----------------------------- dockerbuild/publish.py | 79 ---------------------------------------- vendor/Auto-GPT | 2 +- vendor/basic_agent | 2 +- vendor/lollms | 2 +- vendor/python-poetry | 2 +- 12 files changed, 23 insertions(+), 249 deletions(-) delete mode 100644 dockerbuild/.gitignore delete mode 100644 dockerbuild/Readme.md delete mode 100644 dockerbuild/__init__.py delete mode 100644 dockerbuild/baseimage.py delete mode 100644 dockerbuild/constants.py delete mode 100644 dockerbuild/images.py delete mode 100644 dockerbuild/publish.py diff --git a/docker-compose.yml b/docker-compose.yml index 1f0540c..4a6e79a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,29 +3,37 @@ services: act_base: #root base of action build: vendor/act_base + image: h4ckermike/act_base poetry_base: # use poetry + image: h4ckermike/poetry_base build: context: vendor/python-poetry/build args: - OFFICIAL_PYTHON_IMAGE: act_base + BASE_IMAGE: h4ckermike/act_base POETRY_VERSION: 1.6.1 + entrypoint: /bin/bash + stdin_open: true # docker run -i + tty: true # docker run -t + depends_on: - act_base ai_ticket: # the ticket to unite + image: h4ckermike/ai_ticket build: context: . args: - BASE_IMAGE: act_base + BASE_IMAGE: h4ckermike/poetry_base depends_on: - poetry_base - basic_agent: #basic agnet + basic_agent: #basic agent + image: h4ckermike/basic_agent build: context: vendor/basic_agent/ args: - OFFICIAL_PYTHON_IMAGE: act_base + BASE_IMAGE: h4ckermike/ai_ticket depends_on: - ai_ticket @@ -35,10 +43,14 @@ services: environment: - GITHUB_PAT=${GITHUB_PAT} - GITHUB_REPO=${GITHUB_REPO} + image: h4ckermike/mockopenai build: context: vendor/lollms/ args: - OFFICIAL_PYTHON_IMAGE: localhost/ai-ticket_ai_ticket:latest + BASE_IMAGE: h4ckermike/ai_ticket + volumes: + - /var/run/docker.sock:/var/run/docker.sock + ports: - "5000:8080" @@ -59,8 +71,9 @@ services: context: vendor/Auto-GPT/ dockerfile: slim/Dockerfile args: - OFFICIAL_PYTHON_IMAGE: localhost/ai-ticket_ai_ticket:latest + BASE_IMAGE: h4ckermike/basic_agent depends_on: - basic_agent - mockopenai + image: h4ckermike/autogpt diff --git a/dockerbuild/.gitignore b/dockerbuild/.gitignore deleted file mode 100644 index bee8a64..0000000 --- a/dockerbuild/.gitignore +++ /dev/null @@ -1 +0,0 @@ -__pycache__ diff --git a/dockerbuild/Readme.md b/dockerbuild/Readme.md deleted file mode 100644 index 502580d..0000000 --- a/dockerbuild/Readme.md +++ /dev/null @@ -1 +0,0 @@ -taken from pfeiffermax/uvicorn-poetry diff --git a/dockerbuild/__init__.py b/dockerbuild/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/dockerbuild/baseimage.py b/dockerbuild/baseimage.py deleted file mode 100644 index fe9dac4..0000000 --- a/dockerbuild/baseimage.py +++ /dev/null @@ -1,71 +0,0 @@ -from pathlib import Path -from typing import Optional - -import docker -from docker.models.images import Image - -from dockerbuild.constants import ( - BASE_IMAGES, - APPLICATION_SERVER_PORT, -) - -# -BASE_IMAGE="nikolaik/python-nodejs:python3.10-nodejs20" - -class DockerImage: - def __init__( - self, - docker_client: docker.client, - target_architecture: str, - version: str, - ): - self.docker_client: docker.client = docker_client - self.dockerfile_name: str = "Dockerfile" - self.dockerfile_directory: Optional[Path] = None - self.image_name: Optional[str] = None - self.image_tag: Optional[str] = None - self.version: Optional[str] = version - self.target_architecture: str = target_architecture - - def build(self) -> Image: - self.image_tag: str = f"{self.version}-{self.target_architecture}" - buildargs: dict[str, str] = { - "BASE_IMAGE": BASE_IMAGE, - "APPLICATION_SERVER_PORT": APPLICATION_SERVER_PORT, } - image: Image = self.docker_client.images.build( - path=str(self.dockerfile_directory), - dockerfile=self.dockerfile_name, - tag=f"{self.image_name}:{self.image_tag}", - buildargs=buildargs,)[0] - return image - -class ExampleApplicationImage(DockerImage): - def build( - self, - target: str, - base_image_tag: str, - ) -> Image: - - self.image_tag = f"{self.version}-{self.target_architecture}" - - buildargs: dict[str, str] = { - "BASE_IMAGE": base_image_tag, - } - print("buildargs",dict( - args=buildargs, - path=str(self.dockerfile_directory), - dockerfile=self.dockerfile_name, - tag=f"{self.image_name}:{self.image_tag}", - #target=target, - buildargs=buildargs, - )) - - image: Image = self.docker_client.images.build( - - path=str(self.dockerfile_directory), - dockerfile=self.dockerfile_name, - tag=f"{self.image_name}:{self.image_tag}", - #target=target, - buildargs=buildargs, - )[0] - return image diff --git a/dockerbuild/constants.py b/dockerbuild/constants.py deleted file mode 100644 index 1f85ba6..0000000 --- a/dockerbuild/constants.py +++ /dev/null @@ -1,30 +0,0 @@ -TARGET_ARCHITECTURES: list[str] = [ - "python3.9.16-bullseye", - "python3.9.16-slim-bullseye", - "python3.10.10-bullseye", - "python3.10.10-slim-bullseye", -] -BASE_IMAGES: dict = { - TARGET_ARCHITECTURES[ - 0 - ]: "pfeiffermax/python-poetry:1.2.0-poetry1.4.1-python3.9.16-bullseye@sha256:54037cfdca026b17e7a57664dff47bf04e7849074d3ab62271ecad0446ef0322", - TARGET_ARCHITECTURES[ - 1 - ]: "pfeiffermax/python-poetry:1.2.0-poetry1.4.1-python3.9.16-slim-bullseye@sha256:c0b8d9c28c5717074c481dfdf1d8bd3aaa0b83a5e2a9e37c77be7af19d70d0ce", - TARGET_ARCHITECTURES[ - 2 - ]: "pfeiffermax/python-poetry:1.2.0-poetry1.4.1-python3.10.10-bullseye@sha256:5a81c8c86132e504db2b7329f5e41cd32bddebf811d83a0d356edbca0d81135c", - TARGET_ARCHITECTURES[ - 3 - ]: "pfeiffermax/python-poetry:1.2.0-poetry1.4.1-python3.10.10-slim-bullseye@sha256:289c6beb568991811629c91cdcb3841ceb95bf0a017c3e411f4b71e18043ef15", -} -PYTHON_VERSIONS: dict = { - TARGET_ARCHITECTURES[0]: "3.9.16", - TARGET_ARCHITECTURES[1]: "3.9.16", - TARGET_ARCHITECTURES[2]: "3.10.10", - TARGET_ARCHITECTURES[3]: "3.10.10", -} - -# As we are running the server with an unprivileged user, we need to use -# a high port. -APPLICATION_SERVER_PORT: str = "8000" diff --git a/dockerbuild/images.py b/dockerbuild/images.py deleted file mode 100644 index 9dfdc72..0000000 --- a/dockerbuild/images.py +++ /dev/null @@ -1,57 +0,0 @@ -from dockerbuild.baseimage import ExampleApplicationImage - -import docker -from pathlib import Path -from docker.models.images import Image - -class AITicketPoetryImage(ExampleApplicationImage): - def __init__( - self, - docker_client: docker.client, - target_architecture: str, - version: str, - ): - super().__init__(docker_client, target_architecture, version) - # An image name is made up of slash-separated name components, - # optionally prefixed by a registry hostname. - # see: https://docs.docker.com/engine/reference/commandline/tag/ - self.image_name: str = "h4ckermike/ai-ticket" - self.dockerfile_directory: Path = Path(__file__).parent.parent.resolve() - - -class AutoGptImage(ExampleApplicationImage): - def __init__( - self, - docker_client: docker.client, - target_architecture: str, - version: str, - ): - super().__init__(docker_client, target_architecture, version) - self.image_name: str = "h4ckermike/act_base" - self.dockerfile_directory: Path = ( - Path(__file__).parent.parent.resolve() - / "vendor" - / "act_base" - ) -class ActBaseImage(ExampleApplicationImage): - def __init__( self, docker_client: docker.client, target_architecture: str, version: str, - ): - super().__init__(docker_client, target_architecture, version) - self.image_name: str = "h4ckermike/autogpt" - self.dockerfile_directory: Path = ( - Path(__file__).parent.parent.resolve() - / "vendor" - / "Auto-GPT/" - ) - -class OpenAIImage(ExampleApplicationImage): - def __init__( self, docker_client: docker.client,target_architecture: str,version: str ): - super().__init__(docker_client, target_architecture, version) - self.image_name: str = "h4ckermike/mockopenai" - self.dockerfile_directory: Path = ( - Path(__file__).parent.parent.resolve() - / "vendor" - / "lollms/" - ) - - diff --git a/dockerbuild/publish.py b/dockerbuild/publish.py deleted file mode 100644 index 714b77a..0000000 --- a/dockerbuild/publish.py +++ /dev/null @@ -1,79 +0,0 @@ -import click -import docker - -from docker.client import DockerClient - -from dockerbuild.constants import ( - TARGET_ARCHITECTURES, -) -import dockerbuild.images -from dockerbuild.baseimage import BASE_IMAGE - -@click.command() -@click.option( - "--docker-hub-username", - envvar="DOCKER_HUB_USERNAME", - help="Docker Hub username", -) -@click.option( - "--docker-hub-password", - envvar="DOCKER_HUB_PASSWORD", - help="Docker Hub password", -) -@click.option( - "--version-tag", envvar="GIT_TAG_NAME", required=True, help="Version Tag" -) -@click.option("--registry", envvar="REGISTRY", help="Docker registry") -def main( - docker_hub_username: str, - docker_hub_password: str, - version_tag: str, - registry: str, -) -> None: - docker_client: DockerClient = docker.from_env() - for target_architecture in TARGET_ARCHITECTURES: - #import pdb - #pdb.set_trace() - for x in dir(dockerbuild.images) : - cls = getattr(dockerbuild.images,x) - if not isinstance(cls,type): - continue - print(cls) - new_uvicorn_gunicorn_poetry_image = (cls(docker_client,target_architecture,version_tag)) - if new_uvicorn_gunicorn_poetry_image: - for old_image in docker_client.images.list(new_uvicorn_gunicorn_poetry_image.image_name): - for tag in old_image.tags: - print("tag",tag) - docker_client.images.remove(tag, force=True) - new_uvicorn_gunicorn_poetry_image.build( - target=target_architecture,base_image_tag=BASE_IMAGE - ) - if docker_hub_username and docker_hub_password: - login_kwargs: dict = { - "username": docker_hub_username, - "password": docker_hub_password, - } - if registry: - login_kwargs["registry"] = registry - docker_client.login(**login_kwargs) - if registry: - repository: str = ( - f"{registry}/{new_uvicorn_gunicorn_poetry_image.image_name}" - ) - else: - repository: str = new_uvicorn_gunicorn_poetry_image.image_name - - if False: - for line in docker_client.images.push( - repository, - tag=new_uvicorn_gunicorn_poetry_image.image_tag, - stream=True, - decode=True, - ): - print(line) - docker_client.close() - - -if __name__ == "__main__": - # pylint: disable=no-value-for-parameter - main() diff --git a/vendor/Auto-GPT b/vendor/Auto-GPT index 2c9f2ec..6026332 160000 --- a/vendor/Auto-GPT +++ b/vendor/Auto-GPT @@ -1 +1 @@ -Subproject commit 2c9f2ec8badcf331c74ed241a2df56abe4408cac +Subproject commit 6026332e9dbaea217a5db06b6a68e4174ae8c2e3 diff --git a/vendor/basic_agent b/vendor/basic_agent index ab60de9..6f68d72 160000 --- a/vendor/basic_agent +++ b/vendor/basic_agent @@ -1 +1 @@ -Subproject commit ab60de9662af21bb534ea946869c0c2ddb105e84 +Subproject commit 6f68d72bfdac569c053c03be796b1cdc34b666c5 diff --git a/vendor/lollms b/vendor/lollms index faf3084..bcbe8d6 160000 --- a/vendor/lollms +++ b/vendor/lollms @@ -1 +1 @@ -Subproject commit faf308442626da16ec165d157aeb19e0340883e5 +Subproject commit bcbe8d6de326e821dbbbd4227dffb3f001dcc696 diff --git a/vendor/python-poetry b/vendor/python-poetry index 060f378..af1c7a2 160000 --- a/vendor/python-poetry +++ b/vendor/python-poetry @@ -1 +1 @@ -Subproject commit 060f378c73140a999201ca3425ddb00a1b5bcaa2 +Subproject commit af1c7a2092b2fb3fca599c98c6a7e1d1866b38b4