Skip to content

Commit

Permalink
Merge pull request WecoAI#18 from dexhunter/feat/docker
Browse files Browse the repository at this point in the history
🐳 Add Dockerfile
  • Loading branch information
dexhunter authored Oct 30, 2024
2 parents 59b5a70 + 7d5a3b4 commit 21ab47d
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.git
.gitignore
logs/
workspaces/
__pycache__/
*.pyc
*.pyo
*.pyd
.Python
*.so
*.egg
*.egg-info/
.env
.venv
.coverage
.pytest_cache/
.mypy_cache/
55 changes: 55 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# syntax=docker/dockerfile:1

# Build stage
FROM python:3.10-slim AS builder

# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
gcc \
&& rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Copy only the files needed for installation
COPY requirements.txt setup.py README.md ./
COPY aide ./aide

# Create virtual environment and install dependencies
RUN python -m venv /opt/venv && \
. /opt/venv/bin/activate && \
pip install --no-cache-dir -r requirements.txt && \
pip install -e .

# Runtime stage
FROM python:3.10-slim

# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
unzip \
&& rm -rf /var/lib/apt/lists/*

# Create non-root user
RUN useradd -m -u 1000 aide

# Copy virtual environment from builder
COPY --from=builder /opt/venv /opt/venv
# Copy the package files needed for the installation
COPY --from=builder /app /app
ENV PATH="/opt/venv/bin:$PATH"

# Set working directory
WORKDIR /app

# Create and set permissions for logs and workspaces
RUN mkdir -p logs workspaces && \
chown -R aide:aide /app

# Switch to non-root user
USER aide

# Set default command
ENTRYPOINT ["aide"]
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,36 @@ cd aideml
pip install -e .
```

## Using AIDE with Docker

You can also run AIDE using Docker:

1. Build the Docker image:
```bash
docker build -t aide .
```

2. Run AIDE with Docker (example with house prices task):
```bash
# Set custom workspace and logs location (optional)
export WORKSPACE_BASE=$(pwd)/workspaces
export LOGS_DIR=$(pwd)/logs

docker run -it --rm \
-v "${LOGS_DIR:-$(pwd)/logs}:/app/logs" \
-v "${WORKSPACE_BASE:-$(pwd)/workspaces}:/app/workspaces" \
-v "$(pwd)/aide/example_tasks:/app/data" \
-e OPENAI_API_KEY="your-actual-api-key" \
aide \
data_dir=/app/data/house_prices \
goal="Predict the sales price for each house" \
eval="Use the RMSE metric between the logarithm of the predicted and observed values."
```

You can customize the location of workspaces and logs by setting environment variables before running the container:
- `WORKSPACE_BASE`: Sets the base directory for AIDE workspaces (default: `$(pwd)/workspaces`)
- `LOGS_DIR`: Sets the directory for AIDE logs (default: `$(pwd)/logs`)

Contribution guide will be available soon.

## Algorithm Description
Expand Down

0 comments on commit 21ab47d

Please sign in to comment.