ohmyapi commited on
Commit
60ddd6c
·
1 Parent(s): cefb54b

Deploy new-api with Redis on HF Spaces

Browse files
Files changed (3) hide show
  1. Dockerfile +10 -0
  2. README.md +4 -5
  3. start.sh +23 -0
Dockerfile ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM calciumion/new-api:latest
2
+
3
+ RUN apt-get update && apt-get install -y redis-server && rm -rf /var/lib/apt/lists/*
4
+
5
+ COPY start.sh /app/start.sh
6
+ RUN chmod +x /app/start.sh
7
+
8
+ EXPOSE 3000
9
+
10
+ ENTRYPOINT ["/app/start.sh"]
README.md CHANGED
@@ -1,10 +1,9 @@
1
  ---
2
- title: Newapi
3
- emoji: 😻
4
- colorFrom: red
5
  colorTo: purple
6
  sdk: docker
 
7
  pinned: false
8
  ---
9
-
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: newapi
3
+ emoji: "\U0001F969"
4
+ colorFrom: blue
5
  colorTo: purple
6
  sdk: docker
7
+ app_port: 3000
8
  pinned: false
9
  ---
 
 
start.sh ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ # Start Redis in background
5
+ redis-server --daemonize yes \
6
+ --maxmemory 64mb \
7
+ --maxmemory-policy allkeys-lru \
8
+ --bind 127.0.0.1 \
9
+ --port 6379 \
10
+ --save "" \
11
+ --appendonly no
12
+
13
+ # Wait for Redis
14
+ for i in $(seq 1 10); do
15
+ redis-cli ping >/dev/null 2>&1 && break
16
+ sleep 0.5
17
+ done
18
+
19
+ # Set Redis connection
20
+ export REDIS_CONN_STRING="redis://127.0.0.1:6379"
21
+
22
+ # Start new-api
23
+ exec /app/new-api --log-dir /app/logs