First version

This commit is contained in:
Torsten Raudssus 2024-12-13 06:33:32 +01:00
commit 02365a6379
5 changed files with 525 additions and 0 deletions

180
.dockerignore Normal file
View file

@ -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

176
.gitignore vendored Normal file
View file

@ -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

86
Dockerfile Normal file
View file

@ -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"]

60
README.md Normal file
View file

@ -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)

23
docker-entrypoint.sh Executable file
View file

@ -0,0 +1,23 @@
#!/bin/bash
export IP=$( hostname -i )
cat <<EOF
__ _
___ _ ____ __/ /__ _ __ _____ ____ _(_)
/ __| '__\\ \\ / / / __| '__/ _ \\ \\ /\\ / / _\` | |
\\__ \\ | \\ V / / (__| | | __/\\ V V / (_| | |
|___/_| \\_/_/ \\___|_| \\___| \\_/\\_/ \\__,_|_|
-------------------------------------------------
IP: $IP
EOF
if [[ $1 == "composio" ]]; then
exec $@
elif [[ $1 == "bash" ]]; then
exec $@
else
exec crewai $@
fi