chore: import upstream snapshot with attribution
Update draft releases / main (push) Has been cancelled
Build and push docs image / build-image (push) Has been cancelled
Build Web Application / build-web (macos-latest) (push) Has been cancelled
Build Web Application / build-web (ubuntu-latest) (push) Has been cancelled
Python Code Quality Checks / build (push) Has been cancelled
Test Python / test-python (macos-latest, 3.10) (push) Has been cancelled
Test Python / test-python (macos-latest, 3.11) (push) Has been cancelled
Test Python / test-python (ubuntu-latest, 3.10) (push) Has been cancelled
Test Python / test-python (ubuntu-latest, 3.11) (push) Has been cancelled
Update draft releases / main (push) Has been cancelled
Build and push docs image / build-image (push) Has been cancelled
Build Web Application / build-web (macos-latest) (push) Has been cancelled
Build Web Application / build-web (ubuntu-latest) (push) Has been cancelled
Python Code Quality Checks / build (push) Has been cancelled
Test Python / test-python (macos-latest, 3.10) (push) Has been cancelled
Test Python / test-python (macos-latest, 3.11) (push) Has been cancelled
Test Python / test-python (ubuntu-latest, 3.10) (push) Has been cancelled
Test Python / test-python (ubuntu-latest, 3.11) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
FROM eosphorosai/dbgpt-full:latest
|
||||
ARG PYTHON_VERSION=3.11
|
||||
ARG PIP_INDEX_URL="https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||
ARG USERNAME
|
||||
ARG EXTRAS="base,proxy_openai,graph_rag,rag,storage_chromadb, storage_elasticsearch,cuda121,hf,quant_bnb,dbgpts"
|
||||
ARG DEFAULT_VENV=/opt/.uv.venv
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
USER root
|
||||
# Set the GID and UID of the container and
|
||||
# add a user to prevent permission mismatches
|
||||
# between the container user (root) and the host user,
|
||||
# and to resolve the issue of the host user lacking write permissions.
|
||||
RUN . .devcontainer/.env && \
|
||||
groupadd -g $USER_GID $GROUPNAME && \
|
||||
useradd -u $USER_UID -g $USER_GID -m $USERNAME && \
|
||||
chown -R $USER_UID:$USER_GID /app
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
curl \
|
||||
wget \
|
||||
python${PYTHON_VERSION}-dev \
|
||||
default-libmysqlclient-dev \
|
||||
ssh zsh autojump curl git-flow vim sudo \
|
||||
fonts-wqy-microhei fonts-noto-cjk \
|
||||
locales \
|
||||
&& sed -i '/zh_CN.UTF-8/s/^# //g' /etc/locale.gen \
|
||||
&& locale-gen zh_CN.UTF-8 \
|
||||
&& update-locale LANG=zh_CN.UTF-8 \
|
||||
&& python${PYTHON_VERSION} -m pip install --upgrade pip \
|
||||
&& python${PYTHON_VERSION} -m pip install --upgrade pipx \
|
||||
&& pipx install -i $PIP_INDEX_URL uv --global \
|
||||
&& chown -R $USERNAME:$GROUPNAME $DEFAULT_VENV \
|
||||
&& echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME \
|
||||
&& chmod 0440 /etc/sudoers.d/$USERNAME
|
||||
USER $USERNAME
|
||||
ENV UV_LINK_MODE=copy \
|
||||
PIP_INDEX_URL=$PIP_INDEX_URL \
|
||||
VIRTUAL_ENV=$DEFAULT_VENV \
|
||||
UV_PROJECT_ENVIRONMENT=$DEFAULT_VENV \
|
||||
UV_PYTHON=$DEFAULT_VENV/bin/python3 \
|
||||
UV_INDEX=$PIP_INDEX_URL \
|
||||
UV_DEFAULT_INDEX=$PIP_INDEX_URL \
|
||||
LANG=zh_CN.UTF-8 \
|
||||
LC_ALL=zh_CN.UTF-8
|
||||
|
||||
RUN sed -i "s|/app/\.venv|${FINAL_VENV_NAME}|g" /${DEFAULT_VENV}/bin/activate && \
|
||||
pip config set global.index-url $PIP_INDEX_URL && \
|
||||
pip config set global.trusted-host $(echo "$PIP_INDEX_URL" | sed -E 's|^https?://([^/]+).*|\1|') && \
|
||||
. $DEFAULT_VENV/bin/activate && \
|
||||
extras=$(echo $EXTRAS | tr ',' '\n' | while read extra; do echo "--extra $extra"; done | tr '\n' ' ') && \
|
||||
uv sync -v --active --all-packages $extras --default-index $PIP_INDEX_URL && \
|
||||
uv pip -v install --prefix $VIRTUAL_ENV -r requirements/dev-requirements.txt && \
|
||||
uv pip -v install --prefix $VIRTUAL_ENV -r requirements/lint-requirements.txt && \
|
||||
cp .devcontainer/dbgpt.pth /opt/.uv.venv/lib/python${PYTHON_VERSION}/site-packages/dbgpt.pth && \
|
||||
python -c "import dbgpt; print(dbgpt.__version__)"
|
||||
@@ -0,0 +1,36 @@
|
||||
# Developing inside a Container
|
||||
Use VS Code's Dev Container extension to build a containerized development environment. Leverage the eosphorosai/dbgpt:latest image as the development environment to avoid repeated dependency installations and improve development efficiency.
|
||||
NOTE: **Compatible with Linux and Windows Subsystem for Linux (WSL) environments only.**
|
||||
# Setup
|
||||
|
||||
- Follow the guide [Developing inside a Container](https://code.visualstudio.com/docs/devcontainers/containers) to set up the Dev Container:
|
||||
- Install the **Dev Containers** extension.
|
||||
|
||||
- Before the first launch, please execute the .devcontainer/init_env.sh script in the project root directory in **host**
|
||||
- Create `models` dir in project root and download text2vec-large-chinese to models/text2vec-large-chinese
|
||||
- Use the shortcut `Ctrl+Shift+P` to open the command palette, then enter `Dev Containers: Open Folder in Container`.
|
||||
|
||||
# Develop
|
||||
After successfully starting the Dev Container, open the terminal
|
||||
|
||||
- Activate the virtual environment
|
||||
```bash
|
||||
. /opt/.uv.venv/bin/activate
|
||||
```
|
||||
|
||||
- Customize the configuration file
|
||||
|
||||
You can copy the configuration file to the `.devcontainer` directory and rename it to `dev.toml` to avoid committing your personal configurations to the repository.
|
||||
```bash
|
||||
cp configs/dbgpt-app-config.example.toml .devcontainer/dev.toml
|
||||
```
|
||||
|
||||
- Start the service
|
||||
|
||||
```bash
|
||||
dbgpt start webserver --config .devcontainer/dev.toml
|
||||
```
|
||||
|
||||
# Create A Pull Request
|
||||
|
||||
Please refer to [CONTRIBUTING.md](../CONTRIBUTING.md). Before executing the make script or git commit, remember to deactivate the current virtual environment in the development environment.
|
||||
@@ -0,0 +1,8 @@
|
||||
/app/packages/dbgpt-app/src
|
||||
/app/packages/dbgpt-accelerator
|
||||
/app/packages/dbgpt-accelerator/src
|
||||
/app/packages/dbgpt-core/src
|
||||
/app/packages/dbgpt-client/src
|
||||
/app/packages/dbgpt-ext/src
|
||||
/app/packages/dbgpt-serve/src
|
||||
/app/packages/dbgpt-app/src
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
OS=$(uname -s)
|
||||
USERNAME="$USER"
|
||||
USER_UID=$(id -u "$USER")
|
||||
|
||||
if [ "$OS" = "Linux" ]; then
|
||||
GROUPNAME=$(id -gn "$USER")
|
||||
USER_GID=$(id -g "$USER")
|
||||
else
|
||||
GROUPNAME="root"
|
||||
USER_GID="0"
|
||||
fi
|
||||
|
||||
printf "OS=%s\nUSERNAME=%s\nUSER_UID=%s\nGROUPNAME=%s\nUSER_GID=%s\n" \
|
||||
"$OS" \
|
||||
"$USERNAME" \
|
||||
"$USER_UID" \
|
||||
"$GROUPNAME" \
|
||||
"$USER_GID" > .devcontainer/.env
|
||||
|
||||
# sharing-git-credentials see https://code.visualstudio.com/remote/advancedcontainers/sharing-git-credentials
|
||||
init_ssh_agent(){
|
||||
if [[ -z "$SSH_AUTH_SOCK" || ! -S "$SSH_AUTH_SOCK" ]]; then
|
||||
RUNNING_AGENT="$(ps -ax | grep '''ssh-agent -s''' | grep -v grep | wc -l)"
|
||||
if [ "$RUNNING_AGENT" = "0" ]; then
|
||||
ssh-agent -s &> $HOME/.ssh/ssh-agent
|
||||
fi
|
||||
eval $(cat $HOME/.ssh/ssh-agent) > /dev/null
|
||||
ssh-add 2> /dev/null
|
||||
echo $SSH_AUTH_SOCK
|
||||
fi
|
||||
# Define code block to insert (with unique identifier comment)
|
||||
SSH_AGENT_CODE='# SSH Agent Auto Management[ID:ssh_agent_v1]
|
||||
if [[ -z "$SSH_AUTH_SOCK" || ! -S "$SSH_AUTH_SOCK" ]]; then
|
||||
RUNNING_AGENT="$(ps -ax | grep '\''ssh-agent -s'\'' | grep -v grep | wc -l)"
|
||||
if [ "$RUNNING_AGENT" = "0" ]; then
|
||||
ssh-agent -s &> $HOME/.ssh/ssh-agent
|
||||
fi
|
||||
eval $(cat $HOME/.ssh/ssh-agent) > /dev/null
|
||||
ssh-add 2> /dev/null
|
||||
fi
|
||||
# END_SSH_AGENT_CODE'
|
||||
|
||||
TARGET_FILE="$HOME/.bashrc"
|
||||
|
||||
# Create .ssh directory if not exists
|
||||
mkdir -p "$HOME/.ssh"
|
||||
|
||||
# Check for existing code block
|
||||
if ! grep -q 'END_SSH_AGENT_CODE' "$TARGET_FILE"; then
|
||||
echo "Adding SSH agent management code to ${TARGET_FILE}..."
|
||||
echo "$SSH_AGENT_CODE" >> "$TARGET_FILE"
|
||||
if [[ "$SHELL" == *"zsh"* ]]; then
|
||||
echo "$SSH_AGENT_CODE" >> "$HOME/.zshrc"
|
||||
fi
|
||||
echo "Code added successfully. Please run source ${TARGET_FILE} to apply changes immediately"
|
||||
else
|
||||
echo "Existing SSH agent code detected, no need to add again"
|
||||
fi
|
||||
}
|
||||
init_ssh_agent
|
||||
mkdir -p models
|
||||
Executable
+71
@@ -0,0 +1,71 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
cd /app
|
||||
|
||||
# Install Oh My Zsh with mirror fallback
|
||||
if [ ! -f ~/.oh-my-zsh/oh-my-zsh.sh ]; then
|
||||
echo "Installing Oh My Zsh..."
|
||||
REPO=mirrors/oh-my-zsh REMOTE=https://gitee.com/mirrors/oh-my-zsh.git sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)" "" --unattended
|
||||
fi
|
||||
|
||||
# Install plugins with mirror switching
|
||||
plugins=(
|
||||
"zsh-users/zsh-autosuggestions"
|
||||
"zsh-users/zsh-syntax-highlighting"
|
||||
)
|
||||
|
||||
for plugin in "${plugins[@]}"; do
|
||||
repo_name=$(basename $plugin)
|
||||
if [ ! -d ~/.oh-my-zsh/custom/plugins/$repo_name ]; then
|
||||
echo "Installing plugin: $plugin"
|
||||
# Clone from GitHub with Gitee mirror fallback
|
||||
git clone --depth=1 https://github.com/$plugin.git ~/.oh-my-zsh/custom/plugins/$repo_name || \
|
||||
git clone --depth=1 https://gitee.com/zsh-users/$repo_name.git ~/.oh-my-zsh/custom/plugins/$repo_name
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# Install theme with mirror fallback
|
||||
if [ ! -d ~/.oh-my-zsh/custom/themes/powerlevel10k ]; then
|
||||
echo "Installing powerlevel10k theme..."
|
||||
# Clone from GitHub with Gitee mirror fallback
|
||||
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/custom/themes/powerlevel10k || \
|
||||
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/custom/themes/powerlevel10k
|
||||
fi
|
||||
|
||||
# Configuration section remains the same...
|
||||
# Apply custom configuration
|
||||
if [ -f /app/.devcontainer/zshrc-config ]; then
|
||||
cp /app/.devcontainer/zshrc-config ~/.zshrc
|
||||
else
|
||||
# Generate basic .zshrc if no custom configuration exists
|
||||
cat << EOF >> ~/.zshrc
|
||||
export ZSH="\$HOME/.oh-my-zsh"
|
||||
ZSH_THEME="robbyrussell"
|
||||
plugins=(git zsh-autosuggestions zsh-syntax-highlighting autojump)
|
||||
source \$ZSH/oh-my-zsh.sh
|
||||
export LANG=zh_CN.UTF-8
|
||||
export LC_ALL=zh_CN.UTF-8
|
||||
# Enable autojump
|
||||
[[ -s /usr/share/autojump/autojump.sh ]] && source /usr/share/autojump/autojump.sh
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Ensure autojump configuration is applied (even if custom configuration exists)
|
||||
if ! grep -q "autojump.sh" ~/.zshrc; then
|
||||
echo '[[ -s /usr/share/autojump/autojump.sh ]] && source /usr/share/autojump/autojump.sh' >> ~/.zshrc
|
||||
fi
|
||||
cat << EOF >> ~/.zshrc
|
||||
# Add the following to ~/.zshrc
|
||||
load_env() {
|
||||
if [ -f /app/.env ]; then
|
||||
ENV_CONTENT=$(grep -vE '^#|^$' /app/.env | xargs)
|
||||
if [ -n "$ENV_CONTENT" ]; then
|
||||
export $ENV_CONTENT
|
||||
fi
|
||||
fi
|
||||
}
|
||||
load_env
|
||||
EOF
|
||||
rm -rf .venv.make
|
||||
echo "Post-create setup completed!"
|
||||
Reference in New Issue
Block a user