FROM alpine:latest

# 安裝必要的工具
RUN apk add --no-cache --no-check-certificate bash ca-certificates curl git

# 設定安裝用的環境變數
ENV CODEX_NON_INTERACTIVE=1
ENV CODEX_INSTALL_DIR=/usr/local/bin
ENV CODEX_HOME=/root/.codex

# 安裝 Codex CLI 工具
RUN curl -fsSL https://chatgpt.com/codex/install.sh | sh

# 安裝 doc 技能
RUN codex plugin marketplace add https://gitea.jsc.idv.tw/plugins/doc.git \
    && codex plugin add jsc@doc

# 安裝 code-review 技能
RUN codex plugin marketplace add https://gitea.jsc.idv.tw/plugins/code-review.git \
    && codex plugin add jsc@code-review

COPY entrypoint.sh /entrypoint.sh

RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
