Spaces:
Running
Running
A-Mahla
commited on
FIX dockerfile (#12)
Browse files* FIX dockerfile
* FIX dockerfile
- Dockerfile +35 -9
- cua2-core/src/cua2_core/services/agent_service.py +16 -22
- entrypoint.sh +4 -2
- nginx.conf +3 -2
Dockerfile
CHANGED
|
@@ -14,27 +14,53 @@ RUN npm run build
|
|
| 14 |
# Stage 2: Production image
|
| 15 |
FROM python:3.11-slim
|
| 16 |
|
|
|
|
| 17 |
RUN apt-get update && apt-get install -y \
|
| 18 |
nginx \
|
| 19 |
curl \
|
| 20 |
procps \
|
| 21 |
&& rm -rf /var/lib/apt/lists/*
|
| 22 |
|
| 23 |
-
|
|
|
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
RUN pip install --no-cache-dir uv
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
|
|
|
|
| 33 |
|
| 34 |
-
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
|
|
|
| 38 |
|
| 39 |
EXPOSE 7860
|
| 40 |
|
|
@@ -43,4 +69,4 @@ ENV HOST=0.0.0.0
|
|
| 43 |
ENV PORT=8000
|
| 44 |
|
| 45 |
# Use entrypoint script
|
| 46 |
-
ENTRYPOINT ["
|
|
|
|
| 14 |
# Stage 2: Production image
|
| 15 |
FROM python:3.11-slim
|
| 16 |
|
| 17 |
+
# Install system packages as root
|
| 18 |
RUN apt-get update && apt-get install -y \
|
| 19 |
nginx \
|
| 20 |
curl \
|
| 21 |
procps \
|
| 22 |
&& rm -rf /var/lib/apt/lists/*
|
| 23 |
|
| 24 |
+
# Create a new user named "user" with user ID 1000
|
| 25 |
+
RUN useradd -m -u 1000 user
|
| 26 |
|
| 27 |
+
# Create necessary directories with proper permissions for nginx
|
| 28 |
+
RUN mkdir -p /var/log/nginx /var/lib/nginx /var/cache/nginx /run \
|
| 29 |
+
&& chown -R user:user /var/log/nginx /var/lib/nginx /var/cache/nginx /run \
|
| 30 |
+
&& chmod -R 755 /var/log/nginx /var/lib/nginx /var/cache/nginx /run
|
| 31 |
|
| 32 |
+
# Switch to the "user" user
|
| 33 |
+
USER user
|
| 34 |
+
|
| 35 |
+
# Set home to the user's home directory
|
| 36 |
+
ENV HOME=/home/user \
|
| 37 |
+
PATH=/home/user/.local/bin:$PATH
|
| 38 |
+
|
| 39 |
+
# Set the working directory to the user's home directory
|
| 40 |
+
WORKDIR $HOME/app
|
| 41 |
+
|
| 42 |
+
# Upgrade pip as user
|
| 43 |
+
RUN pip install --no-cache-dir --upgrade pip
|
| 44 |
+
|
| 45 |
+
# Install uv as user
|
| 46 |
RUN pip install --no-cache-dir uv
|
| 47 |
|
| 48 |
+
# Copy the project files with proper ownership
|
| 49 |
+
COPY --chown=user:user pyproject.toml ./
|
| 50 |
+
COPY --chown=user:user cua2-core/ ./cua2-core/
|
| 51 |
+
|
| 52 |
+
# Install Python dependencies
|
| 53 |
+
RUN uv sync --all-extras
|
| 54 |
|
| 55 |
+
# Copy frontend build with proper ownership
|
| 56 |
+
COPY --chown=user:user --from=frontend-builder /app/frontend/dist ./static
|
| 57 |
|
| 58 |
+
# Copy nginx config (user needs read access)
|
| 59 |
+
COPY --chown=user:user nginx.conf ./nginx.conf
|
| 60 |
|
| 61 |
+
# Copy entrypoint script with proper ownership and make it executable
|
| 62 |
+
COPY --chown=user:user entrypoint.sh ./entrypoint.sh
|
| 63 |
+
RUN chmod +x ./entrypoint.sh
|
| 64 |
|
| 65 |
EXPOSE 7860
|
| 66 |
|
|
|
|
| 69 |
ENV PORT=8000
|
| 70 |
|
| 71 |
# Use entrypoint script
|
| 72 |
+
ENTRYPOINT ["./entrypoint.sh"]
|
cua2-core/src/cua2_core/services/agent_service.py
CHANGED
|
@@ -193,28 +193,22 @@ class AgentService:
|
|
| 193 |
|
| 194 |
time.sleep(3)
|
| 195 |
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
):
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
):
|
| 213 |
-
previous_memory_step.observations_images = None
|
| 214 |
-
elif isinstance(previous_memory_step, TaskStep):
|
| 215 |
-
previous_memory_step.task_images = None
|
| 216 |
-
|
| 217 |
-
memory_step.observations_images = [image.copy()]
|
| 218 |
|
| 219 |
model_output = (
|
| 220 |
memory_step.model_output_message.content
|
|
|
|
| 193 |
|
| 194 |
time.sleep(3)
|
| 195 |
|
| 196 |
+
image = self.last_screenshot[message_id]
|
| 197 |
+
# agent.last_marked_screenshot = AgentImage(screenshot_path)
|
| 198 |
+
|
| 199 |
+
for previous_memory_step in (
|
| 200 |
+
agent.memory.steps
|
| 201 |
+
): # Remove previous screenshots from logs for lean processing
|
| 202 |
+
if (
|
| 203 |
+
isinstance(previous_memory_step, ActionStep)
|
| 204 |
+
and previous_memory_step.step_number is not None
|
| 205 |
+
and previous_memory_step.step_number <= memory_step.step_number - 1
|
| 206 |
+
):
|
| 207 |
+
previous_memory_step.observations_images = None
|
| 208 |
+
elif isinstance(previous_memory_step, TaskStep):
|
| 209 |
+
previous_memory_step.task_images = None
|
| 210 |
+
|
| 211 |
+
memory_step.observations_images = [image.copy()]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
|
| 213 |
model_output = (
|
| 214 |
memory_step.model_output_message.content
|
entrypoint.sh
CHANGED
|
@@ -3,7 +3,8 @@ set -e
|
|
| 3 |
|
| 4 |
echo "Starting CUA2 Application..."
|
| 5 |
|
| 6 |
-
|
|
|
|
| 7 |
|
| 8 |
sleep 2
|
| 9 |
|
|
@@ -13,8 +14,9 @@ if ! pgrep nginx > /dev/null; then
|
|
| 13 |
exit 1
|
| 14 |
fi
|
| 15 |
|
|
|
|
| 16 |
|
| 17 |
-
cd /app/cua2-core
|
| 18 |
|
| 19 |
# Set default number of workers if not specified
|
| 20 |
WORKERS=${WORKERS:-1}
|
|
|
|
| 3 |
|
| 4 |
echo "Starting CUA2 Application..."
|
| 5 |
|
| 6 |
+
# Start nginx in the background using the config from the app directory
|
| 7 |
+
nginx -c $HOME/app/nginx.conf -g 'daemon off;' &
|
| 8 |
|
| 9 |
sleep 2
|
| 10 |
|
|
|
|
| 14 |
exit 1
|
| 15 |
fi
|
| 16 |
|
| 17 |
+
echo "nginx started successfully"
|
| 18 |
|
| 19 |
+
cd $HOME/app/cua2-core
|
| 20 |
|
| 21 |
# Set default number of workers if not specified
|
| 22 |
WORKERS=${WORKERS:-1}
|
nginx.conf
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
-
user
|
|
|
|
| 2 |
worker_processes auto;
|
| 3 |
pid /run/nginx.pid;
|
| 4 |
|
|
@@ -29,7 +30,7 @@ http {
|
|
| 29 |
listen 7860;
|
| 30 |
server_name _;
|
| 31 |
|
| 32 |
-
root /app/static;
|
| 33 |
index index.html;
|
| 34 |
|
| 35 |
location / {
|
|
|
|
| 1 |
+
# Running as non-root user, so user directive is not needed
|
| 2 |
+
# user user;
|
| 3 |
worker_processes auto;
|
| 4 |
pid /run/nginx.pid;
|
| 5 |
|
|
|
|
| 30 |
listen 7860;
|
| 31 |
server_name _;
|
| 32 |
|
| 33 |
+
root /home/user/app/static;
|
| 34 |
index index.html;
|
| 35 |
|
| 36 |
location / {
|