Spaces:
Sleeping
Sleeping
WebashalarForML
commited on
Update Dockerfile
Browse files- Dockerfile +22 -20
Dockerfile
CHANGED
@@ -10,42 +10,44 @@ ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
|
|
10 |
ENV HF_HOME=/app/.cache/huggingface
|
11 |
ENV MPLCONFIGDIR=/app/.cache/matplotlib
|
12 |
|
13 |
-
|
|
|
14 |
|
15 |
-
#
|
16 |
-
RUN chmod -R 777 /app/.cache
|
17 |
-
|
18 |
-
# Give write permissions to the /app directory
|
19 |
-
RUN chmod -R 777 /app
|
20 |
-
|
21 |
-
# Give write permissions to the /data directory
|
22 |
-
#RUN chmod -R 777 /app/data
|
23 |
-
|
24 |
-
# Create /app/logs directory and set permissions for logging
|
25 |
-
RUN mkdir -p /app/logs && chmod -R 777 /app/logs
|
26 |
-
|
27 |
-
# Set the working directory
|
28 |
-
WORKDIR /app
|
29 |
-
|
30 |
-
# Install system dependencies, including libgomp
|
31 |
RUN apt-get update && apt-get install -y \
|
32 |
libgl1-mesa-glx \
|
33 |
libgomp1 \
|
34 |
libglib2.0-0 \
|
35 |
&& rm -rf /var/lib/apt/lists/*
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
# Copy the requirements file into the container at /app
|
38 |
COPY requirements.txt /app/
|
39 |
|
40 |
# Install any needed packages specified in requirements.txt
|
41 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
42 |
|
43 |
-
# Create directories for session storage, uploads, and cache
|
44 |
-
RUN mkdir -p /app/flask_sessions /app/uploads /app/data /app/JSON /app/Models /tmp/matplotlib /tmp/transformers_cache && chmod -R 777 /app/flask_sessions /app/uploads /app/JSON /app/data /app/Models /tmp/matplotlib /tmp/transformers_cache
|
45 |
-
|
46 |
# Copy the rest of the application code to /app
|
47 |
COPY . /app/
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
# Expose the port that the app runs on
|
50 |
EXPOSE 7860
|
51 |
|
|
|
10 |
ENV HF_HOME=/app/.cache/huggingface
|
11 |
ENV MPLCONFIGDIR=/app/.cache/matplotlib
|
12 |
|
13 |
+
# Create cache directories and assign permissions
|
14 |
+
RUN mkdir -p /app/.cache/huggingface /app/.cache/matplotlib
|
15 |
|
16 |
+
# Install system dependencies
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
RUN apt-get update && apt-get install -y \
|
18 |
libgl1-mesa-glx \
|
19 |
libgomp1 \
|
20 |
libglib2.0-0 \
|
21 |
&& rm -rf /var/lib/apt/lists/*
|
22 |
|
23 |
+
# Create a non-root user and group
|
24 |
+
RUN groupadd -r appgroup && useradd -r -g appgroup appuser
|
25 |
+
|
26 |
+
# Create necessary directories
|
27 |
+
RUN mkdir -p /app/flask_sessions /app/uploads /app/data /app/JSON /app/Models /app/logs /tmp/matplotlib /tmp/transformers_cache
|
28 |
+
|
29 |
+
# Set permissions for app directories
|
30 |
+
RUN chown -R appuser:appgroup /app /tmp/matplotlib /tmp/transformers_cache \
|
31 |
+
&& chmod -R 755 /app /tmp/matplotlib /tmp/transformers_cache
|
32 |
+
|
33 |
+
# Set working directory
|
34 |
+
WORKDIR /app
|
35 |
+
|
36 |
# Copy the requirements file into the container at /app
|
37 |
COPY requirements.txt /app/
|
38 |
|
39 |
# Install any needed packages specified in requirements.txt
|
40 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
41 |
|
|
|
|
|
|
|
42 |
# Copy the rest of the application code to /app
|
43 |
COPY . /app/
|
44 |
|
45 |
+
# Ensure app user owns the app directory
|
46 |
+
RUN chown -R appuser:appgroup /app
|
47 |
+
|
48 |
+
# Switch to non-root user
|
49 |
+
USER appuser
|
50 |
+
|
51 |
# Expose the port that the app runs on
|
52 |
EXPOSE 7860
|
53 |
|