File size: 2,144 Bytes
125f18f
c27fe7f
a830538
125f18f
 
 
 
fd0ee34
 
 
 
 
 
 
 
 
 
125f18f
a830538
db88c10
 
 
a830538
db88c10
 
 
 
 
a830538
8efa104
e3156f8
8efa104
db88c10
e9bbf23
a830538
db88c10
ffae513
8f01dac
ffae513
8f01dac
a830538
e9bbf23
 
a830538
db88c10
 
 
a830538
 
7a57bb1
a830538
 
 
db88c10
 
c27fe7f
db88c10
 
b419751
7a57bb1
8efa104
b419751
43dee0d
db88c10
 
 
 
 
 
b419751
e3156f8
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
71
# Start with Ubuntu 24.04 (Noble)
FROM ubuntu:oracular

# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive

# Install essential packages and tools
RUN apt-get update && apt-get install -y curl wget git nginx

# Free advertising :)
LABEL maintainer="sam@defact.org" \
      description="Free multimodal inference api running in node via docker and HF serverless inference" \
      usage="https://huggingface.co/spaces/DeFactOfficial/MMAPI"

# Switch to root for system installations
USER root


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

# Install Node.js 20 (using n instead of nodesource for better HF compatibility)
RUN curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n \
    && bash n 20 \
    && rm n \
    && npm install -g npm@latest

# pm2 is awesome... lets you run node.js scripts as services with zero configuration
#RUN npm install pm2 -g 

# Create working directory that matches HF Spaces expectations
WORKDIR $HOME/code 

# Clone your repository (replace with your actual repo URL)
# RUN git clone https://huggingface.co/spaces/DeFactOfficial/MMAPI-2 . 

#RUN git pull 

# Copy the current directory contents into the container at $HOME/app setting the owner to the user
ADD . $HOME/code 
COPY --chown=root . $HOME/code 

# INSTALL NPM PACKAGES
# INSTALL FFMPEG TOOLING
# FIRE UP API
# Loading Dependencies
RUN npm install
#RUN $HOME/code/ffmpeg_install.sh
# Expose application's default port
EXPOSE 7860

# Configure nginx
RUN rm -f /etc/nginx/sites-enabled/default
COPY ./conf/nginx.conf /etc/nginx/sites-available/reverse-proxy.conf
RUN ln -s /etc/nginx/sites-available/reverse-proxy.conf /etc/nginx/sites-enabled/

# Stop all old instances of the api service
# RUN pm2 delete all

# Start nginx in foreground
RUN nginx

# Start all services in background with logging
#cd /code/service1 && ./run.sh > /var/log/service1.log 2>&1 &
#cd /code/service2 && ./run.sh > /var/log/service2.log 2>&1 &
#cd /code/service3 && ./run.sh > /var/log/service3.log 2>&1 &

# Start the API
ENTRYPOINT ["node", "./api.js"]