fix error
Browse files- Dockerfile +22 -26
- lib/env-config.ts +7 -1
Dockerfile
CHANGED
|
@@ -1,61 +1,56 @@
|
|
| 1 |
FROM docker.io/library/node:20-bookworm-slim@sha256:1e85773c98c31d4fe5b545e4cb17379e617b348832fb3738b22a08f68dec30f3
|
| 2 |
|
| 3 |
-
# 1. System Baseline &
|
| 4 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 5 |
ENV HOME=/home/node
|
| 6 |
ENV WORKSPACE_ROOT=/app/workspaces
|
| 7 |
ENV ANDROID_SDK_ROOT=/app/android-sdk
|
| 8 |
ENV PATH="/home/node/.nix-profile/bin:/usr/local/bin:${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin:${ANDROID_SDK_ROOT}/platform-tools:${PATH}"
|
|
|
|
| 9 |
|
| 10 |
-
# 2. Optimized Layering (
|
| 11 |
-
#
|
| 12 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 13 |
python3 python3-pip make g++ git curl ca-certificates tar unzip bzip2 xz-utils procps net-tools iptables \
|
|
|
|
|
|
|
| 14 |
&& rm -rf /var/lib/apt/lists/*
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
RUN curl -fL https://github.com/coder/code-server/releases/download/v4.114.0/code-server-4.114.0-linux-amd64.tar.gz \
|
| 18 |
| tar -C /usr/local/lib -xz \
|
| 19 |
&& ln -s /usr/local/lib/code-server-4.114.0-linux-amd64/bin/code-server /usr/local/bin/code-server
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
RUN
|
| 23 |
-
xvfb fluxbox novnc websockify libnss3 libatk-bridge2.0-0 \
|
| 24 |
-
libcups2 libgtk-3-0 \
|
| 25 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 26 |
-
|
| 27 |
-
# - Android Preview Engine: JRE (Smaller than JDK)
|
| 28 |
-
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 29 |
-
openjdk-17-jre-headless \
|
| 30 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 31 |
-
|
| 32 |
-
# 3. Determinate Systems Nix Installer (Unprivileged Resilience)
|
| 33 |
-
RUN curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux \
|
| 34 |
--init none --no-confirm --no-modify-profile --extra-conf "experimental-features = nix-command flakes" \
|
| 35 |
--extra-conf "sandbox = false" \
|
| 36 |
&& chown -R node:node /nix /home/node
|
| 37 |
|
| 38 |
-
#
|
| 39 |
RUN pip3 install --no-cache-dir huggingface-hub --break-system-packages \
|
| 40 |
-
&& curl -fL https://cachix.org/api/v1/install | sh
|
| 41 |
|
| 42 |
-
#
|
|
|
|
| 43 |
WORKDIR /app
|
| 44 |
RUN mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools && \
|
| 45 |
-
curl -fL https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip -o cmdline.zip && \
|
| 46 |
-
unzip cmdline.zip -d ${ANDROID_SDK_ROOT}/cmdline-tools && \
|
| 47 |
mv ${ANDROID_SDK_ROOT}/cmdline-tools/cmdline-tools ${ANDROID_SDK_ROOT}/cmdline-tools/latest && \
|
| 48 |
rm cmdline.zip && \
|
| 49 |
yes | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=${ANDROID_SDK_ROOT} "platform-tools" "platforms;android-33"
|
| 50 |
|
| 51 |
-
#
|
| 52 |
WORKDIR /app
|
| 53 |
COPY package*.json ./
|
| 54 |
-
|
|
|
|
| 55 |
|
| 56 |
COPY . .
|
| 57 |
|
| 58 |
-
#
|
|
|
|
| 59 |
RUN npm run build && \
|
| 60 |
mkdir -p ${WORKSPACE_ROOT} && \
|
| 61 |
chown -R node:node /app ${WORKSPACE_ROOT}
|
|
@@ -67,5 +62,6 @@ EXPOSE 7860
|
|
| 67 |
LABEL idx.studio.version="2026.04"
|
| 68 |
LABEL idx.optimization.cachix="true"
|
| 69 |
LABEL idx.build.optimized="true"
|
|
|
|
| 70 |
|
| 71 |
CMD ["npm", "run", "start"]
|
|
|
|
| 1 |
FROM docker.io/library/node:20-bookworm-slim@sha256:1e85773c98c31d4fe5b545e4cb17379e617b348832fb3738b22a08f68dec30f3
|
| 2 |
|
| 3 |
+
# 1. System Baseline & Build-Time Acceleration
|
| 4 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 5 |
ENV HOME=/home/node
|
| 6 |
ENV WORKSPACE_ROOT=/app/workspaces
|
| 7 |
ENV ANDROID_SDK_ROOT=/app/android-sdk
|
| 8 |
ENV PATH="/home/node/.nix-profile/bin:/usr/local/bin:${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin:${ANDROID_SDK_ROOT}/platform-tools:${PATH}"
|
| 9 |
+
ENV NEXT_TELEMETRY_DISABLED=1
|
| 10 |
|
| 11 |
+
# 2. Optimized Layering (Reducing redundancy & Adding Retry Resilience)
|
| 12 |
+
# Combine baseline CLI + Desktop UI + OpenJDK to save build time and layers
|
| 13 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 14 |
python3 python3-pip make g++ git curl ca-certificates tar unzip bzip2 xz-utils procps net-tools iptables \
|
| 15 |
+
xvfb fluxbox novnc websockify libnss3 libatk-bridge2.0-0 libcups2 libgtk-3-0 \
|
| 16 |
+
openjdk-17-jre-headless \
|
| 17 |
&& rm -rf /var/lib/apt/lists/*
|
| 18 |
|
| 19 |
+
# 3. IDE Core: code-server (v4.114.0 Stable 2026 - With Retry)
|
| 20 |
+
RUN curl --retry 5 --retry-delay 5 -fL https://github.com/coder/code-server/releases/download/v4.114.0/code-server-4.114.0-linux-amd64.tar.gz \
|
| 21 |
| tar -C /usr/local/lib -xz \
|
| 22 |
&& ln -s /usr/local/lib/code-server-4.114.0-linux-amd64/bin/code-server /usr/local/bin/code-server
|
| 23 |
|
| 24 |
+
# 4. Determinate Systems Nix Installer (Unprivileged Resilience - Hardened)
|
| 25 |
+
RUN curl --retry 5 --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
--init none --no-confirm --no-modify-profile --extra-conf "experimental-features = nix-command flakes" \
|
| 27 |
--extra-conf "sandbox = false" \
|
| 28 |
&& chown -R node:node /nix /home/node
|
| 29 |
|
| 30 |
+
# 5. Advanced Acceleration (Cachix & Hugging Face CLI)
|
| 31 |
RUN pip3 install --no-cache-dir huggingface-hub --break-system-packages \
|
| 32 |
+
&& curl --retry 5 -fL https://cachix.org/api/v1/install | sh
|
| 33 |
|
| 34 |
+
# 6. Android SDK (Studio Preview Engine Integration - Layer Optimized)
|
| 35 |
+
# Using retry-aware downloads for platform tools
|
| 36 |
WORKDIR /app
|
| 37 |
RUN mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools && \
|
| 38 |
+
curl --retry 5 -fL https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip -o cmdline.zip && \
|
| 39 |
+
unzip -q cmdline.zip -d ${ANDROID_SDK_ROOT}/cmdline-tools && \
|
| 40 |
mv ${ANDROID_SDK_ROOT}/cmdline-tools/cmdline-tools ${ANDROID_SDK_ROOT}/cmdline-tools/latest && \
|
| 41 |
rm cmdline.zip && \
|
| 42 |
yes | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=${ANDROID_SDK_ROOT} "platform-tools" "platforms;android-33"
|
| 43 |
|
| 44 |
+
# 7. CodeVerse Application (Production Build)
|
| 45 |
WORKDIR /app
|
| 46 |
COPY package*.json ./
|
| 47 |
+
# Use npm ci for faster, deterministic production builds
|
| 48 |
+
RUN npm ci --quiet
|
| 49 |
|
| 50 |
COPY . .
|
| 51 |
|
| 52 |
+
# 8. Final Sanity Check & Build
|
| 53 |
+
# Invalidate cache only for application changes
|
| 54 |
RUN npm run build && \
|
| 55 |
mkdir -p ${WORKSPACE_ROOT} && \
|
| 56 |
chown -R node:node /app ${WORKSPACE_ROOT}
|
|
|
|
| 62 |
LABEL idx.studio.version="2026.04"
|
| 63 |
LABEL idx.optimization.cachix="true"
|
| 64 |
LABEL idx.build.optimized="true"
|
| 65 |
+
LABEL hf.dataset.status="verified"
|
| 66 |
|
| 67 |
CMD ["npm", "run", "start"]
|
lib/env-config.ts
CHANGED
|
@@ -27,12 +27,18 @@ export const ENV_CONFIG = {
|
|
| 27 |
* Validates that all critical infrastructure secrets are available.
|
| 28 |
*/
|
| 29 |
export function validateEnvironment() {
|
| 30 |
-
const missing = [];
|
| 31 |
if (!ENV_CONFIG.HF_TOKEN) missing.push('HF_TOKEN');
|
| 32 |
if (!ENV_CONFIG.HF_DATASET_ID) missing.push('HF_DATASET_ID');
|
| 33 |
if (!ENV_CONFIG.AUTH_SECRET) missing.push('AUTH_SECRET');
|
| 34 |
if (!ENV_CONFIG.DATABASE_URL) missing.push('TURSO_URL');
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
return {
|
| 37 |
valid: missing.length === 0,
|
| 38 |
missing: missing
|
|
|
|
| 27 |
* Validates that all critical infrastructure secrets are available.
|
| 28 |
*/
|
| 29 |
export function validateEnvironment() {
|
| 30 |
+
const missing: string[] = [];
|
| 31 |
if (!ENV_CONFIG.HF_TOKEN) missing.push('HF_TOKEN');
|
| 32 |
if (!ENV_CONFIG.HF_DATASET_ID) missing.push('HF_DATASET_ID');
|
| 33 |
if (!ENV_CONFIG.AUTH_SECRET) missing.push('AUTH_SECRET');
|
| 34 |
if (!ENV_CONFIG.DATABASE_URL) missing.push('TURSO_URL');
|
| 35 |
|
| 36 |
+
// Strategic Dataset Validation
|
| 37 |
+
if (ENV_CONFIG.HF_DATASET_ID && !ENV_CONFIG.HF_DATASET_ID.includes('/')) {
|
| 38 |
+
console.error("[CRITICAL] HF_DATASET_ID must be in 'username/dataset' format.");
|
| 39 |
+
return { valid: false, missing: ['HF_DATASET_ID_FORMAT_ERROR'] };
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
return {
|
| 43 |
valid: missing.length === 0,
|
| 44 |
missing: missing
|