Centralize session scope, chat projections and typed task bridges. Keep historical interaction replies authoritative and publish terminal state to subscribers. Validate Server contracts before replacing generated artifacts.
94 lines
3.6 KiB
Docker
94 lines
3.6 KiB
Docker
FROM ghcr.io/anomalyco/opencode:2.1.2@sha256:d91c668b3390b5416fee4803ffd0936ad30c3e118f550e7ad6d2fabc8b974b00 AS opencode2-bin
|
|
|
|
FROM oven/bun:1.4.3-slim@sha256:14a223fa35747ec728bce300ef85888bc5f7958164d15bbba6a54b22b52a3288 AS base
|
|
USER root
|
|
ARG UBUNTU_APT_MIRROR=mirrors.aliyun.com
|
|
ARG PYPI_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
|
|
ARG PYPI_TRUSTED_HOST=pypi.tuna.tsinghua.edu.cn
|
|
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
|
ENV VIRTUAL_ENV=/opt/venv
|
|
ENV PATH="$VIRTUAL_ENV/bin:/root/.local/bin:$PATH"
|
|
ENV PIP_INDEX_URL=${PYPI_INDEX_URL}
|
|
ENV PIP_TRUSTED_HOST=${PYPI_TRUSTED_HOST}
|
|
ENV UV_INDEX_URL=${PYPI_INDEX_URL}
|
|
ENV BUN_CONFIG_REGISTRY=${NPM_REGISTRY}
|
|
|
|
RUN sed -i "s|http://archive.ubuntu.com|https://${UBUNTU_APT_MIRROR}|g; s|http://security.ubuntu.com|https://${UBUNTU_APT_MIRROR}|g" /etc/apt/sources.list 2>/dev/null || true && \
|
|
sed -i "s|http://archive.ubuntu.com|https://${UBUNTU_APT_MIRROR}|g; s|http://security.ubuntu.com|https://${UBUNTU_APT_MIRROR}|g" /etc/apt/sources.list.d/*.sources 2>/dev/null || true && \
|
|
sed -i "s|http://deb.debian.org/debian-security|https://${UBUNTU_APT_MIRROR}/debian-security|g; s|http://deb.debian.org/debian|https://${UBUNTU_APT_MIRROR}/debian|g" /etc/apt/sources.list 2>/dev/null || true && \
|
|
sed -i "s|http://deb.debian.org/debian-security|https://${UBUNTU_APT_MIRROR}/debian-security|g; s|http://deb.debian.org/debian|https://${UBUNTU_APT_MIRROR}/debian|g" /etc/apt/sources.list.d/*.sources 2>/dev/null || true && \
|
|
apt-get -o Acquire::Retries=3 update && apt-get -o Acquire::Retries=3 install -y --no-install-recommends \
|
|
curl \
|
|
jq \
|
|
unzip \
|
|
python3 \
|
|
python3-venv \
|
|
libseccomp2 \
|
|
ripgrep && \
|
|
ln -sf /usr/bin/python3 /usr/local/bin/python && \
|
|
mkdir -p /root/.config/pip && \
|
|
printf "[global]\nindex-url = %s\ntrusted-host = %s\n" "$PIP_INDEX_URL" "$PIP_TRUSTED_HOST" > /root/.config/pip/pip.conf && \
|
|
python3 -m venv "$VIRTUAL_ENV" && \
|
|
pip install \
|
|
--index-url "$PIP_INDEX_URL" \
|
|
--trusted-host "$PIP_TRUSTED_HOST" \
|
|
uv \
|
|
pip \
|
|
setuptools \
|
|
wheel \
|
|
requests \
|
|
httpx \
|
|
pydantic \
|
|
python-dotenv \
|
|
rich \
|
|
ipython \
|
|
pytest && \
|
|
ln -s "$VIRTUAL_ENV/bin/uv" /usr/local/bin/uv && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
ENV PATH="/root/.bun/bin:$PATH"
|
|
COPY --from=opencode2-bin /lib/ld-musl-x86_64.so.1 /lib/ld-musl-x86_64.so.1
|
|
COPY --from=opencode2-bin /usr/lib/libgcc_s.so.1 /usr/lib/libgcc_s.so.1
|
|
COPY --from=opencode2-bin /usr/lib/libstdc++.so.6 /usr/lib/libstdc++.so.6
|
|
COPY --from=opencode2-bin /usr/lib/libstdc++.so.6.0.34 /usr/lib/libstdc++.so.6.0.34
|
|
COPY --from=opencode2-bin /usr/local/bin/opencode /usr/local/bin/opencode2
|
|
RUN opencode2 --version
|
|
|
|
FROM base AS deps
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json bun.lock ./
|
|
COPY .opencode/package.json .opencode/bun.lock ./.opencode/
|
|
RUN bun install --frozen-lockfile
|
|
|
|
FROM base AS build
|
|
WORKDIR /app
|
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY --from=deps /app/.opencode/node_modules ./.opencode/node_modules
|
|
COPY package.json bun.lock ./
|
|
COPY tsconfig.json opencode.json agent-models.json README.md .gitignore ./
|
|
COPY scripts ./scripts
|
|
COPY openapi ./openapi
|
|
COPY src ./src
|
|
COPY .opencode ./.opencode
|
|
RUN bun run check && bun run check:openapi
|
|
|
|
FROM build AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV HOST=0.0.0.0
|
|
ENV PORT=8787
|
|
|
|
COPY entrypoint.sh /entrypoint.sh
|
|
RUN chmod +x /entrypoint.sh
|
|
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
|
|
|
EXPOSE 8787
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
|
|
CMD curl --fail --silent --show-error "http://127.0.0.1:${PORT}/health" >/dev/null || exit 1
|
|
CMD ["bun", "src/server.ts"]
|