Update Dockerfile
Browse files- Dockerfile +21 -9
Dockerfile
CHANGED
@@ -20,16 +20,28 @@ COPY . /app
|
|
20 |
# Set permissions for non-root user
|
21 |
RUN chown -R user:user /app
|
22 |
|
23 |
-
# Create startup script
|
24 |
-
RUN
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
# Switch to non-root user
|
32 |
USER user
|
33 |
|
34 |
-
#
|
35 |
-
CMD ["bash", "start.sh"]
|
|
|
20 |
# Set permissions for non-root user
|
21 |
RUN chown -R user:user /app
|
22 |
|
23 |
+
# Create startup script that logs tmate link
|
24 |
+
RUN cat << 'EOF' > /app/start.sh
|
25 |
+
#!/bin/bash
|
26 |
+
|
27 |
+
# Start tmate in the background and write output to log
|
28 |
+
tmate -F > /tmp/tmate.log 2>&1 &
|
29 |
+
|
30 |
+
# Wait for tmate to initialize
|
31 |
+
sleep 2
|
32 |
+
|
33 |
+
# Print the SSH/web link from the tmate log
|
34 |
+
grep -E "ssh|web|https" /tmp/tmate.log || tail -n 20 /tmp/tmate.log
|
35 |
+
|
36 |
+
# Start FastAPI app
|
37 |
+
exec uvicorn main:app --host 0.0.0.0 --port 7860
|
38 |
+
EOF
|
39 |
+
|
40 |
+
# Make the script executable
|
41 |
+
RUN chmod +x /app/start.sh
|
42 |
|
43 |
# Switch to non-root user
|
44 |
USER user
|
45 |
|
46 |
+
# Run the startup script
|
47 |
+
CMD ["bash", "/app/start.sh"]
|