Spaces:
Running
Running
amaye15
commited on
Commit
·
db08d02
1
Parent(s):
32d4248
Debug - Docker
Browse files- Dockerfile +83 -2
Dockerfile
CHANGED
@@ -1,3 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Stage 1: Build stage
|
2 |
FROM python:3.11-slim as builder
|
3 |
|
@@ -6,7 +77,7 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
6 |
PYTHONUNBUFFERED=1 \
|
7 |
PATH="/root/.local/bin:$PATH"
|
8 |
|
9 |
-
# Install system dependencies (curl
|
10 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
11 |
curl \
|
12 |
ca-certificates \
|
@@ -25,8 +96,10 @@ RUN useradd -m -u 1000 user
|
|
25 |
# Set the working directory
|
26 |
WORKDIR /app
|
27 |
|
28 |
-
# Create a virtual environment
|
29 |
RUN uv venv /opt/venv
|
|
|
|
|
30 |
|
31 |
# Update PATH to include the virtual environment's bin directory
|
32 |
ENV PATH="/opt/venv/bin:$PATH"
|
@@ -43,6 +116,11 @@ COPY --chown=user . /app
|
|
43 |
# Stage 2: Runtime stage
|
44 |
FROM python:3.11-slim
|
45 |
|
|
|
|
|
|
|
|
|
|
|
46 |
# Create a non-root user
|
47 |
RUN useradd -m -u 1000 user
|
48 |
USER user
|
@@ -60,6 +138,9 @@ COPY --from=builder --chown=user /opt/venv /opt/venv
|
|
60 |
# Copy only the necessary files from the builder stage
|
61 |
COPY --from=builder --chown=user /app /app
|
62 |
|
|
|
|
|
|
|
63 |
# Expose the port the app runs on
|
64 |
EXPOSE 7860
|
65 |
|
|
|
1 |
+
# # Stage 1: Build stage
|
2 |
+
# FROM python:3.11-slim as builder
|
3 |
+
|
4 |
+
# # Set environment variables
|
5 |
+
# ENV PYTHONDONTWRITEBYTECODE=1 \
|
6 |
+
# PYTHONUNBUFFERED=1 \
|
7 |
+
# PATH="/root/.local/bin:$PATH"
|
8 |
+
|
9 |
+
# # Install system dependencies (curl and ca-certificates for uv installer)
|
10 |
+
# RUN apt-get update && apt-get install -y --no-install-recommends \
|
11 |
+
# curl \
|
12 |
+
# ca-certificates \
|
13 |
+
# && rm -rf /var/lib/apt/lists/*
|
14 |
+
|
15 |
+
# # Install uv using the official installer
|
16 |
+
# RUN curl -sSfL https://astral.sh/uv/install.sh | sh
|
17 |
+
|
18 |
+
# # Verify uv is installed and available
|
19 |
+
# RUN uv --version
|
20 |
+
|
21 |
+
# # Create a non-root user
|
22 |
+
# RUN useradd -m -u 1000 user
|
23 |
+
|
24 |
+
# # Set the working directory
|
25 |
+
# WORKDIR /app
|
26 |
+
|
27 |
+
# # Create a virtual environment
|
28 |
+
# RUN uv venv /opt/venv
|
29 |
+
|
30 |
+
# # Update PATH to include the virtual environment's bin directory
|
31 |
+
# ENV PATH="/opt/venv/bin:$PATH"
|
32 |
+
|
33 |
+
# # Copy only the requirements file first to leverage Docker cache
|
34 |
+
# COPY --chown=user ./requirements.txt /app/requirements.txt
|
35 |
+
|
36 |
+
# # Install dependencies into the virtual environment using uv
|
37 |
+
# RUN uv pip install --no-cache-dir -r requirements.txt
|
38 |
+
|
39 |
+
# # Copy the rest of the application code
|
40 |
+
# COPY --chown=user . /app
|
41 |
+
|
42 |
+
# # Stage 2: Runtime stage
|
43 |
+
# FROM python:3.11-slim
|
44 |
+
|
45 |
+
# # Create a non-root user
|
46 |
+
# RUN useradd -m -u 1000 user
|
47 |
+
# USER user
|
48 |
+
|
49 |
+
# # Set environment variables
|
50 |
+
# ENV PATH="/opt/venv/bin:$PATH" \
|
51 |
+
# PYTHONUNBUFFERED=1
|
52 |
+
|
53 |
+
# # Set the working directory
|
54 |
+
# WORKDIR /app
|
55 |
+
|
56 |
+
# # Copy the virtual environment from the builder stage
|
57 |
+
# COPY --from=builder --chown=user /opt/venv /opt/venv
|
58 |
+
|
59 |
+
# # Copy only the necessary files from the builder stage
|
60 |
+
# COPY --from=builder --chown=user /app /app
|
61 |
+
|
62 |
+
# # Expose the port the app runs on
|
63 |
+
# EXPOSE 7860
|
64 |
+
|
65 |
+
# # Health check to ensure the application is running
|
66 |
+
# HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
67 |
+
# CMD curl -f http://localhost:7860/health || exit 1
|
68 |
+
|
69 |
+
# # Command to run the application with hot reloading
|
70 |
+
# CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]
|
71 |
+
|
72 |
# Stage 1: Build stage
|
73 |
FROM python:3.11-slim as builder
|
74 |
|
|
|
77 |
PYTHONUNBUFFERED=1 \
|
78 |
PATH="/root/.local/bin:$PATH"
|
79 |
|
80 |
+
# Install system dependencies (curl, ca-certificates, and libgomp)
|
81 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
82 |
curl \
|
83 |
ca-certificates \
|
|
|
96 |
# Set the working directory
|
97 |
WORKDIR /app
|
98 |
|
99 |
+
# Create a virtual environment and install pip
|
100 |
RUN uv venv /opt/venv
|
101 |
+
RUN /opt/venv/bin/python -m ensurepip
|
102 |
+
RUN /opt/venv/bin/python -m pip install --upgrade pip
|
103 |
|
104 |
# Update PATH to include the virtual environment's bin directory
|
105 |
ENV PATH="/opt/venv/bin:$PATH"
|
|
|
116 |
# Stage 2: Runtime stage
|
117 |
FROM python:3.11-slim
|
118 |
|
119 |
+
# Install libgomp in the runtime stage
|
120 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
121 |
+
libgomp1 \
|
122 |
+
&& rm -rf /var/lib/apt/lists/*
|
123 |
+
|
124 |
# Create a non-root user
|
125 |
RUN useradd -m -u 1000 user
|
126 |
USER user
|
|
|
138 |
# Copy only the necessary files from the builder stage
|
139 |
COPY --from=builder --chown=user /app /app
|
140 |
|
141 |
+
# Debugging step: Verify installed packages
|
142 |
+
RUN /opt/venv/bin/python -m pip list
|
143 |
+
|
144 |
# Expose the port the app runs on
|
145 |
EXPOSE 7860
|
146 |
|