Spaces:
Paused
Paused
Upload folder using huggingface_hub
Browse files- .hfignore +1 -9
- Dockerfile +201 -43
- README.md +0 -10
- apps/server/src/index.ts +1 -23
- entrypoint.sh +17 -19
.hfignore
CHANGED
|
@@ -1,9 +1 @@
|
|
| 1 |
-
node_modules
|
| 2 |
-
.git
|
| 3 |
-
.npm
|
| 4 |
-
.cache
|
| 5 |
-
dist
|
| 6 |
-
apps/ui/dist
|
| 7 |
-
apps/server/dist
|
| 8 |
-
libs/*/dist
|
| 9 |
-
temp_repo
|
|
|
|
| 1 |
+
node_modules\n.git\n.npm\n.cache\ndist\napps/ui/dist\napps/server/dist\nlibs/*/dist\ntemp_repo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dockerfile
CHANGED
|
@@ -1,11 +1,75 @@
|
|
| 1 |
-
# Automaker
|
| 2 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
# Install
|
| 7 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
# Playwright/Chromium dependencies
|
| 10 |
libglib2.0-0 libnss3 libnspr4 libdbus-1-3 libatk1.0-0 libatk-bridge2.0-0 \
|
| 11 |
libcups2 libdrm2 libxkbcommon0 libatspi2.0-0 libxcomposite1 libxdamage1 \
|
|
@@ -13,10 +77,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 13 |
libx11-6 libx11-xcb1 libxcb1 libxext6 libxrender1 libxss1 libxtst6 \
|
| 14 |
libxshmfence1 libgtk-3-0 libexpat1 libfontconfig1 fonts-liberation \
|
| 15 |
xdg-utils libpangocairo-1.0-0 libpangoft2-1.0-0 libu2f-udev libvulkan1 \
|
| 16 |
-
&&
|
| 17 |
-
|
| 18 |
-
# Install GitHub CLI
|
| 19 |
-
RUN GH_VERSION="2.63.2" \
|
| 20 |
&& ARCH=$(uname -m) \
|
| 21 |
&& case "$ARCH" in \
|
| 22 |
x86_64) GH_ARCH="amd64" ;; \
|
|
@@ -26,54 +87,151 @@ RUN GH_VERSION="2.63.2" \
|
|
| 26 |
&& curl -L "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_${GH_ARCH}.tar.gz" -o gh.tar.gz \
|
| 27 |
&& tar -xzf gh.tar.gz \
|
| 28 |
&& mv gh_${GH_VERSION}_linux_${GH_ARCH}/bin/gh /usr/local/bin/gh \
|
| 29 |
-
&& rm -rf gh.tar.gz gh_${GH_VERSION}_linux_${GH_ARCH}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
# Set working directory
|
| 32 |
WORKDIR /app
|
| 33 |
|
| 34 |
-
#
|
|
|
|
| 35 |
|
| 36 |
-
#
|
| 37 |
-
|
| 38 |
-
RUN npm install && npm rebuild node-pty
|
| 39 |
-
RUN npm run build:packages && \
|
| 40 |
-
npm run build --workspace=apps/ui && \
|
| 41 |
-
npm run build --workspace=apps/server
|
| 42 |
|
| 43 |
-
#
|
| 44 |
-
|
| 45 |
-
|
| 46 |
|
| 47 |
-
#
|
| 48 |
-
|
| 49 |
-
mkdir -p /home/node/.local/bin && \
|
| 50 |
-
chown -R automaker:automaker /home/node
|
| 51 |
|
| 52 |
-
# Install
|
|
|
|
|
|
|
| 53 |
USER automaker
|
| 54 |
-
|
| 55 |
-
|
|
|
|
| 56 |
USER root
|
| 57 |
|
| 58 |
-
#
|
| 59 |
-
RUN
|
| 60 |
|
| 61 |
-
#
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
-
# Copy
|
| 65 |
-
COPY entrypoint.sh
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
| 68 |
|
| 69 |
# Environment variables
|
| 70 |
-
ENV PORT=
|
| 71 |
-
ENV DATA_DIR=/
|
| 72 |
-
ENV
|
| 73 |
-
|
|
|
|
| 74 |
|
| 75 |
# Expose port
|
| 76 |
-
EXPOSE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
-
|
| 79 |
-
ENTRYPOINT ["./entrypoint.sh"]
|
|
|
|
| 1 |
+
# Automaker Multi-Stage Dockerfile
|
| 2 |
+
# Single Dockerfile for both server and UI builds
|
| 3 |
+
# Usage:
|
| 4 |
+
# docker build --target server -t automaker-server .
|
| 5 |
+
# docker build --target ui -t automaker-ui .
|
| 6 |
+
# Or use docker-compose which selects targets automatically
|
| 7 |
|
| 8 |
+
# =============================================================================
|
| 9 |
+
# BASE STAGE - Common setup for all builds (DRY: defined once, used by all)
|
| 10 |
+
# =============================================================================
|
| 11 |
+
FROM node:22-slim AS base
|
| 12 |
|
| 13 |
+
# Install build dependencies for native modules (node-pty)
|
| 14 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 15 |
+
python3 make g++ \
|
| 16 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 17 |
+
|
| 18 |
+
WORKDIR /app
|
| 19 |
+
|
| 20 |
+
# Copy root package files
|
| 21 |
+
COPY package*.json ./
|
| 22 |
+
|
| 23 |
+
# Copy all libs package.json files (centralized - add new libs here)
|
| 24 |
+
COPY libs/types/package*.json ./libs/types/
|
| 25 |
+
COPY libs/utils/package*.json ./libs/utils/
|
| 26 |
+
COPY libs/prompts/package*.json ./libs/prompts/
|
| 27 |
+
COPY libs/platform/package*.json ./libs/platform/
|
| 28 |
+
COPY libs/spec-parser/package*.json ./libs/spec-parser/
|
| 29 |
+
COPY libs/model-resolver/package*.json ./libs/model-resolver/
|
| 30 |
+
COPY libs/dependency-resolver/package*.json ./libs/dependency-resolver/
|
| 31 |
+
COPY libs/git-utils/package*.json ./libs/git-utils/
|
| 32 |
+
COPY libs/spec-parser/package*.json ./libs/spec-parser/
|
| 33 |
+
|
| 34 |
+
# Copy scripts (needed by npm workspace)
|
| 35 |
+
COPY scripts ./scripts
|
| 36 |
+
|
| 37 |
+
# =============================================================================
|
| 38 |
+
# SERVER BUILD STAGE
|
| 39 |
+
# =============================================================================
|
| 40 |
+
FROM base AS server-builder
|
| 41 |
+
|
| 42 |
+
# Copy server-specific package.json
|
| 43 |
+
COPY apps/server/package*.json ./apps/server/
|
| 44 |
+
|
| 45 |
+
# Install dependencies (--ignore-scripts to skip husky/prepare, then rebuild native modules)
|
| 46 |
+
RUN npm ci --ignore-scripts && npm rebuild node-pty
|
| 47 |
+
|
| 48 |
+
# Copy all source files
|
| 49 |
+
COPY libs ./libs
|
| 50 |
+
COPY apps/server ./apps/server
|
| 51 |
+
|
| 52 |
+
# Build packages in dependency order, then build server
|
| 53 |
+
RUN npm run build:packages && npm run build --workspace=apps/server
|
| 54 |
+
|
| 55 |
+
# =============================================================================
|
| 56 |
+
# SERVER PRODUCTION STAGE
|
| 57 |
+
# =============================================================================
|
| 58 |
+
FROM node:22-slim AS server
|
| 59 |
+
|
| 60 |
+
# Build argument for tracking which commit this image was built from
|
| 61 |
+
ARG GIT_COMMIT_SHA=unknown
|
| 62 |
+
LABEL automaker.git.commit.sha="${GIT_COMMIT_SHA}"
|
| 63 |
+
|
| 64 |
+
# Build arguments for user ID matching (allows matching host user for mounted volumes)
|
| 65 |
+
# Override at build time: docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) ...
|
| 66 |
+
ARG UID=1001
|
| 67 |
+
ARG GID=1001
|
| 68 |
+
|
| 69 |
+
# Install git, curl, bash (for terminal), gosu (for user switching), and GitHub CLI (pinned version, multi-arch)
|
| 70 |
+
# Also install Playwright/Chromium system dependencies (aligns with playwright install-deps on Debian/Ubuntu)
|
| 71 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 72 |
+
git curl bash gosu ca-certificates openssh-client \
|
| 73 |
# Playwright/Chromium dependencies
|
| 74 |
libglib2.0-0 libnss3 libnspr4 libdbus-1-3 libatk1.0-0 libatk-bridge2.0-0 \
|
| 75 |
libcups2 libdrm2 libxkbcommon0 libatspi2.0-0 libxcomposite1 libxdamage1 \
|
|
|
|
| 77 |
libx11-6 libx11-xcb1 libxcb1 libxext6 libxrender1 libxss1 libxtst6 \
|
| 78 |
libxshmfence1 libgtk-3-0 libexpat1 libfontconfig1 fonts-liberation \
|
| 79 |
xdg-utils libpangocairo-1.0-0 libpangoft2-1.0-0 libu2f-udev libvulkan1 \
|
| 80 |
+
&& GH_VERSION="2.63.2" \
|
|
|
|
|
|
|
|
|
|
| 81 |
&& ARCH=$(uname -m) \
|
| 82 |
&& case "$ARCH" in \
|
| 83 |
x86_64) GH_ARCH="amd64" ;; \
|
|
|
|
| 87 |
&& curl -L "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_${GH_ARCH}.tar.gz" -o gh.tar.gz \
|
| 88 |
&& tar -xzf gh.tar.gz \
|
| 89 |
&& mv gh_${GH_VERSION}_linux_${GH_ARCH}/bin/gh /usr/local/bin/gh \
|
| 90 |
+
&& rm -rf gh.tar.gz gh_${GH_VERSION}_linux_${GH_ARCH} \
|
| 91 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 92 |
+
|
| 93 |
+
# Install Claude CLI globally (available to all users via npm global bin)
|
| 94 |
+
RUN npm install -g @anthropic-ai/claude-code
|
| 95 |
+
|
| 96 |
+
# Create non-root user with home directory BEFORE installing Cursor CLI
|
| 97 |
+
# Uses UID/GID build args to match host user for mounted volume permissions
|
| 98 |
+
# Use -o flag to allow non-unique IDs (GID 1000 may already exist as 'node' group)
|
| 99 |
+
RUN groupadd -o -g ${GID} automaker && \
|
| 100 |
+
useradd -o -u ${UID} -g automaker -m -d /home/automaker -s /bin/bash automaker && \
|
| 101 |
+
mkdir -p /home/automaker/.local/bin && \
|
| 102 |
+
mkdir -p /home/automaker/.cursor && \
|
| 103 |
+
chown -R automaker:automaker /home/automaker && \
|
| 104 |
+
chmod 700 /home/automaker/.cursor
|
| 105 |
+
|
| 106 |
+
# Install Cursor CLI as the automaker user
|
| 107 |
+
# Set HOME explicitly and install to /home/automaker/.local/bin/
|
| 108 |
+
USER automaker
|
| 109 |
+
ENV HOME=/home/automaker
|
| 110 |
+
RUN curl https://cursor.com/install -fsS | bash && \
|
| 111 |
+
echo "=== Checking Cursor CLI installation ===" && \
|
| 112 |
+
ls -la /home/automaker/.local/bin/ && \
|
| 113 |
+
echo "=== PATH is: $PATH ===" && \
|
| 114 |
+
(which cursor-agent && cursor-agent --version) || echo "cursor-agent installed (may need auth setup)"
|
| 115 |
+
|
| 116 |
+
# Install OpenCode CLI (for multi-provider AI model access)
|
| 117 |
+
RUN curl -fsSL https://opencode.ai/install | bash && \
|
| 118 |
+
echo "=== Checking OpenCode CLI installation ===" && \
|
| 119 |
+
ls -la /home/automaker/.local/bin/ && \
|
| 120 |
+
(which opencode && opencode --version) || echo "opencode installed (may need auth setup)"
|
| 121 |
+
|
| 122 |
+
USER root
|
| 123 |
+
|
| 124 |
+
# Add PATH to profile so it's available in all interactive shells (for login shells)
|
| 125 |
+
RUN mkdir -p /etc/profile.d && \
|
| 126 |
+
echo 'export PATH="/home/automaker/.local/bin:$PATH"' > /etc/profile.d/cursor-cli.sh && \
|
| 127 |
+
chmod +x /etc/profile.d/cursor-cli.sh
|
| 128 |
+
|
| 129 |
+
# Add to automaker's .bashrc for bash interactive shells
|
| 130 |
+
RUN echo 'export PATH="/home/automaker/.local/bin:$PATH"' >> /home/automaker/.bashrc && \
|
| 131 |
+
chown automaker:automaker /home/automaker/.bashrc
|
| 132 |
+
|
| 133 |
+
# Also add to root's .bashrc since docker exec defaults to root
|
| 134 |
+
RUN echo 'export PATH="/home/automaker/.local/bin:$PATH"' >> /root/.bashrc
|
| 135 |
|
|
|
|
| 136 |
WORKDIR /app
|
| 137 |
|
| 138 |
+
# Copy root package.json (needed for workspace resolution)
|
| 139 |
+
COPY --from=server-builder /app/package*.json ./
|
| 140 |
|
| 141 |
+
# Copy built libs (workspace packages are symlinked in node_modules)
|
| 142 |
+
COPY --from=server-builder /app/libs ./libs
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
+
# Copy built server
|
| 145 |
+
COPY --from=server-builder /app/apps/server/dist ./apps/server/dist
|
| 146 |
+
COPY --from=server-builder /app/apps/server/package*.json ./apps/server/
|
| 147 |
|
| 148 |
+
# Copy node_modules (includes symlinks to libs)
|
| 149 |
+
COPY --from=server-builder /app/node_modules ./node_modules
|
|
|
|
|
|
|
| 150 |
|
| 151 |
+
# Install Playwright Chromium browser for AI agent verification tests
|
| 152 |
+
# This adds ~300MB to the image but enables automated testing mode out of the box
|
| 153 |
+
# Using the locally installed playwright ensures we use the pinned version from package-lock.json
|
| 154 |
USER automaker
|
| 155 |
+
RUN ./node_modules/.bin/playwright install chromium && \
|
| 156 |
+
echo "=== Playwright Chromium installed ===" && \
|
| 157 |
+
ls -la /home/automaker/.cache/ms-playwright/
|
| 158 |
USER root
|
| 159 |
|
| 160 |
+
# Create data and projects directories
|
| 161 |
+
RUN mkdir -p /data /projects && chown automaker:automaker /data /projects
|
| 162 |
|
| 163 |
+
# Configure git for mounted volumes and authentication
|
| 164 |
+
# Use --system so it's not overwritten by mounted user .gitconfig
|
| 165 |
+
RUN git config --system --add safe.directory '*' && \
|
| 166 |
+
# Use gh as credential helper (works with GH_TOKEN env var)
|
| 167 |
+
git config --system credential.helper '!gh auth git-credential'
|
| 168 |
|
| 169 |
+
# Copy entrypoint script for fixing permissions on mounted volumes
|
| 170 |
+
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
| 171 |
+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
| 172 |
+
|
| 173 |
+
# Note: We stay as root here so entrypoint can fix permissions
|
| 174 |
+
# The entrypoint script will switch to automaker user before running the command
|
| 175 |
|
| 176 |
# Environment variables
|
| 177 |
+
ENV PORT=3008
|
| 178 |
+
ENV DATA_DIR=/data
|
| 179 |
+
ENV HOME=/home/automaker
|
| 180 |
+
# Add user's local bin to PATH for cursor-agent
|
| 181 |
+
ENV PATH="/home/automaker/.local/bin:${PATH}"
|
| 182 |
|
| 183 |
# Expose port
|
| 184 |
+
EXPOSE 3008
|
| 185 |
+
|
| 186 |
+
# Health check (using curl since it's already installed, more reliable than busybox wget)
|
| 187 |
+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
| 188 |
+
CMD curl -f http://localhost:3008/api/health || exit 1
|
| 189 |
+
|
| 190 |
+
# Use entrypoint to fix permissions before starting
|
| 191 |
+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
| 192 |
+
|
| 193 |
+
# Start server
|
| 194 |
+
CMD ["node", "apps/server/dist/index.js"]
|
| 195 |
+
|
| 196 |
+
# =============================================================================
|
| 197 |
+
# UI BUILD STAGE
|
| 198 |
+
# =============================================================================
|
| 199 |
+
FROM base AS ui-builder
|
| 200 |
+
|
| 201 |
+
# Copy UI-specific package.json
|
| 202 |
+
COPY apps/ui/package*.json ./apps/ui/
|
| 203 |
+
|
| 204 |
+
# Install dependencies (--ignore-scripts to skip husky and build:packages in prepare script)
|
| 205 |
+
RUN npm ci --ignore-scripts
|
| 206 |
+
|
| 207 |
+
# Copy all source files
|
| 208 |
+
COPY libs ./libs
|
| 209 |
+
COPY apps/ui ./apps/ui
|
| 210 |
+
|
| 211 |
+
# Build packages in dependency order, then build UI
|
| 212 |
+
# When VITE_SERVER_URL is empty, the UI uses relative URLs (e.g., /api/...) which nginx proxies
|
| 213 |
+
# to the server container. This avoids CORS issues entirely in Docker Compose setups.
|
| 214 |
+
# Override at build time if needed: --build-arg VITE_SERVER_URL=http://api.example.com
|
| 215 |
+
ARG VITE_SERVER_URL=
|
| 216 |
+
ENV VITE_SKIP_ELECTRON=true
|
| 217 |
+
ENV VITE_SERVER_URL=${VITE_SERVER_URL}
|
| 218 |
+
RUN npm run build:packages && npm run build --workspace=apps/ui
|
| 219 |
+
|
| 220 |
+
# =============================================================================
|
| 221 |
+
# UI PRODUCTION STAGE
|
| 222 |
+
# =============================================================================
|
| 223 |
+
FROM nginx:alpine AS ui
|
| 224 |
+
|
| 225 |
+
# Build argument for tracking which commit this image was built from
|
| 226 |
+
ARG GIT_COMMIT_SHA=unknown
|
| 227 |
+
LABEL automaker.git.commit.sha="${GIT_COMMIT_SHA}"
|
| 228 |
+
|
| 229 |
+
# Copy built files
|
| 230 |
+
COPY --from=ui-builder /app/apps/ui/dist /usr/share/nginx/html
|
| 231 |
+
|
| 232 |
+
# Copy nginx config for SPA routing
|
| 233 |
+
COPY apps/ui/nginx.conf /etc/nginx/conf.d/default.conf
|
| 234 |
+
|
| 235 |
+
EXPOSE 80
|
| 236 |
|
| 237 |
+
CMD ["nginx", "-g", "daemon off;"]
|
|
|
README.md
CHANGED
|
@@ -1,13 +1,3 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: Automaker
|
| 3 |
-
emoji: 🤖
|
| 4 |
-
colorFrom: blue
|
| 5 |
-
colorTo: indigo
|
| 6 |
-
sdk: docker
|
| 7 |
-
app_port: 7860
|
| 8 |
-
pinned: false
|
| 9 |
-
---
|
| 10 |
-
|
| 11 |
<p align="center">
|
| 12 |
<img src="apps/ui/public/readme_logo.svg" alt="Automaker Logo" height="80" />
|
| 13 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<p align="center">
|
| 2 |
<img src="apps/ui/public/readme_logo.svg" alt="Automaker Logo" height="80" />
|
| 3 |
</p>
|
apps/server/src/index.ts
CHANGED
|
@@ -283,8 +283,6 @@ function isLocalOrigin(origin: string): boolean {
|
|
| 283 |
hostname === '0.0.0.0' ||
|
| 284 |
hostname.startsWith('192.168.') ||
|
| 285 |
hostname.startsWith('10.') ||
|
| 286 |
-
hostname.endsWith('.hf.space') ||
|
| 287 |
-
hostname.endsWith('.huggingface.co') ||
|
| 288 |
/^172\.(1[6-9]|2[0-9]|3[0-1])\./.test(hostname)
|
| 289 |
);
|
| 290 |
} catch {
|
|
@@ -302,7 +300,7 @@ app.use(
|
|
| 302 |
}
|
| 303 |
|
| 304 |
// If CORS_ORIGIN is set, use it (can be comma-separated list)
|
| 305 |
-
const allowedOrigins = process.env.CORS_ORIGIN?.split(',')
|
| 306 |
.map((o) => o.trim())
|
| 307 |
.filter(Boolean);
|
| 308 |
if (allowedOrigins && allowedOrigins.length > 0) {
|
|
@@ -480,20 +478,6 @@ app.use('/api', requireJsonContentType);
|
|
| 480 |
|
| 481 |
// Mount API routes - health, auth, and setup are unauthenticated
|
| 482 |
app.use('/api/health', createHealthRoutes());
|
| 483 |
-
import path from 'path';
|
| 484 |
-
import { fileURLToPath } from 'url';
|
| 485 |
-
const __filename = fileURLToPath(import.meta.url);
|
| 486 |
-
const __dirname = path.dirname(__filename);
|
| 487 |
-
const UI_DIST_PATH = path.resolve(__dirname, '../../../apps/ui/dist');
|
| 488 |
-
app.use(express.static(UI_DIST_PATH));
|
| 489 |
-
app.get('/health', (_req, res) => res.status(200).json({ status: 'ok' }));
|
| 490 |
-
app.get('/api-docs', (_req, res) => res.status(200).json({
|
| 491 |
-
message: 'Automaker API Documentation',
|
| 492 |
-
endpoints: [
|
| 493 |
-
{ method: 'GET', path: '/api/health', purpose: 'Health Check' },
|
| 494 |
-
{ method: 'POST', path: '/api/auth/login', purpose: 'Login' }
|
| 495 |
-
]
|
| 496 |
-
}));
|
| 497 |
app.use('/api/auth', createAuthRoutes());
|
| 498 |
app.use('/api/setup', createSetupRoutes());
|
| 499 |
|
|
@@ -537,12 +521,6 @@ app.use(
|
|
| 537 |
'/api/projects',
|
| 538 |
createProjectsRoutes(featureLoader, autoModeService, settingsService, notificationService)
|
| 539 |
);
|
| 540 |
-
app.use((req, res, next) => {
|
| 541 |
-
if (req.path.startsWith('/api/') || req.path === '/health' || req.path === '/api-docs') {
|
| 542 |
-
return next();
|
| 543 |
-
}
|
| 544 |
-
res.sendFile(path.join(UI_DIST_PATH, 'index.html'));
|
| 545 |
-
});
|
| 546 |
|
| 547 |
// Create HTTP server
|
| 548 |
const server = createServer(app);
|
|
|
|
| 283 |
hostname === '0.0.0.0' ||
|
| 284 |
hostname.startsWith('192.168.') ||
|
| 285 |
hostname.startsWith('10.') ||
|
|
|
|
|
|
|
| 286 |
/^172\.(1[6-9]|2[0-9]|3[0-1])\./.test(hostname)
|
| 287 |
);
|
| 288 |
} catch {
|
|
|
|
| 300 |
}
|
| 301 |
|
| 302 |
// If CORS_ORIGIN is set, use it (can be comma-separated list)
|
| 303 |
+
const allowedOrigins = process.env.CORS_ORIGIN?.split(',')
|
| 304 |
.map((o) => o.trim())
|
| 305 |
.filter(Boolean);
|
| 306 |
if (allowedOrigins && allowedOrigins.length > 0) {
|
|
|
|
| 478 |
|
| 479 |
// Mount API routes - health, auth, and setup are unauthenticated
|
| 480 |
app.use('/api/health', createHealthRoutes());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 481 |
app.use('/api/auth', createAuthRoutes());
|
| 482 |
app.use('/api/setup', createSetupRoutes());
|
| 483 |
|
|
|
|
| 521 |
'/api/projects',
|
| 522 |
createProjectsRoutes(featureLoader, autoModeService, settingsService, notificationService)
|
| 523 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 524 |
|
| 525 |
// Create HTTP server
|
| 526 |
const server = createServer(app);
|
entrypoint.sh
CHANGED
|
@@ -6,39 +6,37 @@ echo "Starting Automaker entrypoint script..."
|
|
| 6 |
# Ensure DATA_DIR exists
|
| 7 |
mkdir -p "$DATA_DIR"
|
| 8 |
|
| 9 |
-
# Configure OpenCode
|
| 10 |
-
if [ -n "$OPENCODE_AUTH_TOKEN" ]; then
|
| 11 |
-
echo "
|
| 12 |
-
|
| 13 |
-
# Use the CLI to login if possible, or manually create the config
|
| 14 |
-
# Since opencode auth login is interactive, we might need to simulate it or use the config file approach
|
| 15 |
mkdir -p "$HOME/.local/share/opencode"
|
| 16 |
-
echo "{\"opencode\": {\"type\": \"api\", \"key\": \"$OPENCODE_AUTH_TOKEN\"}}" > "$HOME/.local/share/opencode/auth.json"
|
| 17 |
|
| 18 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
if [ -n "$BLABLADOR_API_KEY" ]; then
|
| 20 |
-
echo "
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
# opencode provider add helmholtz --endpoint https://api.helmholtz-blablador.fz-juelich.de/v1 --api-key $BLABLADOR_API_KEY
|
| 24 |
-
|
| 25 |
-
# Or update auth.json manually to be sure
|
| 26 |
-
AUTH_JSON=$(cat "$HOME/.local/share/opencode/auth.json")
|
| 27 |
-
NEW_AUTH_JSON=$(echo "$AUTH_JSON" | jq ". + {\"helmholtz\": {\"type\": \"api\", \"key\": \"$BLABLADOR_API_KEY\", \"baseURL\": \"https://api.helmholtz-blablador.fz-juelich.de/v1\"}}")
|
| 28 |
-
echo "$NEW_AUTH_JSON" > "$HOME/.local/share/opencode/auth.json"
|
| 29 |
-
|
| 30 |
-
# Set Helmholtz alias-code as the default model in Automaker settings
|
| 31 |
python3 /usr/local/bin/update_settings.py "$DATA_DIR" "helmholtz/alias-code"
|
| 32 |
echo "Helmholtz provider and default model configured."
|
| 33 |
fi
|
|
|
|
|
|
|
|
|
|
| 34 |
else
|
| 35 |
-
echo "
|
| 36 |
fi
|
| 37 |
|
| 38 |
# Configure GitHub CLI authentication if token is provided
|
| 39 |
if [ -n "$GITHUB_API_TOKEN" ]; then
|
| 40 |
echo "GITHUB_API_TOKEN detected, configuring GitHub CLI..."
|
| 41 |
export GH_TOKEN="$GITHUB_API_TOKEN"
|
|
|
|
| 42 |
fi
|
| 43 |
|
| 44 |
# Start the application
|
|
|
|
| 6 |
# Ensure DATA_DIR exists
|
| 7 |
mkdir -p "$DATA_DIR"
|
| 8 |
|
| 9 |
+
# Configure OpenCode & Helmholtz authentication
|
| 10 |
+
if [ -n "$OPENCODE_AUTH_TOKEN" ] || [ -n "$BLABLADOR_API_KEY" ]; then
|
| 11 |
+
echo "Authentication tokens detected, configuring providers..."
|
|
|
|
|
|
|
|
|
|
| 12 |
mkdir -p "$HOME/.local/share/opencode"
|
|
|
|
| 13 |
|
| 14 |
+
# Initialize base JSON
|
| 15 |
+
AUTH_JSON="{}"
|
| 16 |
+
|
| 17 |
+
if [ -n "$OPENCODE_AUTH_TOKEN" ]; then
|
| 18 |
+
AUTH_JSON=$(echo "$AUTH_JSON" | jq ". + {\"opencode\": {\"type\": \"api\", \"key\": \"$OPENCODE_AUTH_TOKEN\"}}")
|
| 19 |
+
fi
|
| 20 |
+
|
| 21 |
if [ -n "$BLABLADOR_API_KEY" ]; then
|
| 22 |
+
AUTH_JSON=$(echo "$AUTH_JSON" | jq ". + {\"helmholtz\": {\"type\": \"api\", \"key\": \"$BLABLADOR_API_KEY\", \"baseURL\": \"https://api.helmholtz-blablador.fz-juelich.de/v1\"}}")
|
| 23 |
|
| 24 |
+
# Configure the app settings to use Helmholtz alias-code model by default
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
python3 /usr/local/bin/update_settings.py "$DATA_DIR" "helmholtz/alias-code"
|
| 26 |
echo "Helmholtz provider and default model configured."
|
| 27 |
fi
|
| 28 |
+
|
| 29 |
+
echo "$AUTH_JSON" > "$HOME/.local/share/opencode/auth.json"
|
| 30 |
+
echo "Provider authentication configured."
|
| 31 |
else
|
| 32 |
+
echo "No provider tokens set, skipping auto-login."
|
| 33 |
fi
|
| 34 |
|
| 35 |
# Configure GitHub CLI authentication if token is provided
|
| 36 |
if [ -n "$GITHUB_API_TOKEN" ]; then
|
| 37 |
echo "GITHUB_API_TOKEN detected, configuring GitHub CLI..."
|
| 38 |
export GH_TOKEN="$GITHUB_API_TOKEN"
|
| 39 |
+
echo "GitHub CLI token exported."
|
| 40 |
fi
|
| 41 |
|
| 42 |
# Start the application
|