Dockerfile
1 # Copyright 2026 Alibaba Group Holding Ltd. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 FROM python:3.10-slim AS builder 16 17 ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \ 18 PYTHONDONTWRITEBYTECODE=1 \ 19 PYTHONUNBUFFERED=1 \ 20 UV_PROJECT_ENV=/app/.venv \ 21 UV_LINK_MODE=copy 22 23 WORKDIR /app 24 25 RUN apt-get update \ 26 && apt-get install -y --no-install-recommends curl ca-certificates \ 27 && rm -rf /var/lib/apt/lists/* 28 29 RUN curl -LsSf https://astral.sh/uv/install.sh | sh 30 ENV PATH="/root/.local/bin:/root/.cargo/bin:${PATH}" 31 32 COPY pyproject.toml uv.lock ./ 33 RUN uv sync --frozen --no-dev --no-install-project 34 35 COPY opensandbox_server ./opensandbox_server 36 COPY LICENSE README.md ./ 37 38 # Install the project itself into the venv (deps already synced) 39 RUN uv pip install --no-deps --editable . 40 41 FROM python:3.10-slim AS runtime 42 43 ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \ 44 PYTHONDONTWRITEBYTECODE=1 \ 45 PYTHONUNBUFFERED=1 \ 46 UV_PROJECT_ENV=/app/.venv \ 47 PATH="/app/.venv/bin:${PATH}" \ 48 SANDBOX_CONFIG_PATH=/etc/opensandbox/config.toml 49 50 WORKDIR /app 51 52 COPY --from=builder /app/.venv /app/.venv 53 COPY --from=builder /app/opensandbox_server /app/opensandbox_server 54 COPY --from=builder /app/opensandbox_server/examples/example.config.k8s.toml /etc/opensandbox/config.toml 55 COPY --from=builder /app/opensandbox_server/examples/example.config.k8s.zh.toml /etc/opensandbox/config.zh.toml 56 COPY --from=builder /app/opensandbox_server/examples/example.batchsandbox-template.yaml /etc/opensandbox/example.batchsandbox-template.yaml 57 COPY --from=builder /app/opensandbox_server/examples/e2e.batchsandbox-template.yaml /etc/opensandbox/e2e.batchsandbox-template.yaml 58 59 EXPOSE 8080 60 61 ENTRYPOINT ["opensandbox-server"] 62 CMD ["--config", "/etc/opensandbox/config.toml"]