Spaces:
Running
Running
tmzh
commited on
Commit
•
e04cdba
1
Parent(s):
b6d6046
add Dockerfile changes
Browse files- Dockerfile +17 -7
- app.py +1 -1
Dockerfile
CHANGED
@@ -1,20 +1,30 @@
|
|
1 |
# Use an official Python runtime as a parent image
|
2 |
FROM python:3.8-slim-buster
|
3 |
|
4 |
-
# Set
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Copy the current directory contents into the container at /app
|
8 |
ADD . /app
|
9 |
|
10 |
-
#
|
11 |
-
RUN pip install --no-cache-dir
|
|
|
|
|
|
|
12 |
|
13 |
# Make port 7860 available to the world outside this container
|
14 |
EXPOSE 7860
|
15 |
|
16 |
-
# Define environment variable
|
17 |
-
ENV NAME World
|
18 |
-
|
19 |
# Run app.py when the container launches
|
20 |
CMD ["python", "app.py"]
|
|
|
1 |
# Use an official Python runtime as a parent image
|
2 |
FROM python:3.8-slim-buster
|
3 |
|
4 |
+
# Set up a new user named "user" with user ID 1000
|
5 |
+
RUN useradd -m -u 1000 user
|
6 |
+
|
7 |
+
# Switch to the "user" user
|
8 |
+
USER user
|
9 |
+
|
10 |
+
# Set home to the user's home directory
|
11 |
+
ENV HOME=/home/user \
|
12 |
+
PATH=/home/user/.local/bin:$PATH
|
13 |
+
|
14 |
+
# Set the working directory to the user's home directory
|
15 |
+
WORKDIR $HOME/app
|
16 |
|
17 |
# Copy the current directory contents into the container at /app
|
18 |
ADD . /app
|
19 |
|
20 |
+
# Try and run pip command after setting the user with `USER user` to avoid permission issues with Python
|
21 |
+
RUN pip install --no-cache-dir --upgrade pip
|
22 |
+
|
23 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
24 |
+
COPY --chown=user . $HOME/app
|
25 |
|
26 |
# Make port 7860 available to the world outside this container
|
27 |
EXPOSE 7860
|
28 |
|
|
|
|
|
|
|
29 |
# Run app.py when the container launches
|
30 |
CMD ["python", "app.py"]
|
app.py
CHANGED
@@ -96,4 +96,4 @@ def query():
|
|
96 |
|
97 |
|
98 |
if __name__ == '__main__':
|
99 |
-
app.run(host='0.0.0.0', port=
|
|
|
96 |
|
97 |
|
98 |
if __name__ == '__main__':
|
99 |
+
app.run(host='0.0.0.0', port=7860)
|