File size: 2,185 Bytes
968cf16
 
 
c46cd17
968cf16
 
c46cd17
 
 
 
968cf16
c46cd17
968cf16
c46cd17
 
968cf16
c46cd17
 
 
968cf16
 
c46cd17
 
968cf16
 
c46cd17
968cf16
c46cd17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Use an official Python runtime as a parent image
FROM python:3.10-slim

# Set the working directory in the container
WORKDIR /app

# Create the data directory for persistent template storage
# This ensures the directory exists when the application starts.
# Permissions are usually fine by default for the user running the app.
RUN mkdir -p ./app/data

chmod -R 777 ./app/data

# Copy the requirements file into the container at /app
COPY requirements.txt .

# Install any needed packages specified in requirements.txt
# --no-cache-dir reduces image size
# Ensure Hydrogram and any other dependencies are in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code (e.g., main.py) into the container at /app
COPY . .

# Command to run the application
# This will execute your main.py script when the container launches.
CMD ["python", "main.py"]

# --- Persistence Note for Docker (and similar platforms) ---
# The `RUN mkdir -p /app/data` line creates the directory INSIDE the container image.
# If the container is stopped and removed, and a new one is started from the image,
# this directory will be "fresh" (empty, or as it was when the image was built).
#
# To make the template content in `/app/data` truly persistent across container
# restarts and deployments (so you don't lose the template), you would use a Docker Volume.
# When running the container, you would mount a volume to `/app/data`:
#
# docker run -d -v my_template_data:/app/data <your_image_name>
#
# - `my_template_data` is the name of the Docker volume on the host.
# - `:/app/data` maps this volume to the `/app/data` directory inside the container.
#
# Hugging Face Spaces often handles some level of persistence for the main app directory,
# so the `data/` subfolder might persist. However, if you need guaranteed persistence
# that survives complete rebuilds or more complex scenarios, you'd look into the specific
# persistence options offered by the platform (which might abstract Docker volumes).
# For simple cases on HF Spaces, just creating the directory and writing to it usually works
# for persistence across restarts of the same deployment.