File size: 1,189 Bytes
35729d9
 
1fcc069
 
35729d9
 
1fcc069
 
35729d9
1fcc069
 
35729d9
1fcc069
 
35729d9
 
1fcc069
 
 
 
 
 
 
 
 
35729d9
1fcc069
 
35729d9
 
1fcc069
 
35729d9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
FROM python:3.11-slim

# No build-essential / sqlite3: nothing here compiles C extensions (asyncpg
# ships wheels), so the packages only inflate the image and its attack surface.
WORKDIR /app

# Copy and install dependencies first so layer caching works when only code
# changes.
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip \
    && pip install --no-cache-dir -r requirements.txt

# Copy only the source. .dockerignore excludes .env, data/, .venv/, .git/ and
# the OAuth secrets, so credentials and user data cannot leak into the image.
COPY . .

# The app writes nothing to disk: all state lives in Postgres. Create a
# non-writable runtime directory only so a stray relative path cannot fail.
RUN mkdir -p /app/data \
    && chmod 755 /app/data

# Run as a non-root user.
RUN useradd --create-home --uid 10001 ginchiee \
    && chown -R ginchiee:ginchiee /app
USER ginchiee

# Hugging Face Spaces port. main.py serves a lightweight health endpoint on it.
ENV PORT=7860
EXPOSE 7860

# DATABASE_URL (plus TELEGRAM_BOT_TOKEN / GEMINI_API_KEY) must be supplied at
# runtime via Space Secrets or `docker run -e`, never baked into the image.
CMD ["python", "main.py"]