Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +51 -47
Dockerfile
CHANGED
@@ -1,48 +1,52 @@
|
|
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
|
4 |
-
|
5 |
-
# Add new user 'user' (non-root)
|
6 |
-
RUN useradd -m -u 1000 user
|
7 |
-
|
8 |
-
# Set working dir to app
|
9 |
-
ENV HOME=/home/user \
|
10 |
-
PATH=/home/user/.local/bin:$PATH
|
11 |
-
RUN mkdir $HOME/app
|
12 |
-
WORKDIR $HOME/app
|
13 |
-
|
14 |
-
# Switch to root
|
15 |
-
USER root
|
16 |
-
|
17 |
-
# Install nginx and packages.txt
|
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
|
28 |
-
RUN touch /var/run/nginx.pid
|
29 |
-
RUN chown -R user:user /var/cache/nginx \
|
30 |
-
/var/log/nginx \
|
31 |
-
/var/lib/nginx \
|
32 |
-
/var/run/nginx.pid
|
33 |
-
|
34 |
-
# Switch to 'user' (non-root)
|
35 |
-
USER user
|
36 |
-
|
37 |
-
# Install requirements.txt
|
38 |
-
COPY --chown=user requirements.txt requirements.txt
|
39 |
-
RUN
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
48 |
CMD ["bash", "run.sh"]
|
|
|
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)
|
6 |
+
RUN useradd -m -u 1000 user
|
7 |
+
|
8 |
+
# Set working dir to app
|
9 |
+
ENV HOME=/home/user \
|
10 |
+
PATH=/home/user/.local/bin:$PATH
|
11 |
+
RUN mkdir $HOME/app
|
12 |
+
WORKDIR $HOME/app
|
13 |
+
|
14 |
+
# Switch to root
|
15 |
+
USER root
|
16 |
+
|
17 |
+
# Install nginx and packages.txt
|
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
|
28 |
+
RUN touch /var/run/nginx.pid
|
29 |
+
RUN chown -R user:user /var/cache/nginx \
|
30 |
+
/var/log/nginx \
|
31 |
+
/var/lib/nginx \
|
32 |
+
/var/run/nginx.pid
|
33 |
+
|
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 |
+
|
48 |
+
# Copy app
|
49 |
+
COPY --chown=user . .
|
50 |
+
|
51 |
+
# Run
|
52 |
CMD ["bash", "run.sh"]
|