Files
opencode-manager/Dockerfile
T
Chris Scott 1b4c4f2c30 Fix SQLite readonly: entrypoint must run as root to fix volume permissions
Entrypoint ran as USER node (inherited from Dockerfile) so chown
silently failed with EPERM. SQLite needs write access to the directory
to create WAL/journal files alongside the database.

- Remove USER node from Dockerfile so entrypoint runs as root
- Restore mkdir /app/data + chown for fresh volume initialization
- Entrypoint now fixes ownership then drops to node via runuser before exec
2026-04-07 23:19:51 -04:00

107 lines
3.3 KiB
Docker

FROM node:24.13.0 AS base
RUN apt-get update && apt-get install -y \
git \
curl \
lsof \
ripgrep \
ca-certificates \
grep \
gawk \
sed \
findutils \
coreutils \
procps \
jq \
less \
tree \
file \
python3 \
python3-pip \
python3-venv \
&& rm -rf /var/lib/apt/lists/*
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& apt-get update && apt-get install -y gh \
&& rm -rf /var/lib/apt/lists/*
RUN corepack enable && corepack prepare pnpm@latest --activate
RUN curl -fsSL https://bun.sh/install | bash && \
mv /root/.bun /opt/bun && \
chmod -R 755 /opt/bun && \
ln -s /opt/bun/bin/bun /usr/local/bin/bun
WORKDIR /app
FROM base AS deps
COPY --chown=node:node package.json pnpm-workspace.yaml pnpm-lock.yaml ./
COPY --chown=node:node shared/package.json ./shared/
COPY --chown=node:node backend/package.json ./backend/
COPY --chown=node:node frontend/package.json ./frontend/
RUN pnpm install --frozen-lockfile
FROM base AS builder
COPY --from=deps /app ./
COPY shared ./shared
COPY backend ./backend
COPY frontend/src ./frontend/src
COPY frontend/public ./frontend/public
COPY frontend/index.html frontend/vite.config.ts frontend/tsconfig*.json frontend/components.json frontend/eslint.config.js ./frontend/
RUN pnpm --filter frontend build
FROM base AS runner
ARG UV_VERSION=latest
ARG OPENCODE_VERSION=latest
RUN echo "Installing uv=${UV_VERSION} opencode=${OPENCODE_VERSION}" && \
curl -LsSf https://astral.sh/uv/install.sh | UV_NO_MODIFY_PATH=1 sh && \
mv /root/.local/bin/uv /usr/local/bin/uv && \
mv /root/.local/bin/uvx /usr/local/bin/uvx && \
chmod +x /usr/local/bin/uv /usr/local/bin/uvx && \
if [ "${OPENCODE_VERSION}" = "latest" ]; then \
curl -fsSL https://opencode.ai/install | bash -s -- --no-modify-path; \
else \
curl -fsSL https://opencode.ai/install | bash -s -- --version ${OPENCODE_VERSION} --no-modify-path; \
fi && \
mv /root/.opencode /opt/opencode && \
chmod -R 755 /opt/opencode && \
ln -s /opt/opencode/bin/opencode /usr/local/bin/opencode
ENV NODE_ENV=production
ENV HOST=0.0.0.0
ENV PORT=5003
ENV OPENCODE_SERVER_PORT=5551
ENV DATABASE_PATH=/app/data/opencode.db
ENV WORKSPACE_PATH=/workspace
COPY --from=deps --chown=node:node /app/node_modules ./node_modules
COPY --from=builder /app/shared ./shared
COPY --from=builder /app/backend ./backend
COPY --from=builder /app/frontend/dist ./frontend/dist
COPY package.json pnpm-workspace.yaml ./
RUN mkdir -p /app/backend/node_modules/@opencode-manager && \
ln -s /app/shared /app/backend/node_modules/@opencode-manager/shared
COPY scripts/docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
RUN mkdir -p /workspace /app/data && \
chown -R node:node /workspace /app/data
EXPOSE 5003 5100 5101 5102 5103
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD curl -f http://localhost:5003/api/health || exit 1
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["bun", "backend/src/index.ts"]