Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +16 -15
Dockerfile
CHANGED
|
@@ -1,31 +1,32 @@
|
|
| 1 |
FROM python:3.10
|
| 2 |
|
| 3 |
-
|
| 4 |
-
# Set up a new user named "user" with user ID 1000
|
| 5 |
RUN useradd -m -u 1000 user
|
| 6 |
|
| 7 |
-
#
|
| 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
|
| 15 |
WORKDIR $HOME/app
|
| 16 |
|
| 17 |
-
# Copy the
|
| 18 |
COPY --chown=user . $HOME/app
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
RUN pip3 install -r requirements.txt
|
| 23 |
|
| 24 |
-
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
| 29 |
USER user
|
| 30 |
|
| 31 |
-
|
|
|
|
|
|
| 1 |
FROM python:3.10
|
| 2 |
|
| 3 |
+
# Create a new user "user" with user ID 1000
|
|
|
|
| 4 |
RUN useradd -m -u 1000 user
|
| 5 |
|
| 6 |
+
# Set environment variables for the user's home and PATH
|
|
|
|
|
|
|
|
|
|
| 7 |
ENV HOME=/home/user \
|
| 8 |
PATH=/home/user/.local/bin:$PATH
|
| 9 |
|
| 10 |
+
# Set the working directory
|
| 11 |
WORKDIR $HOME/app
|
| 12 |
|
| 13 |
+
# Copy the application code and set the owner to "user"
|
| 14 |
COPY --chown=user . $HOME/app
|
| 15 |
|
| 16 |
+
# Switch to root to install dependencies and adjust permissions
|
| 17 |
+
USER root
|
| 18 |
+
|
| 19 |
+
# Install Python dependencies
|
| 20 |
RUN pip3 install -r requirements.txt
|
| 21 |
|
| 22 |
+
# Create the exports/charts directory (if not already present) and update its permissions
|
| 23 |
+
RUN mkdir -p $HOME/app/exports/charts && chmod -R 777 $HOME/app/exports/charts
|
| 24 |
|
| 25 |
+
# (Optional) Update permissions for the entire app directory if needed
|
| 26 |
+
RUN chmod -R 777 $HOME/app
|
| 27 |
+
|
| 28 |
+
# Switch back to the "user"
|
| 29 |
USER user
|
| 30 |
|
| 31 |
+
# Command to run the app
|
| 32 |
+
CMD ["python", "main.py"]
|