Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +8 -9
Dockerfile
CHANGED
|
@@ -1,5 +1,3 @@
|
|
| 1 |
-
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
| 2 |
-
# you will also find guides on how best to write your Dockerfile
|
| 3 |
FROM python:3.13-slim
|
| 4 |
|
| 5 |
# Add new user 'user' (non-root)
|
|
@@ -18,10 +16,9 @@ USER root
|
|
| 18 |
RUN apt-get -y update && apt-get -y install nginx
|
| 19 |
|
| 20 |
# Give app permissions to 'user' (non-root)
|
| 21 |
-
RUN chown user:user .
|
| 22 |
|
| 23 |
# Give nginx permissions to 'user' (non-root)
|
| 24 |
-
# See https://www.rockyourcode.com/run-docker-nginx-as-non-root-user/
|
| 25 |
RUN mkdir -p /var/cache/nginx \
|
| 26 |
/var/log/nginx \
|
| 27 |
/var/lib/nginx
|
|
@@ -34,14 +31,16 @@ RUN chown -R user:user /var/cache/nginx \
|
|
| 34 |
# Switch to 'user' (non-root)
|
| 35 |
USER user
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
# Install requirements.txt
|
| 38 |
COPY --chown=user requirements.txt requirements.txt
|
| 39 |
-
RUN python3 -m venv /app/venv
|
| 40 |
-
ENV PATH="/app/venv/bin:$PATH"
|
| 41 |
-
|
| 42 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 43 |
|
| 44 |
-
|
| 45 |
# Copy nginx configuration
|
| 46 |
COPY --chown=user nginx.conf /etc/nginx/sites-available/default
|
| 47 |
|
|
@@ -49,4 +48,4 @@ COPY --chown=user nginx.conf /etc/nginx/sites-available/default
|
|
| 49 |
COPY --chown=user . .
|
| 50 |
|
| 51 |
# Run
|
| 52 |
-
CMD ["bash", "run.sh"]
|
|
|
|
|
|
|
|
|
|
| 1 |
FROM python:3.13-slim
|
| 2 |
|
| 3 |
# Add new user 'user' (non-root)
|
|
|
|
| 16 |
RUN apt-get -y update && apt-get -y install nginx
|
| 17 |
|
| 18 |
# Give app permissions to 'user' (non-root)
|
| 19 |
+
RUN chown user:user .
|
| 20 |
|
| 21 |
# Give nginx permissions to 'user' (non-root)
|
|
|
|
| 22 |
RUN mkdir -p /var/cache/nginx \
|
| 23 |
/var/log/nginx \
|
| 24 |
/var/lib/nginx
|
|
|
|
| 31 |
# Switch to 'user' (non-root)
|
| 32 |
USER user
|
| 33 |
|
| 34 |
+
# Create the virtual environment as 'user' should have permission on $HOME/app
|
| 35 |
+
RUN python3 -m venv /home/user/app/venv
|
| 36 |
+
|
| 37 |
+
# Ensure the virtual environment is on the path
|
| 38 |
+
ENV PATH="/home/user/app/venv/bin:$PATH"
|
| 39 |
+
|
| 40 |
# Install requirements.txt
|
| 41 |
COPY --chown=user requirements.txt requirements.txt
|
|
|
|
|
|
|
|
|
|
| 42 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 43 |
|
|
|
|
| 44 |
# Copy nginx configuration
|
| 45 |
COPY --chown=user nginx.conf /etc/nginx/sites-available/default
|
| 46 |
|
|
|
|
| 48 |
COPY --chown=user . .
|
| 49 |
|
| 50 |
# Run
|
| 51 |
+
CMD ["bash", "run.sh"]
|