NitinBot002 commited on
Commit
6e984b7
·
verified ·
1 Parent(s): c5092b6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -24
Dockerfile CHANGED
@@ -1,10 +1,8 @@
1
- # Use official code-server base image
2
  FROM codercom/code-server:latest
3
 
4
- # Switch to root user for installing system packages
5
  USER root
6
 
7
- # Update apt and install all required dependencies
8
  RUN apt-get update && \
9
  apt-get install -y \
10
  python3-pip \
@@ -28,35 +26,25 @@ RUN apt-get update && \
28
  npm install -g npm yarn && \
29
  apt-get clean && rm -rf /var/lib/apt/lists/*
30
 
31
- # Install Python packages with pip (bypassing PEP 668 restrictions)
32
  RUN pip3 install --break-system-packages --no-cache-dir --upgrade pip setuptools wheel && \
33
  pip3 install --break-system-packages ipython virtualenv jupyter
34
 
35
- # Create a project directory and assign ownership to coder user
36
  RUN mkdir -p /home/coder/project && chown -R coder:coder /home/coder/project
37
 
38
- # Switch back to coder user
39
  USER coder
40
 
41
- # Set environment variables
42
- ENV PASSWORD=hfspacespassword \
43
- PORT=7860 \
44
- HOME=/home/coder
45
-
46
- # Create code-server config directory and file
47
- RUN mkdir -p ~/.config/code-server && \
48
- echo '{ \
49
- "bind-addr": "0.0.0.0:7860", \
50
- "auth": "password", \
51
- "password": "'"${PASSWORD}"'", \
52
- "cert": false \
53
- }' > ~/.config/code-server/config.json
54
-
55
- # Set the working directory
56
  WORKDIR /home/coder/project
57
 
58
- # Expose the port for Hugging Face Space
59
  EXPOSE 7860
60
 
61
- # Start code-server
62
- CMD ["code-server", "--port", "7860", "/home/coder/project"]
 
 
1
  FROM codercom/code-server:latest
2
 
 
3
  USER root
4
 
5
+ # Install system tools and dev environment
6
  RUN apt-get update && \
7
  apt-get install -y \
8
  python3-pip \
 
26
  npm install -g npm yarn && \
27
  apt-get clean && rm -rf /var/lib/apt/lists/*
28
 
29
+ # Install Python libraries
30
  RUN pip3 install --break-system-packages --no-cache-dir --upgrade pip setuptools wheel && \
31
  pip3 install --break-system-packages ipython virtualenv jupyter
32
 
33
+ # Setup workspace
34
  RUN mkdir -p /home/coder/project && chown -R coder:coder /home/coder/project
35
 
36
+ # Switch back to non-root user
37
  USER coder
38
 
39
+ ENV PORT=7860
40
+ ENV HOME=/home/coder
41
+
42
+ # Delay config writing until container run using entrypoint script
43
+ COPY --chown=coder:coder entrypoint.sh /home/coder/entrypoint.sh
44
+ RUN chmod +x /home/coder/entrypoint.sh
45
+
 
 
 
 
 
 
 
 
46
  WORKDIR /home/coder/project
47
 
 
48
  EXPOSE 7860
49
 
50
+ CMD ["/home/coder/entrypoint.sh"]