Fred808 commited on
Commit
165bcd1
·
verified ·
1 Parent(s): 73e4339

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +58 -58
Dockerfile CHANGED
@@ -1,58 +1,58 @@
1
- # Use Python 3.11 slim as base image
2
- FROM python:3.11-slim as builder
3
-
4
- # Set working directory
5
- WORKDIR /app
6
-
7
- # Install system dependencies
8
- RUN apt-get update && apt-get install -y \
9
- gcc \
10
- libpq-dev \
11
- && rm -rf /var/lib/apt/lists/*
12
-
13
- # Install Python dependencies
14
- COPY requirements.txt .
15
- RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt
16
-
17
- # Final stage
18
- FROM python:3.11-slim
19
-
20
- # Create non-root user
21
- RUN useradd -m appuser
22
-
23
- # Set working directory
24
- WORKDIR /app
25
-
26
- # Install system dependencies
27
- RUN apt-get update && apt-get install -y \
28
- libpq5 \
29
- && rm -rf /var/lib/apt/lists/*
30
-
31
- # Copy wheels from builder stage
32
- COPY --from=builder /app/wheels /wheels
33
- COPY --from=builder /app/requirements.txt .
34
-
35
- # Install Python packages
36
- RUN pip install --no-cache /wheels/*
37
-
38
- # Copy application code
39
- COPY ./app app/
40
- COPY ./alembic.ini .
41
- COPY ./alembic alembic/
42
-
43
- # Create necessary directories with proper permissions
44
- RUN mkdir -p /app/logs /app/uploads/images /app/uploads/documents /app/backups && \
45
- chown -R appuser:appuser /app
46
-
47
- # Switch to non-root user
48
- USER appuser
49
-
50
- # Set environment variables
51
- ENV PYTHONPATH=/app \
52
- PYTHONUNBUFFERED=1
53
-
54
- # Expose port
55
- EXPOSE 8000
56
-
57
- # Start the application with uvicorn
58
- CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
 
1
+ # Use Python 3.11 slim as base image
2
+ FROM python:3.11-slim as builder
3
+
4
+ # Set working directory
5
+ WORKDIR /app
6
+
7
+ # Install system dependencies
8
+ RUN apt-get update && apt-get install -y \
9
+ gcc \
10
+ libpq-dev \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Install Python dependencies
14
+ COPY requirements.txt .
15
+ RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt
16
+
17
+ # Final stage
18
+ FROM python:3.11-slim
19
+
20
+ # Create non-root user
21
+ RUN useradd -m appuser
22
+
23
+ # Set working directory
24
+ WORKDIR /app
25
+
26
+ # Install system dependencies
27
+ RUN apt-get update && apt-get install -y \
28
+ libpq5 \
29
+ && rm -rf /var/lib/apt/lists/*
30
+
31
+ # Copy wheels from builder stage
32
+ COPY --from=builder /app/wheels /wheels
33
+ COPY --from=builder /app/requirements.txt .
34
+
35
+ # Install Python packages
36
+ RUN pip install --no-cache /wheels/*
37
+
38
+ # Copy application code
39
+ COPY ./app app/
40
+ COPY ./alembic.ini .
41
+ COPY ./alembic alembic/
42
+
43
+ # Create necessary directories with proper permissions
44
+ RUN mkdir -p /app/logs /app/uploads/images /app/uploads/documents /app/backups && \
45
+ chown -R appuser:appuser /app
46
+
47
+ # Switch to non-root user
48
+ USER appuser
49
+
50
+ # Set environment variables
51
+ ENV PYTHONPATH=/app \
52
+ PYTHONUNBUFFERED=1
53
+
54
+ # Expose port required by Hugging Face
55
+ EXPOSE 7860
56
+
57
+ # Start the application with uvicorn on port 7860
58
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]