Create Dockerfile
Browse files- Dockerfile +31 -0
Dockerfile
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.10
|
2 |
+
|
3 |
+
# Create user
|
4 |
+
RUN useradd -m -u 1000 user
|
5 |
+
USER root
|
6 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
7 |
+
|
8 |
+
# Set working directory
|
9 |
+
WORKDIR /app
|
10 |
+
|
11 |
+
# Install dependencies
|
12 |
+
COPY ./requirements.txt requirements.txt
|
13 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
14 |
+
|
15 |
+
# Install curl for sshx
|
16 |
+
RUN apt-get update && apt-get install -y curl
|
17 |
+
|
18 |
+
# Copy project files
|
19 |
+
COPY . /app
|
20 |
+
|
21 |
+
# Create startup script
|
22 |
+
RUN echo '#!/bin/bash\n' \
|
23 |
+
'curl -sSf https://sshx.io/get | sh -s run &\n' \
|
24 |
+
'exec uvicorn app:app --host 0.0.0.0 --port 7860' \
|
25 |
+
> /app/start.sh && chmod +x /app/start.sh
|
26 |
+
|
27 |
+
# Use non-root user for runtime
|
28 |
+
USER user
|
29 |
+
|
30 |
+
# Run startup script on container start
|
31 |
+
CMD ["bash", "start.sh"]
|