# Vibn IDE — Custom Theia workspace image
# Wraps the official Theia Blueprint with a startup script that:
#   1. Clones the project's Gitea repo on first boot (using GITEA_REPO + GITEA_TOKEN)
#   2. Starts Theia pre-loaded with the cloned folder open

FROM ghcr.io/eclipse-theia/theia-blueprint/theia-ide:latest

USER root

# git is needed for clone — install if not present
RUN apt-get update && apt-get install -y --no-install-recommends git && \
    rm -rf /var/lib/apt/lists/*

# Add startup script
COPY startup.sh /startup.sh
RUN chmod +x /startup.sh && \
    chown theia:theia /startup.sh

# Ensure workspace dir exists and is owned by theia
RUN mkdir -p /home/project && chown -R theia:theia /home/project

USER theia

EXPOSE 3000

ENTRYPOINT ["/startup.sh"]
