Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +15 -21
Dockerfile
CHANGED
|
@@ -1,34 +1,28 @@
|
|
| 1 |
FROM python:3.10
|
| 2 |
|
| 3 |
-
### Set up user with permissions
|
| 4 |
# Set up a new user named "user" with user ID 1000
|
| 5 |
RUN useradd -m -u 1000 user
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 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
|
| 18 |
-
COPY
|
| 19 |
-
|
| 20 |
-
### Set up app-specific content
|
| 21 |
-
COPY requirements.txt requirements.txt
|
| 22 |
RUN pip3 install -r requirements.txt
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
USER root
|
| 28 |
-
RUN chmod 777 ~/app/*
|
| 29 |
USER user
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
|
|
|
|
| 33 |
|
| 34 |
CMD ["python", "main.py"]
|
|
|
|
| 1 |
FROM python:3.10
|
| 2 |
|
|
|
|
| 3 |
# Set up a new user named "user" with user ID 1000
|
| 4 |
RUN useradd -m -u 1000 user
|
| 5 |
|
| 6 |
+
# Set working directory
|
| 7 |
+
WORKDIR /home/user/app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
# Copy requirements first for better caching
|
| 10 |
+
COPY requirements.txt .
|
|
|
|
|
|
|
|
|
|
| 11 |
RUN pip3 install -r requirements.txt
|
| 12 |
|
| 13 |
+
# Copy the rest of the application
|
| 14 |
+
COPY --chown=user:user . .
|
| 15 |
+
|
| 16 |
+
# Create the exports/charts directory and set permissions
|
| 17 |
+
RUN mkdir -p exports/charts && \
|
| 18 |
+
chmod -R 777 exports/charts && \
|
| 19 |
+
chmod -R 777 .
|
| 20 |
|
| 21 |
+
# Switch to the "user" user
|
|
|
|
|
|
|
| 22 |
USER user
|
| 23 |
|
| 24 |
+
# Set environment variables
|
| 25 |
+
ENV HOME=/home/user \
|
| 26 |
+
PATH=/home/user/.local/bin:$PATH
|
| 27 |
|
| 28 |
CMD ["python", "main.py"]
|