From 02365a63798438e2e82f94dbb1eabed38b04ab05 Mon Sep 17 00:00:00 2001 From: Torsten Raudssus Date: Fri, 13 Dec 2024 06:33:32 +0100 Subject: [PATCH] First version --- .dockerignore | 180 +++++++++++++++++++++++++++++++++++++++++++ .gitignore | 176 ++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 86 +++++++++++++++++++++ README.md | 60 +++++++++++++++ docker-entrypoint.sh | 23 ++++++ 5 files changed, 525 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100755 docker-entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..940403a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,180 @@ +.git +.home +.data + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/latest/usage/project/#working-with-version-control +.pdm.toml +.pdm-python +.pdm-build/ + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +docker-compose.override.yml +common.override.yml + +.data/ +.home/ +tmp/ + +.joe_state +.plandex/ +.plandex-home/ +.bash_history +.cache +.local diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..072f479 --- /dev/null +++ b/.gitignore @@ -0,0 +1,176 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/latest/usage/project/#working-with-version-control +.pdm.toml +.pdm-python +.pdm-build/ + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +docker-compose.override.yml +common.override.yml + +.data/ +.home/ +tmp/ + +.joe_state +.plandex/ +.plandex-home/ +.bash_history +.cache +.local diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dd3f303 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,86 @@ +FROM buildpack-deps:bookworm + +ARG SRV_UID="1000" +ARG SRV_GID="1000" +ARG SRV_VERSION="0" +ARG SRV_APT_GET_INSTALL="" + +ENV SRV_UID="${SRV_UID}" +ENV SRV_GID="${SRV_GID}" +ENV SRV_VERSION="${SRV_VERSION}" +ENV SRV_APT_GET_INSTALL="${SRV_APT_GET_INSTALL}" + +# Install Debian packages ---------------------------------------------------- + +ENV DEBIAN_FRONTEND="noninteractive" + +RUN echo "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8" > /debconf-preseed.txt \ + && echo "locales locales/default_environment_locale select en_US.UTF-8" >> /debconf-preseed.txt \ + && debconf-set-selections /debconf-preseed.txt && apt-get update -y \ + && apt-get update -y \ + && apt-get install -y git zip unzip curl ca-certificates build-essential \ + ${SRV_APT_GET_INSTALL} \ + && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/log/* /var/cache/* + +# Install Python ------------------------------------------------------------- + +WORKDIR /usr/src + +ENV PYTHON_MAJOR="3" +ENV PYTHON_MINOR="10" +ENV PYTHON_VERSION="${PYTHON_MAJOR}.${PYTHON_MINOR}.16" + +ENV PYTHON_DIR="/usr/local/python/${PYTHON_VERSION}" +ENV PATH="${PYTHON_DIR}/bin:${PATH}" + +RUN mkdir -p /usr/src/python && cd /usr/src/python \ + && curl -sfSLO https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz \ + && tar --strip-components=1 -xzf Python-${PYTHON_VERSION}.tgz -C /usr/src/python \ + && rm Python-${PYTHON_VERSION}.tgz \ + && ./configure --prefix=${PYTHON_DIR} \ + --enable-shared \ + --enable-optimizations \ + --enable-ipv6 \ + LDFLAGS=-Wl,-rpath=${PYTHON_DIR}/lib,--disable-new-dtags \ + && make -j $(nproc) \ + && make -j $(nproc) altinstall \ + && ln -s ${PYTHON_DIR}/bin/python${PYTHON_MAJOR}.${PYTHON_MINOR} ${PYTHON_DIR}/bin/python${PYTHON_MAJOR} \ + && ln -s ${PYTHON_DIR}/bin/python${PYTHON_MAJOR} ${PYTHON_DIR}/bin/python \ + && ln -s ${PYTHON_DIR}/bin/pip${PYTHON_MAJOR}.${PYTHON_MINOR} ${PYTHON_DIR}/bin/pip \ + && cd .. && rm -rf /usr/src/python + +RUN pip install ollama openai groq anthropic crewai crewai-tools \ + composio_crewai + +COPY ./docker-entrypoint.sh /docker-entrypoint.sh + +# Install crewai user --------------------------------------------------------- + +RUN mkdir /home/crewai /opt/rust \ + && groupadd -g ${SRV_GID} crewai \ + && useradd -s /bin/bash -d /home/crewai -u ${SRV_UID} -g ${SRV_GID} crewai \ + && chown ${SRV_UID}.${SRV_GID} /home/crewai /opt/rust \ + && rm -rf /tmp/* + +# Activate crewai user -------------------------------------------------------- + +USER ${SRV_UID}:${SRV_GID} + +RUN ln -s /app/.bash_history $HOME/.bash_history \ + && ln -s /app/.composio $HOME/.composio + +VOLUME /app + +WORKDIR /app + +# Install rustup -------------------------------------------------------------- + +ENV RUSTUP_HOME=/opt/rust/rustup +ENV CARGO_HOME=/opt/rust/cargo + +ENV PATH="${PATH}:/opt/rust/cargo/bin" + +RUN curl https://sh.rustup.rs -sSf | \ + sh -s -- --default-toolchain stable --profile default --no-modify-path -y + +ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..cfc32eb --- /dev/null +++ b/README.md @@ -0,0 +1,60 @@ +# CrewAI image + +## How To Use + +Best used as alias, like in `.bashrc` with: + +```bash +alias crewai="docker run --rm -it --env-file .env -v \$(pwd):/app src.ci/srv/crewai:latest" +``` + +With this alias you can then directly work with the image, just by using the command `crewai`, assuming you have the User ID 1000, else you might need to make a custom image, see ARGS. + +You can directly go into a directory where you want to gather all your crews, and run the following commands to create a new crew and run the crew directly: + +```bash +crewai create crew myvikings +cd myvikings +crewai run +``` + +You can also get into the environment of the image with `bash` or directly all the `composio` CLI tool. + +```bash +crewai bash +crewai composio +``` + +More to come + +### Image Name + +The image name for your Docker is **src.ci/srv/crewai:latest**. This is only applicable, if you do not need to change the User ID and Group ID. + +### ARGS + +For changing the ARGS, you need to copy the repository and build the image yourself with setting the necessary ARGS to get a new image. As convention, you could use the User ID as the tag name for your new image, we will not make an official tag that is just a number, so you will not collide here in the future. Of course, you can also just give it then a complete new image name, so that there can't be any collide. You can also *git submodule* the repository in a subdirectory and then add it with args to your Docker-Compose configuration, like in this example, assuming you put the submodule of the repository under *docker/crewai*: + +```yaml +services: + crewai: + image: "src.ci/srv/crewai:1010" + build: + context: "docker/crewai" + args: + SRV_UID: "1010" +``` + +#### SRV_UID + +User ID for the CrewAI process and so of the data (Default: 1000) + +#### SRV_GID + +Group ID for the CrewAI process and so of the data (Default: 1000) + +## Support + +### Email + +You can also email me under [**getty@conflict.industries**](mailto:getty@conflict.industries) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..cfbe41c --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +export IP=$( hostname -i ) + +cat <