File size: 2,065 Bytes
714ef40
3a838fc
7e1eded
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cbf3323
7e1eded
 
 
 
 
 
 
 
 
ad673a7
35e4ca1
ad673a7
32e83ad
 
 
 
ad673a7
7e1eded
 
 
 
ad673a7
7e1eded
 
 
ad673a7
7c31872
7e1eded
41ed08f
fc70af0
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
66
67
68
69
70
FROM python:3.10

# Install dependencies and Node.js
RUN apt-get update && apt-get install -y \
    curl \
    git \
    ssh \
    && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
    && apt-get install -y nodejs \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Configure SSH to recognize the host
RUN mkdir -p /root/.ssh && ssh-keyscan hf.co >> /root/.ssh/known_hosts

# Use the secret SSH key
RUN --mount=type=secret,id=SSH_PRIVATE_KEY,mode=0444,required=true \
    echo "$(cat /run/secrets/SSH_PRIVATE_KEY)" > /root/.ssh/id_ed25519 && \
    chmod 600 /root/.ssh/id_ed25519

# Install Node.js dependencies
COPY package.json /app/package.json
RUN npm install

# Copy Tailwind configuration and static files
COPY tailwind.config.js /app/tailwind.config.js
COPY templates /app/templates
COPY static /app/static

# Run the Tailwind CSS build script
RUN npm run publish

# Git configuration
RUN git config --global user.name "nexus3rd"
RUN git config --global user.email "problemsolved1990@proton.me"

# Clone the repository and conditionally commit and push changes
RUN git clone git@hf.co:spaces/nexus4rd/README /app/repo \
    && cp /app/templates/output.css /app/repo/templates/output.css \
    && cd /app/repo \
    && git add templates/output.css \
    && if ! git diff --cached --quiet; then \
            git commit -m "output.css" && git push -f; \
        else \
            echo "No changes to commit"; \
        fi

# Create a user for running the application
RUN useradd -m -u 1000 user

# Ensure the cookies directory exists and is writable by the user
RUN mkdir -p /app/cookies && \
    chown -R user:user /app/cookies

# Switch to the newly created user
USER user
ENV PATH="/home/user/.local/bin:$PATH"

# Copy and install Python dependencies
COPY --chown=user:user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# Copy the rest of the application code
COPY --chown=user:user . .

EXPOSE 7860

CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]