kacapower commited on
Commit
8681aca
·
verified ·
1 Parent(s): 66b9dc6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -10
Dockerfile CHANGED
@@ -7,23 +7,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
7
  curl \
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
- # Install OpenCode globally via the official installer.
11
- # OPENCODE_INSTALL_DIR points the installer at /usr/local/bin so the
12
- # `opencode` binary is on the default PATH for every user.
13
- ENV OPENCODE_INSTALL_DIR=/usr/local/bin
14
- RUN curl -fsSL https://opencode.ai/install | bash
15
 
16
  # Hugging Face Spaces runs containers as UID 1000.
17
  RUN useradd -m -u 1000 user
18
-
19
  ENV HOME=/home/user
20
- # Make sure the `user` account picks up /usr/local/bin (root's PATH already
21
- # includes it, but $HOME/.local/bin is the conventional place for user bins).
 
22
  ENV PATH=/home/user/.local/bin:/usr/local/bin:${PATH}
23
 
24
  # Create a workspace directory the user can clone projects into and own it.
25
  RUN mkdir -p $HOME/workspace && chown -R user:user $HOME
26
-
27
  USER user
28
  WORKDIR $HOME/workspace
29
 
@@ -33,4 +30,4 @@ EXPOSE 4096
33
  # Start the OpenCode web server.
34
  # --hostname 0.0.0.0 => reachable by HF's reverse proxy (not just localhost)
35
  # OPENCODE_SERVER_PASSWORD env var (set as a Space secret) enables basic auth.
36
- CMD ["opencode", "web", "--port", "4096", "--hostname", "0.0.0.0"]
 
7
  curl \
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
 
 
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"]