veltrixcode commited on
Commit
2ed8330
·
verified ·
1 Parent(s): adda875

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +31 -37
Dockerfile CHANGED
@@ -1,52 +1,46 @@
 
1
  FROM ubuntu:22.04
2
 
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
 
5
- # Use bash for subsequent RUN commands
6
- SHELL ["/bin/bash", "-c"]
7
-
8
- # Install desktop + tools
9
  RUN apt-get update && apt-get install -y \
10
- xfce4 xfce4-goodies \
11
- tigervnc-standalone-server \
12
- dbus-x11 x11-xserver-utils \
13
- novnc websockify curl wget git sudo nano && \
14
- apt-get clean
15
 
16
- # Install VS Code Server
17
  RUN curl -fsSL https://code-server.dev/install.sh | sh
18
 
19
- # Create a non-root user
20
- RUN useradd -m -s /bin/bash user && \
21
- echo "user:user" | chpasswd && \
22
- adduser user sudo
23
-
24
- USER user
25
- WORKDIR /home/user
26
-
27
- # Make a startup script that runs everything
28
- RUN cat << 'EOF' > start.sh
29
- #!/bin/bash
30
- export DISPLAY=:1
31
 
32
- # Start VNC server (TigerVNC)
33
- vncserver :1 -geometry 1280x720 -depth 24
34
 
35
- # Start noVNC on port 7860
36
- websockify --web=/usr/share/novnc 0.0.0.0:7860 localhost:5901 &
 
37
 
38
- # Start VS Code Server on port 9000
39
- code-server --bind-addr 0.0.0.0:9000 --auth none &
 
 
 
40
 
41
- # Prevent container from exiting
42
- while true; do sleep 1000; done
43
- EOF
44
 
45
- RUN chmod +x start.sh
46
-
47
- # Expose ports
48
  EXPOSE 7860
49
- EXPOSE 9000
50
 
51
- # Run the startup script when container starts
52
- CMD ["./start.sh"]
 
 
 
 
 
 
 
1
+ # Use a small base image with Node + common tools
2
  FROM ubuntu:22.04
3
 
4
+ # Avoid interactive prompts
5
  ENV DEBIAN_FRONTEND=noninteractive
6
 
7
+ # Install dependencies
 
 
 
8
  RUN apt-get update && apt-get install -y \
9
+ curl ca-certificates git python3 python3-pip \
10
+ build-essential wget sudo \
11
+ && rm -rf /var/lib/apt/lists/*
 
 
12
 
13
+ # Install code-server (official script)
14
  RUN curl -fsSL https://code-server.dev/install.sh | sh
15
 
16
+ # Create a non-root user (optional but recommended)
17
+ RUN useradd -m -s /bin/bash coder && \
18
+ echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
 
 
 
 
 
 
 
 
 
19
 
20
+ USER coder
21
+ WORKDIR /home/coder
22
 
23
+ # Directory where your projects will live
24
+ # This will be symlinked to /data to get persistence
25
+ RUN mkdir -p /home/coder/projects
26
 
27
+ # Hugging Face Spaces mount /data when you enable persistent storage
28
+ # Use /data as your persistent directory
29
+ USER root
30
+ RUN mkdir -p /data && chown -R coder:coder /data
31
+ USER coder
32
 
33
+ # Optional: symlink a folder into /data so your work persists
34
+ RUN ln -s /data /home/coder/persist
 
35
 
36
+ # Expose the port code-server will listen on
 
 
37
  EXPOSE 7860
 
38
 
39
+ # Environment variables
40
+ # PASSWORD: set some password so you can log in from your PC
41
+ # BIND-ADDR: bind to all interfaces at port 7860
42
+ ENV PASSWORD="changeme"
43
+ ENV PORT=7860
44
+
45
+ # Start code-server with the project root pointing to /data
46
+ CMD ["code-server", "--bind-addr", "0.0.0.0:7860", "/data"]