3v324v23 commited on
Commit
9cf2270
·
1 Parent(s): 667fd5f

測試使用copilot建議的Dockerfile

Browse files
Files changed (2) hide show
  1. Dockerfile +17 -4
  2. Dockerfile.old +11 -0
Dockerfile CHANGED
@@ -1,11 +1,24 @@
1
- FROM python:3.12.2
 
 
 
 
 
 
2
 
3
  WORKDIR /code
4
 
5
- COPY ./requirements.txt /code/requirements.txt
 
6
 
7
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
 
9
- COPY . .
 
 
 
 
 
 
10
 
11
- CMD ["gunicorn","-b", "0.0.0.0:7860", "gpt4:app"]
 
1
+ FROM python:3.12.10-slim
2
+
3
+ # Update packages and install curl for health check
4
+ RUN apt-get update && apt-get upgrade -y && apt-get install -y curl=7.74.0-1.3+deb11u3 && rm -rf /var/lib/apt/lists/*
5
+
6
+ # Create a non-root user
7
+ RUN useradd --create-home appuser
8
 
9
  WORKDIR /code
10
 
11
+ # Copy files with proper ownership
12
+ COPY --chown=appuser:appuser ./requirements.txt /code/requirements.txt
13
 
14
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
15
 
16
+ COPY --chown=appuser:appuser . .
17
+
18
+ # Add HEALTHCHECK instruction
19
+ HEALTHCHECK --interval=30s --timeout=3s CMD curl -f http://localhost:7860/ || exit 1
20
+
21
+ # Switch to non-root user
22
+ USER appuser
23
 
24
+ CMD ["gunicorn", "-b", "0.0.0.0:7860", "gpt4:app"]
Dockerfile.old ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.12.2
2
+
3
+ WORKDIR /code
4
+
5
+ COPY ./requirements.txt /code/requirements.txt
6
+
7
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
+
9
+ COPY . .
10
+
11
+ CMD ["gunicorn","-b", "0.0.0.0:7860", "gpt4:app"]