# Alga PSA Development Environment - Code Server # Based on the official code-server image with Node.js LTS and development tools FROM codercom/code-server:latest # Switch to root to install packages USER root # Install prerequisites and Node.js LTS RUN apt-get update && \ apt-get install -y \ curl \ ca-certificates \ wget \ gnupg \ lsb-release \ git \ build-essential \ python3 \ python3-pip \ jq \ vim \ nano \ htop \ tree \ unzip \ sudo \ ffmpeg \ && rm -rf /var/lib/apt/lists/* # Give coder user sudo privileges for development tasks RUN echo 'coder ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers # Increase file watcher limits for development RUN echo 'fs.inotify.max_user_watches=524288' >> /etc/sysctl.conf && \ echo 'fs.inotify.max_user_instances=256' >> /etc/sysctl.conf # Add NodeSource repository and install Node.js LTS (18.x) RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ apt-get install -y nodejs && \ rm -rf /var/lib/apt/lists/* # Install global npm packages RUN npm install -g \ @anthropic-ai/claude-code \ npm-check-updates \ typescript \ ts-node \ nodemon \ prettier \ eslint \ zstd # Install mirrord for remote development RUN curl -fsSL https://raw.githubusercontent.com/metalbear-co/mirrord/main/scripts/install.sh | bash # Install kubectl RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && \ install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl && \ rm kubectl # Install helm RUN curl -fsSL https://get.helm.sh/helm-v3.12.0-linux-amd64.tar.gz | tar xz && \ mv linux-amd64/helm /usr/local/bin/ && \ rm -rf linux-amd64 # Install Docker CLI (for building images from within the environment) RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \ apt-get update && \ apt-get install -y docker-ce-cli && \ rm -rf /var/lib/apt/lists/* # Install VS Code extensions that work well in the browser environment # Use || true to continue if an extension fails to install RUN code-server --install-extension ms-vscode.vscode-typescript-next || true && \ code-server --install-extension bradlc.vscode-tailwindcss || true && \ code-server --install-extension esbenp.prettier-vscode || true && \ code-server --install-extension redhat.vscode-yaml || true && \ code-server --install-extension ms-kubernetes-tools.vscode-kubernetes-tools || true && \ code-server --install-extension dbaeumer.vscode-eslint || true # Create necessary directories RUN mkdir -p /home/coder/.config/code-server && \ mkdir -p /home/coder/.local/share/code-server/User && \ mkdir -p /home/coder/.vscode-server/extensions && \ mkdir -p /home/coder/alga-psa # Copy configuration files (will be mounted from configmap) COPY --chown=coder:coder docker/dev-env/config/settings.json /home/coder/.local/share/code-server/User/settings.json COPY --chown=coder:coder docker/dev-env/config/extensions.json /home/coder/.vscode-server/extensions.json # Copy and setup startup script COPY docker/dev-env/start-dev-env.sh /usr/local/bin/start-dev-env.sh RUN chmod +x /usr/local/bin/start-dev-env.sh # Pre-install npm dependencies to speed up environment startup # Copy package files first for better Docker layer caching COPY --chown=coder:coder package*.json /home/coder/alga-psa/ COPY --chown=coder:coder server/package*.json /home/coder/alga-psa/server/ COPY --chown=coder:coder tools/ai-automation/package*.json /home/coder/alga-psa/tools/ai-automation/ COPY --chown=coder:coder server/src/invoice-templates/assemblyscript/package*.json /home/coder/alga-psa/server/src/invoice-templates/assemblyscript/ # Ensure coder owns the entire directory structure RUN chown -R coder:coder /home/coder/alga-psa # Switch to coder user for npm installs USER coder # Set the default workspace WORKDIR /home/coder/alga-psa # Download and install VS Code CLI in the coder user's home directory RUN cd /home/coder && \ curl -Lk 'https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64' --output vscode_cli.tar.gz && \ tar -xf vscode_cli.tar.gz && \ rm vscode_cli.tar.gz && \ echo "✅ VS Code CLI installed in /home/coder/code" # Continue in the alga-psa directory WORKDIR /home/coder/alga-psa # Install dependencies during build RUN echo "📦 Pre-installing root dependencies..." && \ npm ci --prefer-offline --no-audit && \ echo "📦 Pre-installing server dependencies..." && \ cd server && npm ci --prefer-offline --no-audit && \ cd .. && \ echo "🤖 Pre-installing AI automation dependencies..." && \ cd tools/ai-automation && npm ci --prefer-offline --no-audit && \ cd ../.. && \ echo "📄 Pre-installing AssemblyScript template dependencies..." && \ cd server/src/invoice-templates/assemblyscript && npm ci --prefer-offline --no-audit && \ cd ../.. # Switch back to root for final setup USER root # Expose the code-server port EXPOSE 8080 # Use our custom startup script ENTRYPOINT ["/usr/local/bin/start-dev-env.sh"]