ar08 commited on
Commit
8c0ea63
·
verified ·
1 Parent(s): c8f1f2a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +96 -97
Dockerfile CHANGED
@@ -1,98 +1,97 @@
1
- ARG OPENHANDS_BUILD_VERSION=dev
2
- FROM node:21.7.2-bookworm-slim AS frontend-builder
3
-
4
- WORKDIR /app
5
-
6
- COPY ./frontend/package.json frontend/package-lock.json ./
7
- RUN npm install -g [email protected]
8
- RUN npm ci
9
-
10
- COPY ./frontend ./
11
- RUN npm run build
12
-
13
- FROM python:3.12.3-slim AS backend-builder
14
-
15
- WORKDIR /app
16
- ENV PYTHONPATH='/app'
17
-
18
- ENV POETRY_NO_INTERACTION=1 \
19
- POETRY_VIRTUALENVS_IN_PROJECT=1 \
20
- POETRY_VIRTUALENVS_CREATE=1 \
21
- POETRY_CACHE_DIR=/tmp/poetry_cache
22
-
23
- RUN apt-get update -y \
24
- && apt-get install -y curl make git build-essential \
25
- && python3 -m pip install poetry==1.8.2 --break-system-packages
26
-
27
- COPY ./pyproject.toml ./poetry.lock ./
28
- RUN touch README.md
29
- RUN export POETRY_CACHE_DIR && poetry install --without evaluation,llama-index --no-root && rm -rf $POETRY_CACHE_DIR
30
-
31
- FROM python:3.12.3-slim AS openhands-app
32
-
33
- WORKDIR /app
34
-
35
- ARG OPENHANDS_BUILD_VERSION #re-declare for this section
36
-
37
- ENV RUN_AS_OPENHANDS=true
38
- # A random number--we need this to be different from the user's UID on the host machine
39
- ENV OPENHANDS_USER_ID=42420
40
- ENV SANDBOX_LOCAL_RUNTIME_URL=http://host.docker.internal
41
- ENV USE_HOST_NETWORK=false
42
- ENV WORKSPACE_BASE=/opt/workspace_base
43
- ENV OPENHANDS_BUILD_VERSION=$OPENHANDS_BUILD_VERSION
44
- ENV SANDBOX_USER_ID=0
45
- ENV FILE_STORE=local
46
- ENV FILE_STORE_PATH=/.openhands-state
47
- RUN mkdir -p $FILE_STORE_PATH
48
- RUN mkdir -p $WORKSPACE_BASE
49
-
50
- RUN apt-get update -y \
51
- && apt-get install -y curl ssh sudo
52
-
53
- # Default is 1000, but OSX is often 501
54
- RUN sed -i 's/^UID_MIN.*/UID_MIN 499/' /etc/login.defs
55
- # Default is 60000, but we've seen up to 200000
56
- RUN sed -i 's/^UID_MAX.*/UID_MAX 1000000/' /etc/login.defs
57
-
58
- RUN groupadd app
59
- RUN useradd -l -m -u $OPENHANDS_USER_ID -s /bin/bash openhands && \
60
- usermod -aG app openhands && \
61
- usermod -aG sudo openhands && \
62
- echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
63
- RUN chown -R openhands:app /app && chmod -R 770 /app
64
- RUN sudo chown -R openhands:app $WORKSPACE_BASE && sudo chmod -R 770 $WORKSPACE_BASE
65
- USER openhands
66
-
67
- ENV VIRTUAL_ENV=/app/.venv \
68
- PATH="/app/.venv/bin:$PATH" \
69
- PYTHONPATH='/app'
70
-
71
- COPY --chown=openhands:app --chmod=770 --from=backend-builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
72
- RUN playwright install --with-deps chromium
73
-
74
- COPY --chown=openhands:app --chmod=770 ./microagents ./microagents
75
- COPY --chown=openhands:app --chmod=770 ./openhands ./openhands
76
- COPY --chown=openhands:app --chmod=777 ./openhands/runtime/plugins ./openhands/runtime/plugins
77
- COPY --chown=openhands:app --chmod=770 ./openhands/agenthub ./openhands/agenthub
78
- COPY --chown=openhands:app ./pyproject.toml ./pyproject.toml
79
- COPY --chown=openhands:app ./poetry.lock ./poetry.lock
80
- COPY --chown=openhands:app ./README.md ./README.md
81
- COPY --chown=openhands:app ./MANIFEST.in ./MANIFEST.in
82
- COPY --chown=openhands:app ./LICENSE ./LICENSE
83
-
84
- # This is run as "openhands" user, and will create __pycache__ with openhands:openhands ownership
85
- RUN python openhands/core/download.py # No-op to download assets
86
- # Add this line to set group ownership of all files/directories not already in "app" group
87
- # openhands:openhands -> openhands:app
88
- RUN find /app \! -group app -exec chgrp app {} +
89
-
90
- COPY --chown=openhands:app --chmod=770 --from=frontend-builder /app/build ./frontend/build
91
- COPY --chown=openhands:app --chmod=770 ./containers/app/entrypoint.sh /app/entrypoint.sh
92
-
93
- USER root
94
-
95
- WORKDIR /app
96
-
97
- ENTRYPOINT ["/app/entrypoint.sh"]
98
  CMD ["uvicorn", "openhands.server.listen:app", "--host", "0.0.0.0", "--port", "3000"]
 
1
+ ARG OPENHANDS_BUILD_VERSION=dev
2
+ FROM node:21.7.2-bookworm-slim AS frontend-builder
3
+
4
+ WORKDIR /app
5
+
6
+ COPY ./frontend/package.json frontend/package-lock.json ./
7
+ RUN npm install -g [email protected]
8
+ RUN npm ci
9
+
10
+ COPY ./frontend ./
11
+ RUN npm run build
12
+
13
+ FROM python:3.12.3-slim AS backend-builder
14
+
15
+ WORKDIR /app
16
+ ENV PYTHONPATH='/app'
17
+
18
+ ENV POETRY_NO_INTERACTION=1 \
19
+ POETRY_VIRTUALENVS_IN_PROJECT=1 \
20
+ POETRY_VIRTUALENVS_CREATE=1 \
21
+ POETRY_CACHE_DIR=/tmp/poetry_cache
22
+
23
+ RUN apt-get update -y \
24
+ && apt-get install -y curl make git build-essential \
25
+ && python3 -m pip install poetry==1.8.2 --break-system-packages
26
+
27
+ COPY ./pyproject.toml ./poetry.lock ./
28
+ RUN touch README.md
29
+ RUN export POETRY_CACHE_DIR && poetry install --without evaluation,llama-index --no-root && rm -rf $POETRY_CACHE_DIR
30
+
31
+ FROM python:3.12.3-slim AS openhands-app
32
+
33
+ WORKDIR /app
34
+
35
+ ARG OPENHANDS_BUILD_VERSION #re-declare for this section
36
+
37
+ ENV RUN_AS_OPENHANDS=true
38
+ # A random number--we need this to be different from the user's UID on the host machine
39
+ ENV OPENHANDS_USER_ID=42420
40
+ ENV SANDBOX_LOCAL_RUNTIME_URL=http://host.docker.internal
41
+ ENV USE_HOST_NETWORK=false
42
+ ENV WORKSPACE_BASE=/opt/workspace_base
43
+ ENV OPENHANDS_BUILD_VERSION=$OPENHANDS_BUILD_VERSION
44
+ ENV SANDBOX_USER_ID=0
45
+ ENV FILE_STORE=local
46
+ ENV FILE_STORE_PATH=/.openhands-state
47
+ RUN mkdir -p $FILE_STORE_PATH
48
+ RUN mkdir -p $WORKSPACE_BASE
49
+
50
+ RUN apt-get update -y \
51
+ && apt-get install -y curl ssh sudo
52
+
53
+ # Default is 1000, but OSX is often 501
54
+ RUN sed -i 's/^UID_MIN.*/UID_MIN 499/' /etc/login.defs
55
+ # Default is 60000, but we've seen up to 200000
56
+ RUN sed -i 's/^UID_MAX.*/UID_MAX 1000000/' /etc/login.defs
57
+
58
+ RUN groupadd app
59
+ RUN useradd -l -m -u $OPENHANDS_USER_ID -s /bin/bash openhands && \
60
+ usermod -aG app openhands && \
61
+ usermod -aG sudo openhands && \
62
+ echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
63
+ RUN chown -R openhands:app /app && chmod -R 770 /app
64
+ RUN sudo chown -R openhands:app $WORKSPACE_BASE && sudo chmod -R 770 $WORKSPACE_BASE
65
+ USER openhands
66
+
67
+ ENV VIRTUAL_ENV=/app/.venv \
68
+ PATH="/app/.venv/bin:$PATH" \
69
+ PYTHONPATH='/app'
70
+
71
+ COPY --chown=openhands:app --chmod=770 --from=backend-builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
72
+ RUN playwright install --with-deps chromium
73
+
74
+ COPY --chown=openhands:app --chmod=770 ./microagents ./microagents
75
+ COPY --chown=openhands:app --chmod=770 ./openhands ./openhands
76
+ COPY --chown=openhands:app --chmod=777 ./openhands/runtime/plugins ./openhands/runtime/plugins
77
+ COPY --chown=openhands:app --chmod=770 ./openhands/agenthub ./openhands/agenthub
78
+ COPY --chown=openhands:app ./pyproject.toml ./pyproject.toml
79
+ COPY --chown=openhands:app ./poetry.lock ./poetry.lock
80
+ COPY --chown=openhands:app ./README.md ./README.md
81
+ COPY --chown=openhands:app ./MANIFEST.in ./MANIFEST.in
82
+ COPY --chown=openhands:app ./LICENSE ./LICENSE
83
+
84
+ # This is run as "openhands" user, and will create __pycache__ with openhands:openhands ownership
85
+ RUN python openhands/core/download.py # No-op to download assets
86
+ # Add this line to set group ownership of all files/directories not already in "app" group
87
+ # openhands:openhands -> openhands:app
88
+ RUN find /app \! -group app -exec chgrp app {} +
89
+
90
+ COPY --chown=openhands:app --chmod=770 --from=frontend-builder /app/build ./frontend/build
91
+ COPY --chown=openhands:app --chmod=770 ./containers/app/entrypoint.sh /app/entrypoint.sh
92
+
93
+ USER root
94
+
95
+ WORKDIR /app
96
+
 
97
  CMD ["uvicorn", "openhands.server.listen:app", "--host", "0.0.0.0", "--port", "3000"]