codeby-hp commited on
Commit
1f0b7ad
·
verified ·
1 Parent(s): 024b706

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -28
Dockerfile CHANGED
@@ -1,28 +1,28 @@
1
- FROM python:3.10-slim
2
-
3
- WORKDIR /app
4
-
5
- # Install system dependencies
6
- RUN apt-get update && apt-get install -y --no-install-recommends \
7
- build-essential \
8
- && rm -rf /var/lib/apt/lists/*
9
-
10
- # Copy requirements first for better caching
11
- COPY fastapi_app/requirements.txt /app/
12
- RUN pip install --no-cache-dir -r requirements.txt
13
-
14
- # Copy application files
15
- COPY fastapi_app /app/
16
-
17
- # Create non-root user
18
- RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
19
- USER appuser
20
-
21
- EXPOSE 8000
22
-
23
- # Health check using urllib (built-in)
24
- HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
25
- CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
26
-
27
- # Run the application
28
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
 
1
+ FROM python:3.10-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Install system dependencies
6
+ RUN apt-get update && apt-get install -y --no-install-recommends \
7
+ build-essential \
8
+ && rm -rf /var/lib/apt/lists/*
9
+
10
+ # Copy requirements first for better caching
11
+ COPY fastapi_app/requirements.txt /app/
12
+ RUN pip install --no-cache-dir -r requirements.txt
13
+
14
+ # Copy application files
15
+ COPY fastapi_app /app/
16
+
17
+ # Create non-root user
18
+ RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
19
+ USER appuser
20
+
21
+ EXPOSE 7860
22
+
23
+ # Health check using urllib (built-in)
24
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
25
+ CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
26
+
27
+ # Run the application
28
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]