miike-ai commited on
Commit
718fcd1
·
verified ·
1 Parent(s): f530cbe

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -21
Dockerfile CHANGED
@@ -2,55 +2,49 @@ FROM ubuntu:22.04
2
 
3
  # Set environment variables
4
  ENV DEBIAN_FRONTEND=noninteractive
5
- ENV HOME=/home/coder
6
- ENV USER=coder
7
 
8
- # Create a non-root user
9
- RUN useradd -m -d $HOME -s /bin/bash $USER && \
10
- echo "$USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
11
-
12
- # Install dependencies, code-server, and ollama
13
  RUN apt-get update && \
14
- apt-get install -y curl wget gpg apt-transport-https sudo git nodejs npm python3 python3-pip && \
15
  curl -fsSL https://code-server.dev/install.sh | sh && \
16
- curl -fsSL https://ollama.com/install.sh | sh && \
17
  apt-get clean && \
18
  rm -rf /var/lib/apt/lists/*
19
 
20
- # Switch to the non-root user
21
- USER $USER
22
- WORKDIR $HOME
23
 
24
  # Create configuration directory
25
- RUN mkdir -p $HOME/.config/code-server
26
 
27
  # Configure code-server to run on port 7860 (Hugging Face Spaces default)
28
- RUN echo "bind-addr: 0.0.0.0:7860\nauth: none\ncert: false" > $HOME/.config/code-server/config.yaml
 
 
 
29
 
30
  # Install some useful VS Code extensions
31
  RUN code-server --install-extension ms-python.python && \
32
  code-server --install-extension ritwickdey.LiveServer && \
33
  code-server --install-extension ms-toolsai.jupyter
34
 
35
- # Create a workspace directory
36
- RUN mkdir -p $HOME/workspace
37
-
38
- # Create a startup script to run both services
39
- USER root
40
  RUN echo '#!/bin/bash\n\
41
  # Start ollama in the background\n\
42
- ollama serve &\n\
43
  \n\
44
  # Give ollama a moment to start\n\
45
  sleep 2\n\
46
  \n\
47
  # Start code-server in the foreground\n\
48
- exec sudo -u $USER code-server --disable-telemetry --bind-addr 0.0.0.0:7860 /home/coder/workspace\n\
49
  ' > /start.sh && \
50
  chmod +x /start.sh
51
 
52
  # Expose ports for both services
53
  EXPOSE 7860 11434
54
 
 
 
 
55
  # Start both services
56
  CMD ["/start.sh"]
 
2
 
3
  # Set environment variables
4
  ENV DEBIAN_FRONTEND=noninteractive
 
 
5
 
6
+ # Install dependencies, code-server, and ollama without sudo in the initial list
 
 
 
 
7
  RUN apt-get update && \
8
+ apt-get install -y curl wget gpg apt-transport-https git nodejs npm python3 python3-pip && \
9
  curl -fsSL https://code-server.dev/install.sh | sh && \
 
10
  apt-get clean && \
11
  rm -rf /var/lib/apt/lists/*
12
 
13
+ # Create a directory for the workspace
14
+ RUN mkdir -p /workspace
 
15
 
16
  # Create configuration directory
17
+ RUN mkdir -p /root/.config/code-server
18
 
19
  # Configure code-server to run on port 7860 (Hugging Face Spaces default)
20
+ RUN echo "bind-addr: 0.0.0.0:7860\nauth: none\ncert: false" > /root/.config/code-server/config.yaml
21
+
22
+ # Install ollama after code-server is set up
23
+ RUN curl -fsSL https://ollama.com/install.sh | sh || true
24
 
25
  # Install some useful VS Code extensions
26
  RUN code-server --install-extension ms-python.python && \
27
  code-server --install-extension ritwickdey.LiveServer && \
28
  code-server --install-extension ms-toolsai.jupyter
29
 
30
+ # Create a startup script
 
 
 
 
31
  RUN echo '#!/bin/bash\n\
32
  # Start ollama in the background\n\
33
+ /usr/local/bin/ollama serve &\n\
34
  \n\
35
  # Give ollama a moment to start\n\
36
  sleep 2\n\
37
  \n\
38
  # Start code-server in the foreground\n\
39
+ exec code-server --disable-telemetry --bind-addr 0.0.0.0:7860 /workspace\n\
40
  ' > /start.sh && \
41
  chmod +x /start.sh
42
 
43
  # Expose ports for both services
44
  EXPOSE 7860 11434
45
 
46
+ # Set the workspace as working directory
47
+ WORKDIR /workspace
48
+
49
  # Start both services
50
  CMD ["/start.sh"]