Spaces:
Sleeping
Sleeping
Create Dockerfile
Browse files- Dockerfile +43 -0
Dockerfile
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use the official Python image from the Docker library
|
2 |
+
FROM python:3.10-slim
|
3 |
+
|
4 |
+
# Set the working directory
|
5 |
+
WORKDIR /app
|
6 |
+
|
7 |
+
# Install system dependencies
|
8 |
+
RUN apt-get update && apt-get install -y \
|
9 |
+
git \
|
10 |
+
libgl1-mesa-glx \
|
11 |
+
libglib2.0-0 \
|
12 |
+
&& rm -rf /var/lib/apt/lists/*
|
13 |
+
|
14 |
+
# Set environment variables
|
15 |
+
ENV TRANSFORMERS_CACHE=/tmp/transformers_cache
|
16 |
+
ENV MPLCONFIGDIR=/tmp/.matplotlib
|
17 |
+
|
18 |
+
# Set up a new user named "user" with user ID 1000
|
19 |
+
RUN useradd -m -u 1000 user
|
20 |
+
|
21 |
+
# Switch to the "user" user
|
22 |
+
USER user
|
23 |
+
|
24 |
+
# Set home to the user's home directory
|
25 |
+
ENV HOME=/home/user \
|
26 |
+
PATH=/home/user/.local/bin:$PATH \
|
27 |
+
PYTHONPATH=$HOME/app \
|
28 |
+
PYTHONUNBUFFERED=1
|
29 |
+
|
30 |
+
# Set the working directory to the user's home directory
|
31 |
+
WORKDIR $HOME/app
|
32 |
+
|
33 |
+
# Copy the application code into the container and set the owner to the user
|
34 |
+
COPY --chown=user . $HOME/app
|
35 |
+
|
36 |
+
# Install Python dependencies
|
37 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
38 |
+
|
39 |
+
# Expose the port the app runs on
|
40 |
+
EXPOSE 7860
|
41 |
+
|
42 |
+
# Command to run the application
|
43 |
+
CMD ["python", "app.py"]
|