MMAPI-2 / Dockerfile
DeFactOfficial's picture
Update Dockerfile
b419751 verified
raw
history blame
2.29 kB
# Start with Ubuntu 24.04 (Noble)
FROM ubuntu:noble
# 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://your-repo-url.git .
# 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 $HOME/code/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 -g 'daemon off;'
# 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 ["pm2", "start", "./api.js"]
# Wait for services to start
RUN sleep 5
# Display the status of the service, make sure it started
RUN pm2 list
# Tail the logs in background
#tail -f /var/log/*.log &