Update Dockerfile
Browse files- 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
|
| 11 |
-
#
|
| 12 |
-
|
| 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 |
-
|
| 21 |
-
#
|
|
|
|
| 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", "
|
|
|
|
| 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"]
|