| FROM ubuntu:22.04 | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # Update and install dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| curl \ | |
| wget \ | |
| git \ | |
| python3 \ | |
| python3-pip \ | |
| && apt-get clean | |
| # Install code-server properly | |
| RUN curl -fsSL https://code-server.dev/install.sh | sh | |
| # Work directory | |
| WORKDIR /workspace | |
| # Hugging Face will pass PASSWORD as an environment variable | |
| # In HF Space → Settings → Variables → add: | |
| # PASSWORD = yourpassword | |
| # ENV PASSWORD="" | |
| # Expose Hugging Face port | |
| EXPOSE 7860 | |
| # Start VS Code server | |
| # If PASSWORD isn't set, print error and exit (so you notice) | |
| CMD bash -c ' \ | |
| if [ -z "$PASSWORD" ]; then \ | |
| echo "ERROR: PASSWORD env variable not set in Hugging Face Space settings."; \ | |
| exit 1; \ | |
| fi; \ | |
| code-server --bind-addr 0.0.0.0:7860 --auth password /workspace \ | |
| ' | |