Muhammad Faraz Malik commited on
Commit ·
da45a82
1
Parent(s): c26f194
feat(deploy): add root Dockerfile, docker-compose.yml, and AWS Free-Tier EC2 User-Data bootstrap script
Browse files- Dockerfile +27 -0
- deploy/ec2_userdata.sh +45 -0
- docker-compose.yml +12 -0
Dockerfile
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 4 |
+
PYTHONUNBUFFERED=1 \
|
| 5 |
+
PIP_NO_CACHE_DIR=1 \
|
| 6 |
+
PYTHONPATH=/app/src
|
| 7 |
+
|
| 8 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 9 |
+
git \
|
| 10 |
+
curl \
|
| 11 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
+
|
| 13 |
+
WORKDIR /app
|
| 14 |
+
|
| 15 |
+
COPY requirements.txt pyproject.toml README.md SPEC.md ./
|
| 16 |
+
COPY src ./src
|
| 17 |
+
COPY tests ./tests
|
| 18 |
+
COPY .streamlit ./.streamlit
|
| 19 |
+
|
| 20 |
+
RUN pip install --upgrade pip && pip install -r requirements.txt
|
| 21 |
+
|
| 22 |
+
EXPOSE 8501
|
| 23 |
+
|
| 24 |
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
|
| 25 |
+
CMD curl --fail http://localhost:8501/_stcore/health || exit 1
|
| 26 |
+
|
| 27 |
+
CMD ["streamlit", "run", "src/ui/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.headless=true"]
|
deploy/ec2_userdata.sh
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# AWS EC2 Free Tier (Ubuntu 22.04 / 24.04 or Amazon Linux 2023) User-Data Bootstrap Script
|
| 3 |
+
set -euxo pipefail
|
| 4 |
+
|
| 5 |
+
# 1. Install Docker & Git
|
| 6 |
+
if command -v apt-get >/dev/null 2>&1; then
|
| 7 |
+
apt-get update -y
|
| 8 |
+
apt-get install -y git docker.io docker-compose-v2
|
| 9 |
+
systemctl enable --now docker
|
| 10 |
+
elif command -v dnf >/dev/null 2>&1; then
|
| 11 |
+
dnf update -y
|
| 12 |
+
dnf install -y git docker
|
| 13 |
+
systemctl enable --now docker
|
| 14 |
+
fi
|
| 15 |
+
|
| 16 |
+
# 2. Clone the repository
|
| 17 |
+
mkdir -p /opt/bugfix-agent
|
| 18 |
+
cd /opt/bugfix-agent
|
| 19 |
+
if [ ! -d ".git" ]; then
|
| 20 |
+
git clone https://github.com/farazmalik180/autonomous-bug-fixing-agent.git .
|
| 21 |
+
else
|
| 22 |
+
git pull origin main
|
| 23 |
+
fi
|
| 24 |
+
|
| 25 |
+
# 3. Create .env (replace GROQ_API_KEY below or set in UI)
|
| 26 |
+
cat <<EOF > .env
|
| 27 |
+
GROQ_API_KEY=${GROQ_API_KEY:-}
|
| 28 |
+
GROQ_MODEL=openai/gpt-oss-120b
|
| 29 |
+
SANDBOX_BACKEND=docker
|
| 30 |
+
EOF
|
| 31 |
+
|
| 32 |
+
# 4. Build the inner Docker sandbox image so tests run in isolated containers on EC2
|
| 33 |
+
docker build -t bugfix-agent-sandbox:latest src/sandbox || true
|
| 34 |
+
|
| 35 |
+
# 5. Build and run the Streamlit app container on port 80 and 8501
|
| 36 |
+
docker build -t bugfix-agent-web:latest .
|
| 37 |
+
docker rm -f bugfix-agent-web || true
|
| 38 |
+
docker run -d \
|
| 39 |
+
--name bugfix-agent-web \
|
| 40 |
+
--restart unless-stopped \
|
| 41 |
+
-p 80:8501 \
|
| 42 |
+
-p 8501:8501 \
|
| 43 |
+
--env-file /opt/bugfix-agent/.env \
|
| 44 |
+
-v /var/run/docker.sock:/var/run/docker.sock \
|
| 45 |
+
bugfix-agent-web:latest
|
docker-compose.yml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
services:
|
| 2 |
+
bugfix-agent:
|
| 3 |
+
build: .
|
| 4 |
+
container_name: autonomous-bug-fixing-agent
|
| 5 |
+
restart: unless-stopped
|
| 6 |
+
ports:
|
| 7 |
+
- "80:8501"
|
| 8 |
+
- "8501:8501"
|
| 9 |
+
env_file:
|
| 10 |
+
- .env
|
| 11 |
+
environment:
|
| 12 |
+
- SANDBOX_BACKEND=local
|