zyxciss commited on
Commit
2aac6fe
·
verified ·
1 Parent(s): 266c1aa

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -9
Dockerfile CHANGED
@@ -4,16 +4,18 @@ FROM ghcr.io/remsky/kokoro-fastapi-cpu:v0.2.0post3
4
  USER root
5
  RUN apt-get update && apt-get install -y socat && rm -rf /var/lib/apt/lists/*
6
 
7
- # Set the PORT environment variable.
8
- # Hugging Face Spaces will provide a $PORT value; default to 8880 if not set.
9
  ENV PORT=8880
10
 
11
- # Expose the port (the value of $PORT)
12
  EXPOSE ${PORT}
13
 
14
- # Copy in our wrapper startup script
15
- COPY start.sh /start.sh
16
- RUN chmod +x /start.sh
17
-
18
- # Override the base image’s entrypoint so only our script runs.
19
- ENTRYPOINT ["/start.sh"]
 
 
 
 
4
  USER root
5
  RUN apt-get update && apt-get install -y socat && rm -rf /var/lib/apt/lists/*
6
 
7
+ # Set the dynamic port; Spaces will set this environment variable, defaulting here to 8880
 
8
  ENV PORT=8880
9
 
10
+ # Expose the dynamic port
11
  EXPOSE ${PORT}
12
 
13
+ # Override any inherited ENTRYPOINT or CMD by using our own one-liner:
14
+ ENTRYPOINT ["/bin/sh", "-c", "\
15
+ echo 'Starting uvicorn on port 8880...'; \
16
+ uvicorn api.src.main:app --host 0.0.0.0 --port 8880 & \
17
+ pid=\$!; \
18
+ sleep 5; \
19
+ echo 'Starting socat: forwarding incoming \$PORT (${PORT}) to 8880...'; \
20
+ exec socat TCP-LISTEN:${PORT},reuseaddr,fork TCP:127.0.0.1:8880"]
21
+ CMD []