Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +34 -74
Dockerfile
CHANGED
|
@@ -1,87 +1,47 @@
|
|
| 1 |
-
#
|
| 2 |
-
FROM ghcr.io/danny-avila/librechat-dev:latest as builder
|
| 3 |
-
|
| 4 |
-
# Install build tools if needed (like pm2 globally for potential build steps)
|
| 5 |
-
USER root
|
| 6 |
-
RUN npm install -g pm2
|
| 7 |
-
# Add curl, etc. if needed for downloading things during build
|
| 8 |
-
RUN apk update && apk add --no-cache curl
|
| 9 |
-
|
| 10 |
-
# Copy necessary source code files
|
| 11 |
-
WORKDIR /app
|
| 12 |
-
# Copy package.json and lock files first for caching
|
| 13 |
-
COPY api/package.json api/package-lock.json* ./api/
|
| 14 |
-
COPY client/package.json client/package-lock.json* ./client/
|
| 15 |
-
# Copy other root files if needed for build
|
| 16 |
-
COPY librechat.yaml .
|
| 17 |
-
COPY ecosystem.config.js .
|
| 18 |
-
COPY admin-tasks.js .
|
| 19 |
-
|
| 20 |
-
# Install ALL dependencies (including dev) in API
|
| 21 |
-
WORKDIR /app/api
|
| 22 |
-
RUN npm install
|
| 23 |
-
|
| 24 |
-
# Install ALL dependencies (including dev) in Client (if needed for a build step)
|
| 25 |
-
# WORKDIR /app/client
|
| 26 |
-
# RUN npm install
|
| 27 |
-
# RUN npm run build # <-- Example if you have a client build step
|
| 28 |
-
|
| 29 |
-
# Copy the rest of the source code
|
| 30 |
-
WORKDIR /app
|
| 31 |
-
COPY ./api ./api
|
| 32 |
-
COPY ./client ./client
|
| 33 |
-
# Add other COPY commands as needed
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
# --- Final Stage ---
|
| 37 |
FROM ghcr.io/danny-avila/librechat-dev:latest
|
|
|
|
| 38 |
|
| 39 |
-
|
| 40 |
-
ENV ADMIN_PORT=${ADMIN_PORT}
|
| 41 |
-
ENV NODE_ENV=production
|
| 42 |
ENV HOST=0.0.0.0
|
| 43 |
ENV PORT=3080
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
# Create directories and set permissions (keep these)
|
| 53 |
RUN mkdir -p /app/uploads/temp \
|
| 54 |
&& mkdir -p /app/client/public/images/temp \
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
# etc...
|
| 58 |
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
#
|
| 62 |
-
|
| 63 |
-
# COPY --from=builder /app/client/dist ./client/dist # Example if client has build output
|
| 64 |
-
COPY --from=builder /app/client/public ./client/public # Copy public assets
|
| 65 |
-
COPY --from=builder /app/librechat.yaml .
|
| 66 |
-
COPY --from=builder /app/ecosystem.config.js .
|
| 67 |
-
COPY --from=builder /app/admin-tasks.js .
|
| 68 |
-
# IMPORTANT: Copy ONLY production node_modules
|
| 69 |
-
COPY --from=builder /app/api/node_modules ./api/node_modules
|
| 70 |
-
# If client has separate node_modules needed at runtime:
|
| 71 |
-
# COPY --from=builder /app/client/node_modules ./client/node_modules
|
| 72 |
|
| 73 |
-
#
|
| 74 |
-
|
| 75 |
-
# RUN apk add --no-cache python3 make g++
|
| 76 |
|
| 77 |
-
#
|
| 78 |
-
|
| 79 |
-
#
|
| 80 |
|
| 81 |
-
|
|
|
|
|
|
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
|
|
|
| 85 |
|
| 86 |
-
# Command
|
| 87 |
-
CMD ["
|
|
|
|
| 1 |
+
# Pull the base image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
FROM ghcr.io/danny-avila/librechat-dev:latest
|
| 3 |
+
EXPOSE 3080
|
| 4 |
|
| 5 |
+
# Set environment variables
|
|
|
|
|
|
|
| 6 |
ENV HOST=0.0.0.0
|
| 7 |
ENV PORT=3080
|
| 8 |
+
ENV SESSION_EXPIRY=900000
|
| 9 |
+
ENV REFRESH_TOKEN_EXPIRY=604800000
|
| 10 |
+
ENV SEARCH=true
|
| 11 |
+
ENV MEILI_NO_ANALYTICS=true
|
| 12 |
+
ENV MEILI_HOST=https://wasabidrop-meilisearch.hf.space
|
| 13 |
+
ENV MEILI_HTTP_ADDR=https://wasabidrop-meilisearch.hf.space
|
| 14 |
+
|
| 15 |
+
# Create necessary directories (likely done as root by default initially)
|
|
|
|
| 16 |
RUN mkdir -p /app/uploads/temp \
|
| 17 |
&& mkdir -p /app/client/public/images/temp \
|
| 18 |
+
&& mkdir -p /app/api/logs/ \
|
| 19 |
+
&& mkdir -p /app/data
|
|
|
|
| 20 |
|
| 21 |
+
# Give write permission to the directory
|
| 22 |
+
# Note: 777 is very permissive, consider chown to the node user later if needed
|
| 23 |
+
RUN chmod -R 777 /app/uploads/temp \
|
| 24 |
+
&& chmod -R 777 /app/client/public/images \
|
| 25 |
+
&& chmod -R 777 /app/api/logs/ \
|
| 26 |
+
&& chmod -R 777 /app/data
|
| 27 |
|
| 28 |
+
# Switch to root user to install packages
|
| 29 |
+
USER root
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
# Install curl using apk
|
| 32 |
+
RUN apk update && apk add --no-cache curl
|
|
|
|
| 33 |
|
| 34 |
+
# Copy Custom Endpoints Config (as root, writing to /app)
|
| 35 |
+
RUN curl -o /app/librechat.yaml https://raw.githubusercontent.com/fuegovic/lc-config-yaml/main/librechat-rw.yaml
|
| 36 |
+
# COPY librechat.yaml /app/librechat.yaml # Uncomment this and comment out the previous line to use the local librechat.yaml
|
| 37 |
|
| 38 |
+
# Switch back to the non-root user (likely 'node' in this image)
|
| 39 |
+
# This user should own the application files and run the process
|
| 40 |
+
USER node
|
| 41 |
|
| 42 |
+
# Install dependencies (as the 'node' user)
|
| 43 |
+
# Assuming WORKDIR is already /app in the base image
|
| 44 |
+
RUN cd /app/api && npm install
|
| 45 |
|
| 46 |
+
# Command to run on container start (will run as 'node' user)
|
| 47 |
+
CMD ["npm", "run", "backend"]
|