File size: 1,588 Bytes
deec87c
233d9ad
 
deec87c
233d9ad
 
 
f4546db
ac89c2f
 
a656753
 
 
 
 
 
 
 
233d9ad
 
 
 
 
f4546db
ac89c2f
 
 
233d9ad
f4546db
 
233d9ad
f4546db
 
ac89c2f
 
f4546db
 
ac89c2f
 
 
 
 
233d9ad
 
ac89c2f
deec87c
f4546db
 
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
FROM node:lts-bookworm-slim

USER root

# Create app directory and set permissions
RUN mkdir -p /app && chown -R node:node /app

# Install system dependencies cleanly
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        ffmpeg \
        imagemagick \
        build-essential \
        git \
        libtool \
        automake \
        autoconf \
        ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /app

# 1. Clone the private GitHub repository using Docker BuildKit secrets
RUN --mount=type=secret,id=GITHUB_REPO,required=true \
    --mount=type=secret,id=GITHUB_TOKEN,required=true \
    git clone https://$(cat /run/secrets/GITHUB_TOKEN)@github.com/$(cat /run/secrets/GITHUB_REPO).git .

# 2. Copy Hugging Face Space files (start.sh හෝ වෙනත් files ඇත්නම් copy වේ)
COPY --chown=node:node . .

# 3. Create database directory & set permissions
RUN mkdir -p /app/lib/database && chown -R node:node /app/lib
RUN chmod -R 777 /app

# 4. start.sh ඇත්නම් පමණක් execute permission දීම (නැතිනම් error නොදී skip වේ)
RUN if [ -f "./start.sh" ]; then chmod +x ./start.sh; fi

# Update npm and install dependencies
RUN npm install -g npm@latest
RUN npm install node-cache
RUN npm install || yarn install

EXPOSE 7860
ENV NODE_ENV=production

# start.sh ඇත්නම් එයින්ද, නැත්නම් npm start මඟින්ද run කිරීම
CMD ["sh", "-c", "if [ -f ./start.sh ]; then ./start.sh; else npm start; fi"]