kacapower commited on
Commit
ae62098
·
verified ·
1 Parent(s): 4bab0e0

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +9 -11
Dockerfile CHANGED
@@ -8,26 +8,24 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
  # Install OpenCode globally via NPM to bypass the bash script rate-limit error.
11
- # Since this base image is node:20, npm is already available natively.
12
  RUN npm install -g opencode-ai
13
 
14
- # Hugging Face Spaces runs containers as UID 1000.
15
- RUN useradd -m -u 1000 user
16
- ENV HOME=/home/user
17
 
18
- # Make sure the `user` account picks up /usr/local/bin
19
- # (where npm installs global packages).
20
- ENV PATH=/home/user/.local/bin:/usr/local/bin:${PATH}
21
 
22
  # Create a workspace directory the user can clone projects into and own it.
23
- RUN mkdir -p $HOME/workspace && chown -R user:user $HOME
24
- USER user
 
 
25
  WORKDIR $HOME/workspace
26
 
27
  # The port must match `app_port` in the README's YAML block.
28
  EXPOSE 4096
29
 
30
  # Start the OpenCode web server.
31
- # --hostname 0.0.0.0 => reachable by HF's reverse proxy (not just localhost)
32
- # OPENCODE_SERVER_PASSWORD env var (set as a Space secret) enables basic auth.
33
  CMD ["opencode", "serve", "--port", "4096", "--hostname", "0.0.0.0"]
 
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
  # Install OpenCode globally via NPM to bypass the bash script rate-limit error.
 
11
  RUN npm install -g opencode-ai
12
 
13
+ # The node base image ALREADY has a user with UID 1000 named "node".
14
+ # We will use this existing user for Hugging Face Spaces.
15
+ ENV HOME=/home/node
16
 
17
+ # Make sure the `node` account picks up /usr/local/bin
18
+ ENV PATH=/home/node/.local/bin:/usr/local/bin:${PATH}
 
19
 
20
  # Create a workspace directory the user can clone projects into and own it.
21
+ RUN mkdir -p $HOME/workspace && chown -R node:node $HOME
22
+
23
+ # Switch to the existing UID 1000 user
24
+ USER node
25
  WORKDIR $HOME/workspace
26
 
27
  # The port must match `app_port` in the README's YAML block.
28
  EXPOSE 4096
29
 
30
  # Start the OpenCode web server.
 
 
31
  CMD ["opencode", "serve", "--port", "4096", "--hostname", "0.0.0.0"]