martynka commited on
Commit
2c0ee73
·
verified ·
1 Parent(s): f6fb9fd

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +41 -41
Dockerfile CHANGED
@@ -1,5 +1,6 @@
1
- #original repo
2
  FROM ghcr.io/danny-avila/librechat-dev:latest
 
3
  # Install dependencies
4
  USER root
5
  RUN apk update && apk add --no-cache \
@@ -7,44 +8,37 @@ RUN apk update && apk add --no-cache \
7
  python3 \
8
  py3-pip \
9
  py3-dotenv \
10
- git
11
- RUN pip install flask pymongo[srv] --break-system-packages
12
- COPY config.yaml /app/librechat.yaml
13
- #secrets
14
- RUN --mount=type=secret,id=SUDO_SECRET,required=true cat /run/secrets/SUDO_SECRET > /app/sudo.sec
15
- RUN export SUDO_SECRET=$(cat /app/sudo.sec)
16
- RUN --mount=type=secret,id=MONGO_URI,required=true cat /run/secrets/MONGO_URI > /app/mongo.sec
17
- RUN export MONGO_URI=$(cat /app/mongo.sec)
18
- RUN --mount=type=secret,id=FLASK_SECRET,required=true cat /run/secrets/FLASK_SECRET > /app/flask.sec
19
- RUN export FLASK_SECRET=$(cat /app/flask.sec)
20
 
21
- # Create admin structure
22
- RUN mkdir -p /app/sudo/{templates,static} \
23
- && chown -R 1000:1000 /app
24
- # HTML Admin Panel
25
- COPY index-temp.html /app/sudo/templates/index.html
26
- # Admin Backend
27
- COPY app-temp.py /app/sudo/app.py
28
- # Caddy Configuration
29
- RUN mkdir -p /app/caddy/
30
  COPY Caddyfile /app/caddy/Caddyfile
31
- # Startup script
32
  COPY start-temp.sh /app/start.sh
33
  RUN chmod +x /app/start.sh
34
- #####################################################
35
- # Create necessary directories
36
- RUN mkdir -p /app/uploads/temp
37
- RUN mkdir -p /app/client/public/images/temp
38
- RUN mkdir -p /app/api/logs/
39
- RUN mkdir -p /app/data
40
- # Give write permission to the directory
41
- RUN chmod -R 777 /app/uploads/temp
42
- RUN chmod -R 777 /app/client/public/images
43
- RUN chmod -R 777 /app/api/logs/
44
- RUN chmod -R 777 /app/data
45
- # Environment variables
 
 
 
 
 
 
 
 
 
46
  ENV HOST=0.0.0.0 \
47
- PORT=3080 \
48
  SESSION_EXPIRY=900000 \
49
  REFRESH_TOKEN_EXPIRY=604800000 \
50
  SEARCH=true \
@@ -52,14 +46,20 @@ ENV HOST=0.0.0.0 \
52
  MEILI_HOST=https://martynka-meilisearch.hf.space \
53
  CONFIG_PATH=/app/librechat.yaml \
54
  CUSTOM_FOOTER=EasierIT \
55
- MONGO_URI="$MONGO_URI" \
56
- SUDO_SECRET="$SUDO_SECRET" \
57
- ADMIN_SECRET="$SUDO_SECRET" \
58
- FLASK_SECRET="$FLASK_SECRET" \
59
  NODE_ENV=production
60
- # npm Install aditional dependencies
 
61
  RUN cd /app/api && npm install
62
- # port
 
 
 
 
63
  EXPOSE 7860
64
- #endpoint
 
 
 
 
 
65
  CMD ["/app/start.sh"]
 
1
+ # Start from the original repo
2
  FROM ghcr.io/danny-avila/librechat-dev:latest
3
+
4
  # Install dependencies
5
  USER root
6
  RUN apk update && apk add --no-cache \
 
8
  python3 \
9
  py3-pip \
10
  py3-dotenv \
11
+ git && \
12
+ pip install flask pymongo[srv] --break-system-packages
 
 
 
 
 
 
 
 
13
 
14
+ # Copy configuration files
15
+ COPY config.yaml /app/librechat.yaml
 
 
 
 
 
 
 
16
  COPY Caddyfile /app/caddy/Caddyfile
 
17
  COPY start-temp.sh /app/start.sh
18
  RUN chmod +x /app/start.sh
19
+
20
+ # Create directory structure
21
+ RUN mkdir -p \
22
+ /app/sudo/{templates,static} \
23
+ /app/uploads/temp \
24
+ /app/client/public/images/temp \
25
+ /app/api/logs \
26
+ /app/data \
27
+ /app/caddy && \
28
+ chown -R 1000:1000 /app && \
29
+ chmod -R 777 \
30
+ /app/uploads/temp \
31
+ /app/client/public/images \
32
+ /app/api/logs \
33
+ /app/data
34
+
35
+ # Copy application files
36
+ COPY index-temp.html /app/sudo/templates/index.html
37
+ COPY app-temp.py /app/sudo/app.py
38
+
39
+ # Set environment variables (use HF-specific vars where possible)
40
  ENV HOST=0.0.0.0 \
41
+ PORT=7860 \
42
  SESSION_EXPIRY=900000 \
43
  REFRESH_TOKEN_EXPIRY=604800000 \
44
  SEARCH=true \
 
46
  MEILI_HOST=https://martynka-meilisearch.hf.space \
47
  CONFIG_PATH=/app/librechat.yaml \
48
  CUSTOM_FOOTER=EasierIT \
 
 
 
 
49
  NODE_ENV=production
50
+
51
+ # Install additional dependencies
52
  RUN cd /app/api && npm install
53
+
54
+ # Switch to non-root user
55
+ USER 1000
56
+
57
+ # Expose the correct port for HF Spaces
58
  EXPOSE 7860
59
+
60
+ # Health check (recommended for HF Spaces)
61
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
62
+ CMD curl -f http://localhost:7860 || exit 1
63
+
64
+ # Start command
65
  CMD ["/app/start.sh"]