File size: 1,935 Bytes
9b205e1
 
 
353eeb1
9b205e1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5b0a02b
519d346
9b205e1
 
519d346
429d345
9b205e1
 
519d346
9b205e1
a9b851c
 
28c8900
9b205e1
 
 
 
 
 
 
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
FROM debian:stable-slim

# Container metadata
LABEL maintainer="Synapse"
LABEL description="Universal HF Docker Template"

# Copy installation scripts
COPY scripts/install/ /tmp/install/

# Install all services by processing all .sh files in install directory
RUN chmod +x /tmp/install/*.sh
# Install base dependencies first
RUN /tmp/install/base-install.sh
# Install all other services automatically
RUN for script in /tmp/install/*.sh; do \
        if [ "$(basename "$script")" != "base-install.sh" ]; then \
            echo "Running installation script: $(basename "$script")"; \
            "$script"; \
        fi; \
    done

# Clean up installation scripts
RUN rm -rf /tmp/install*

# Create user with UID 1000 for Hugging Face Spaces compatibility
RUN if id -u 1000 >/dev/null 2>&1; then \
      usermod -l user $(id -un 1000) && \
      usermod -d /home/user -m user; \
    else \
      useradd -m -u 1000 user; \
    fi && \
    mkdir -p /home/user/config /home/user/data && \
    chown -R 1000:1000 /home/user

# Switch to the "user" user
USER user

# Set home to the user's home directory
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Set the working directory to the user's home directory
WORKDIR $HOME

# Create required directories
RUN mkdir -p /home/user/config /home/user/data /home/user/log \
    /home/user/.cache/huggingface /home/user/download /home/user/temp

# Copy project structure
COPY --chown=user:user scripts/ /home/user/script/
COPY --chown=user:user configs/ /home/user/config/

# Make scripts executable
RUN find /home/user/script -name "*.sh" -exec chmod +x {} \;

# Default ports:
# 7860 - Legacy HuggingFace Spaces default (kept for compatibility)
EXPOSE 8008

# Copy main entrypoint script
COPY --chown=user:user docker-entrypoint.sh /home/user/docker-entrypoint.sh
RUN chmod +x /home/user/docker-entrypoint.sh

# Start the universal template
CMD ["/home/user/docker-entrypoint.sh"]