meltedchoco commited on
Commit
0bc275b
·
verified ·
1 Parent(s): 00d4e5c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +8 -7
Dockerfile CHANGED
@@ -36,19 +36,18 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
36
  HF_HOME=/data/.cache/huggingface \
37
  SEKAI_HOST=0.0.0.0 \
38
  SEKAI_PORT=7860 \
39
- PGDATA=/tmp/postgres \
40
  PGHOST=/tmp \
41
  PATH="/usr/lib/postgresql/17/bin:$PATH"
42
 
43
- # Install PostgreSQL 17 (Trixie default) and uv
44
  RUN apt-get update && apt-get install -y --no-install-recommends \
45
  ca-certificates \
46
  postgresql-17 \
47
  && rm -rf /var/lib/apt/lists/* \
48
  && pip install --no-cache-dir uv
49
 
50
- # HF Spaces requires UID 1000 for persistent storage.
51
- # Create sekai user (1000) and make postgres superuser work as UID 1000.
52
  RUN groupadd -g 1000 sekai \
53
  && useradd -m -u 1000 -g sekai sekai \
54
  && mkdir -p /data/postgres /data/.cache /var/run/postgresql \
@@ -56,13 +55,15 @@ RUN groupadd -g 1000 sekai \
56
 
57
  WORKDIR /app
58
 
59
- COPY --from=source /src/app /app
60
- RUN uv sync --frozen --no-dev
 
61
 
62
- COPY entrypoint.sh /app/entrypoint.sh
63
  RUN chmod +x /app/entrypoint.sh
64
 
 
65
  USER sekai
 
66
 
67
  EXPOSE 7860
68
 
 
36
  HF_HOME=/data/.cache/huggingface \
37
  SEKAI_HOST=0.0.0.0 \
38
  SEKAI_PORT=7860 \
39
+ PGDATA=/data/postgres \
40
  PGHOST=/tmp \
41
  PATH="/usr/lib/postgresql/17/bin:$PATH"
42
 
43
+ # Install PostgreSQL 17 and uv
44
  RUN apt-get update && apt-get install -y --no-install-recommends \
45
  ca-certificates \
46
  postgresql-17 \
47
  && rm -rf /var/lib/apt/lists/* \
48
  && pip install --no-cache-dir uv
49
 
50
+ # Create sekai user (1000) and set up directories
 
51
  RUN groupadd -g 1000 sekai \
52
  && useradd -m -u 1000 -g sekai sekai \
53
  && mkdir -p /data/postgres /data/.cache /var/run/postgresql \
 
55
 
56
  WORKDIR /app
57
 
58
+ # Copy files and immediately give ownership to the sekai user
59
+ COPY --from=source --chown=sekai:sekai /src/app /app
60
+ COPY --chown=sekai:sekai entrypoint.sh /app/entrypoint.sh
61
 
 
62
  RUN chmod +x /app/entrypoint.sh
63
 
64
+ # Switch to sekai BEFORE running uv sync so the virtual environment is owned by sekai
65
  USER sekai
66
+ RUN uv sync --frozen --no-dev
67
 
68
  EXPOSE 7860
69