Spaces:
Sleeping
Sleeping
Deploy fix
Browse files- Dockerfile +24 -9
Dockerfile
CHANGED
@@ -1,22 +1,37 @@
|
|
1 |
# Use an official Python runtime as a parent image
|
2 |
-
FROM python:3.10
|
|
|
3 |
# Set Python to use unbuffered mode
|
4 |
-
ENV PYTHONUNBUFFERED
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
# Set the working directory in the container
|
6 |
RUN mkdir /var/www
|
7 |
-
ENV HOME
|
8 |
WORKDIR /var/www
|
9 |
|
10 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
COPY . /var/www
|
12 |
|
13 |
-
RUN pip install -r requirements
|
14 |
|
15 |
-
#
|
16 |
EXPOSE 7860
|
17 |
|
18 |
-
# Define environment variable
|
19 |
-
ENV FLASK_APP app.py
|
20 |
-
|
21 |
# Run app.py when the container launches
|
22 |
CMD flask run --host=0.0.0.0 --port=7860
|
|
|
1 |
# Use an official Python runtime as a parent image
|
2 |
+
FROM python:3.10-slim-bullseye
|
3 |
+
|
4 |
# Set Python to use unbuffered mode
|
5 |
+
ENV PYTHONUNBUFFERED=1
|
6 |
+
|
7 |
+
ENV PATH="/var/www/.local/bin:${PATH}"
|
8 |
+
|
9 |
+
# Create a non-root user
|
10 |
+
RUN useradd -m -u 1000 -U -s /bin/bash myuser
|
11 |
+
|
12 |
+
# Install dependencies
|
13 |
+
RUN apt-get update && \
|
14 |
+
apt-get install -y --no-install-recommends python3-pip python3-dev && \
|
15 |
+
rm -rf /var/lib/apt/lists/*
|
16 |
+
|
17 |
# Set the working directory in the container
|
18 |
RUN mkdir /var/www
|
19 |
+
ENV HOME=/var/www
|
20 |
WORKDIR /var/www
|
21 |
|
22 |
+
# Change ownership of /var/www to the non-root user
|
23 |
+
RUN chown -R myuser:myuser /var/www
|
24 |
+
|
25 |
+
# Switch to the non-root user
|
26 |
+
USER myuser
|
27 |
+
|
28 |
+
# Copy the current directory contents into the container at /var/www
|
29 |
COPY . /var/www
|
30 |
|
31 |
+
RUN pip install --user -r requirements.txt
|
32 |
|
33 |
+
# Expose the port
|
34 |
EXPOSE 7860
|
35 |
|
|
|
|
|
|
|
36 |
# Run app.py when the container launches
|
37 |
CMD flask run --host=0.0.0.0 --port=7860
|