File size: 1,897 Bytes
125f18f
c27fe7f
a830538
125f18f
 
 
 
fd0ee34
 
 
 
 
 
 
a878e43
1ea6780
a878e43
 
1ea6780
a878e43
125f18f
a830538
1ea6780
 
 
a830538
db88c10
e68b460
 
 
 
a830538
8efa104
e3156f8
8efa104
db88c10
e9bbf23
a830538
db88c10
ffae513
8f01dac
ffae513
8f01dac
a830538
e9bbf23
1ea6780
a830538
db88c10
 
 
a830538
 
7a57bb1
a830538
 
 
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
# 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"

# Set up a new user named "user" with user ID 1000
RUN useradd -o -u 1000 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  \
      STATIC_SITE_user=$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=user . $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


# 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"]