Update Dockerfile
Browse files- Dockerfile +45 -27
Dockerfile
CHANGED
@@ -1,24 +1,28 @@
|
|
1 |
-
|
|
|
2 |
|
3 |
-
#
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
11 |
|
12 |
-
#
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
16 |
|
17 |
# Create necessary directories
|
18 |
RUN mkdir -p /app/uploads/temp
|
19 |
RUN mkdir -p /app/client/public/images/temp
|
20 |
RUN mkdir -p /app/api/logs/
|
21 |
RUN mkdir -p /app/data
|
|
|
22 |
|
23 |
# Give write permission to the directory
|
24 |
RUN chmod -R 777 /app/uploads/temp
|
@@ -26,29 +30,43 @@ RUN chmod -R 777 /app/client/public/images
|
|
26 |
RUN chmod -R 777 /app/api/logs/
|
27 |
RUN chmod -R 777 /app/data
|
28 |
|
29 |
-
# Copy Custom Endpoints Config
|
30 |
RUN curl -o /app/librechat.yaml https://raw.githubusercontent.com/fuegovic/lc-config-yaml/main/librechat-rw.yaml
|
31 |
-
# COPY librechat.yaml /app/librechat.yaml # Uncomment this and comment out the previous line to use the local librechat.yaml
|
32 |
|
33 |
-
# Install
|
34 |
-
RUN
|
|
|
35 |
|
36 |
-
#
|
37 |
-
RUN
|
38 |
-
|
39 |
-
|
40 |
-
&& mv /app/librechat-rag-api-dev-main /app/rag_api
|
41 |
|
42 |
-
#
|
43 |
-
RUN
|
|
|
|
|
|
|
|
|
44 |
|
45 |
-
# Create a script to start
|
46 |
RUN echo '#!/bin/bash\n\
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
wait' > /app/start-services.sh
|
50 |
|
51 |
RUN chmod +x /app/start-services.sh
|
52 |
|
|
|
|
|
|
|
53 |
# Command to run on container start
|
54 |
CMD ["/bin/bash", "/app/start-services.sh"]
|
|
|
1 |
+
# Start with a base image that supports multiple services
|
2 |
+
FROM ubuntu:20.04
|
3 |
|
4 |
+
# Install dependencies
|
5 |
+
RUN apt-get update && apt-get install -y \
|
6 |
+
postgresql \
|
7 |
+
curl \
|
8 |
+
wget \
|
9 |
+
gnupg \
|
10 |
+
lsb-release \
|
11 |
+
software-properties-common \
|
12 |
+
&& rm -rf /var/lib/apt/lists/*
|
13 |
|
14 |
+
# Set environment variables for PostgreSQL
|
15 |
+
ENV POSTGRES_DB=mydatabase
|
16 |
+
ENV POSTGRES_USER=myuser
|
17 |
+
ENV POSTGRES_PASSWORD=mypassword
|
18 |
+
ENV PGDATA=/var/lib/postgresql/data
|
19 |
|
20 |
# Create necessary directories
|
21 |
RUN mkdir -p /app/uploads/temp
|
22 |
RUN mkdir -p /app/client/public/images/temp
|
23 |
RUN mkdir -p /app/api/logs/
|
24 |
RUN mkdir -p /app/data
|
25 |
+
RUN mkdir -p /app/rag_api
|
26 |
|
27 |
# Give write permission to the directory
|
28 |
RUN chmod -R 777 /app/uploads/temp
|
|
|
30 |
RUN chmod -R 777 /app/api/logs/
|
31 |
RUN chmod -R 777 /app/data
|
32 |
|
33 |
+
# Copy Custom Endpoints Config for LibreChat
|
34 |
RUN curl -o /app/librechat.yaml https://raw.githubusercontent.com/fuegovic/lc-config-yaml/main/librechat-rw.yaml
|
|
|
35 |
|
36 |
+
# Install Node.js and npm
|
37 |
+
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
|
38 |
+
&& apt-get install -y nodejs
|
39 |
|
40 |
+
# Clone and set up librechat
|
41 |
+
RUN git clone https://github.com/danny-avila/librechat-dev.git /app/librechat
|
42 |
+
WORKDIR /app/librechat/api
|
43 |
+
RUN npm install
|
|
|
44 |
|
45 |
+
# Clone and set up rag_api
|
46 |
+
RUN curl -Lo /app/rag_api.tar.gz https://github.com/danny-avila/librechat-rag-api-dev/archive/refs/heads/main.tar.gz \
|
47 |
+
&& tar -xzvf /app/rag_api.tar.gz -C /app/rag_api --strip-components=1 \
|
48 |
+
&& rm /app/rag_api.tar.gz
|
49 |
+
WORKDIR /app/rag_api
|
50 |
+
RUN npm install
|
51 |
|
52 |
+
# Create a script to start all services
|
53 |
RUN echo '#!/bin/bash\n\
|
54 |
+
# Start PostgreSQL service\n\
|
55 |
+
/etc/init.d/postgresql start\n\
|
56 |
+
# Configure PostgreSQL\n\
|
57 |
+
su postgres -c "psql --command \\"CREATE DATABASE $POSTGRES_DB;\\""\n\
|
58 |
+
su postgres -c "psql --command \\"CREATE USER $POSTGRES_USER WITH PASSWORD \x27$POSTGRES_PASSWORD\x27;\\""\n\
|
59 |
+
su postgres -c "psql --command \\"GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_DB TO $POSTGRES_USER;\\""\n\
|
60 |
+
# Start librechat\n\
|
61 |
+
cd /app/librechat/api && npm run backend &\n\
|
62 |
+
# Start rag_api\n\
|
63 |
+
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\
|
64 |
wait' > /app/start-services.sh
|
65 |
|
66 |
RUN chmod +x /app/start-services.sh
|
67 |
|
68 |
+
# Expose the ports for librechat and rag_api
|
69 |
+
EXPOSE 3080 3081
|
70 |
+
|
71 |
# Command to run on container start
|
72 |
CMD ["/bin/bash", "/app/start-services.sh"]
|