| |
| FROM node:20-alpine |
|
|
| |
| RUN apk add --no-cache gcompat |
|
|
| |
| RUN apk add --no-cache git curl |
|
|
| |
| RUN addgroup -g 1001 -S opencode && \ |
| adduser -S opencode -u 1001 |
|
|
| |
| |
| RUN npm install -g opencode-ai@latest && \ |
| if [ ! -f /usr/local/lib/node_modules/opencode-ai/node_modules/opencode-linux-x64/bin/opencode ]; then \ |
| cd /usr/local/lib/node_modules/opencode-ai && \ |
| npm run postinstall; \ |
| fi |
|
|
| |
| WORKDIR /app |
| COPY --chown=opencode:opencode package*.json ./ |
| COPY --chown=opencode:opencode . /app |
| RUN if [ -f package.json ]; then npm ci --only=production; fi |
|
|
| |
| RUN chown -R opencode:opencode /app /home/opencode |
|
|
| |
| USER opencode |
| RUN mkdir -p /home/opencode/.local/bin |
| RUN printf '#!/bin/sh\n\ |
| echo "Starting OpenCode AI Web Server ..."\n\ |
| exec /usr/local/bin/opencode serve --hostname 0.0.0.0 --port 7860\n' > /home/opencode/.local/bin/start.sh && \ |
| chmod +x /home/opencode/.local/bin/start.sh |
|
|
| |
| EXPOSE 7860 |
| HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ |
| CMD curl -f http://localhost:7860/health || exit 1 |
|
|
| CMD ["/home/opencode/.local/bin/start.sh"] |