prasunsrivastava
commited on
Commit
·
05edc02
1
Parent(s):
3015570
Changed Dockerfile to run the uvicorn with normal user
Browse files- Dockerfile +5 -6
Dockerfile
CHANGED
|
@@ -28,7 +28,7 @@ COPY --chown=user . /app
|
|
| 28 |
# Copy the built frontend from the previous stage
|
| 29 |
COPY --from=frontend-builder --chown=user /app/frontend/build /app/static
|
| 30 |
|
| 31 |
-
# Configure nginx
|
| 32 |
COPY nginx.conf /etc/nginx/nginx.conf
|
| 33 |
RUN mkdir -p /var/log/nginx && \
|
| 34 |
chown -R user:user /var/log/nginx && \
|
|
@@ -47,18 +47,17 @@ ENV HOME=/home/user \
|
|
| 47 |
# Install the Python dependencies
|
| 48 |
RUN uv sync
|
| 49 |
|
| 50 |
-
# Switch back to root
|
| 51 |
USER root
|
| 52 |
|
| 53 |
-
# Create start script
|
| 54 |
RUN echo '#!/bin/bash\n\
|
| 55 |
nginx -g "daemon off;" &\n\
|
| 56 |
-
|
| 57 |
-
su -c "bash -c \"source /app/.venv/bin/activate && uvicorn api:app --host 0.0.0.0 --port 8000\"" user\n\
|
| 58 |
' > /app/start.sh && chmod +x /app/start.sh
|
| 59 |
|
| 60 |
# Expose the Hugging Face port
|
| 61 |
EXPOSE 7860
|
| 62 |
|
| 63 |
-
# Run
|
| 64 |
CMD ["./start.sh"]
|
|
|
|
| 28 |
# Copy the built frontend from the previous stage
|
| 29 |
COPY --from=frontend-builder --chown=user /app/frontend/build /app/static
|
| 30 |
|
| 31 |
+
# Configure nginx
|
| 32 |
COPY nginx.conf /etc/nginx/nginx.conf
|
| 33 |
RUN mkdir -p /var/log/nginx && \
|
| 34 |
chown -R user:user /var/log/nginx && \
|
|
|
|
| 47 |
# Install the Python dependencies
|
| 48 |
RUN uv sync
|
| 49 |
|
| 50 |
+
# Switch back to root for the start script
|
| 51 |
USER root
|
| 52 |
|
| 53 |
+
# Create start script
|
| 54 |
RUN echo '#!/bin/bash\n\
|
| 55 |
nginx -g "daemon off;" &\n\
|
| 56 |
+
cd /app && runuser -u user -- bash -c "source /app/.venv/bin/activate && exec uvicorn api:app --host 0.0.0.0 --port 8000"\n\
|
|
|
|
| 57 |
' > /app/start.sh && chmod +x /app/start.sh
|
| 58 |
|
| 59 |
# Expose the Hugging Face port
|
| 60 |
EXPOSE 7860
|
| 61 |
|
| 62 |
+
# Run the start script
|
| 63 |
CMD ["./start.sh"]
|