template / Dockerfile
eggacheb's picture
Update Dockerfile
df1a817 verified
raw
history blame
2.43 kB
# Start with a base image that supports multiple services
FROM ubuntu:20.04
# Install dependencies
RUN apt-get update && apt-get install -y \
postgresql \
curl \
wget \
gnupg \
lsb-release \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*
# Set environment variables for PostgreSQL
ENV POSTGRES_DB=mydatabase
ENV POSTGRES_USER=myuser
ENV POSTGRES_PASSWORD=mypassword
ENV PGDATA=/var/lib/postgresql/data
# Create necessary directories
RUN mkdir -p /app/uploads/temp
RUN mkdir -p /app/client/public/images/temp
RUN mkdir -p /app/api/logs/
RUN mkdir -p /app/data
RUN mkdir -p /app/rag_api
# Give write permission to the directory
RUN chmod -R 777 /app/uploads/temp
RUN chmod -R 777 /app/client/public/images
RUN chmod -R 777 /app/api/logs/
RUN chmod -R 777 /app/data
# Copy Custom Endpoints Config for LibreChat
RUN curl -o /app/librechat.yaml https://raw.githubusercontent.com/fuegovic/lc-config-yaml/main/librechat-rw.yaml
# Install Node.js and npm
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y nodejs
# Clone and set up librechat
RUN git clone https://github.com/danny-avila/librechat-dev.git /app/librechat
WORKDIR /app/librechat/api
RUN npm install
# Clone and set up rag_api
RUN curl -Lo /app/rag_api.tar.gz https://github.com/danny-avila/librechat-rag-api-dev/archive/refs/heads/main.tar.gz \
&& tar -xzvf /app/rag_api.tar.gz -C /app/rag_api --strip-components=1 \
&& rm /app/rag_api.tar.gz
WORKDIR /app/rag_api
RUN npm install
# Create a script to start all services
RUN echo '#!/bin/bash\n\
# Start PostgreSQL service\n\
/etc/init.d/postgresql start\n\
# Configure PostgreSQL\n\
su postgres -c "psql --command \\"CREATE DATABASE $POSTGRES_DB;\\""\n\
su postgres -c "psql --command \\"CREATE USER $POSTGRES_USER WITH PASSWORD \x27$POSTGRES_PASSWORD\x27;\\""\n\
su postgres -c "psql --command \\"GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_DB TO $POSTGRES_USER;\\""\n\
# Start librechat\n\
cd /app/librechat/api && npm run backend &\n\
# Start rag_api\n\
cd /app/rag_api && DB_HOST=localhost DB_PORT=5432 POSTGRES_DB=$POSTGRES_DB POSTGRES_USER=$POSTGRES_USER POSTGRES_PASSWORD=$POSTGRES_PASSWORD npm start &\n\
wait' > /app/start-services.sh
RUN chmod +x /app/start-services.sh
# Expose the ports for librechat and rag_api
EXPOSE 3080 3081
# Command to run on container start
CMD ["/bin/bash", "/app/start-services.sh"]