Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +21 -11
Dockerfile
CHANGED
@@ -1,28 +1,38 @@
|
|
1 |
FROM python:3.9
|
2 |
|
3 |
-
|
4 |
-
|
5 |
RUN useradd -m -u 1000 user
|
6 |
-
|
|
|
7 |
ENV HOME=/home/user \
|
8 |
-
|
9 |
|
10 |
-
|
|
|
11 |
|
12 |
-
|
|
|
13 |
|
|
|
14 |
COPY ./requirements.txt /code/requirements.txt
|
15 |
|
|
|
16 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
17 |
|
18 |
-
|
|
|
19 |
|
20 |
-
#
|
21 |
-
RUN touch /
|
22 |
|
23 |
# Change ownership of mentor.txt and temp_mentor.txt
|
24 |
-
RUN chown user:user /
|
25 |
|
26 |
-
|
|
|
|
|
|
|
|
|
27 |
|
|
|
28 |
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:7860", "--timeout", "300", "main:app"]
|
|
|
1 |
FROM python:3.9
|
2 |
|
3 |
+
# Create a user with UID 1000
|
|
|
4 |
RUN useradd -m -u 1000 user
|
5 |
+
|
6 |
+
# Set the working directory and user environment variables
|
7 |
ENV HOME=/home/user \
|
8 |
+
PATH=/home/user/.local/bin:$PATH
|
9 |
|
10 |
+
# Switch to the user's home directory
|
11 |
+
WORKDIR $HOME
|
12 |
|
13 |
+
# Copy the application files into the user's home directory
|
14 |
+
COPY --chown=user:user . $HOME
|
15 |
|
16 |
+
# Copy the requirements file to the /code directory
|
17 |
COPY ./requirements.txt /code/requirements.txt
|
18 |
|
19 |
+
# Install the Python dependencies
|
20 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
21 |
|
22 |
+
# Create a directory for cache and set permissions
|
23 |
+
RUN mkdir -p $HOME/.cache && chmod 777 $HOME/.cache
|
24 |
|
25 |
+
# Create the database file and set permissions
|
26 |
+
RUN touch $HOME/users.db && chmod 777 $HOME/users.db
|
27 |
|
28 |
# Change ownership of mentor.txt and temp_mentor.txt
|
29 |
+
RUN chown user:user $HOME/mentor.txt $HOME/temp_mentor.txt
|
30 |
|
31 |
+
# Switch back to the user
|
32 |
+
USER user
|
33 |
+
|
34 |
+
# Set the working directory for the application
|
35 |
+
WORKDIR $HOME/app
|
36 |
|
37 |
+
# Start the application using gunicorn
|
38 |
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:7860", "--timeout", "300", "main:app"]
|