gagannarula commited on
Commit
2c83848
·
1 Parent(s): 054e6df

Build HF app as UID 1000 so runtime user owns .venv

Browse files
Files changed (1) hide show
  1. Dockerfile +8 -0
Dockerfile CHANGED
@@ -16,6 +16,14 @@ RUN apt-get update && apt-get install -y \
16
  && rm -rf /var/lib/apt/lists/* \
17
  && git lfs install
18
 
 
 
 
 
 
 
 
 
19
  RUN --mount=type=secret,id=GH_TOKEN,mode=0444,required=true \
20
  git -c "http.https://github.com/.extraheader=Authorization: Basic $(printf 'x-access-token:%s' "$(cat /run/secrets/GH_TOKEN)" | base64 | tr -d '\n')" \
21
  clone --single-branch --depth 1 https://github.com/earthspecies/esp-research.git /app/esp-research
 
16
  && rm -rf /var/lib/apt/lists/* \
17
  && git lfs install
18
 
19
+ # HF Spaces runs the container as a non-root user (UID 1000) at runtime. Create
20
+ # that user and build everything under it so it owns the .venv and can execute
21
+ # /app/esp-research/.venv/bin/python3.
22
+ RUN useradd -m -u 1000 user
23
+ RUN mkdir -p /app && chown -R user:user /app
24
+ USER user
25
+ ENV HOME=/home/user
26
+
27
  RUN --mount=type=secret,id=GH_TOKEN,mode=0444,required=true \
28
  git -c "http.https://github.com/.extraheader=Authorization: Basic $(printf 'x-access-token:%s' "$(cat /run/secrets/GH_TOKEN)" | base64 | tr -d '\n')" \
29
  clone --single-branch --depth 1 https://github.com/earthspecies/esp-research.git /app/esp-research