sghorbal commited on
Commit
d03a607
·
1 Parent(s): 54b112b

lighten the Docker image

Browse files
Files changed (2) hide show
  1. Dockerfile +16 -2
  2. requirements.txt +0 -1
Dockerfile CHANGED
@@ -1,10 +1,24 @@
1
- FROM tiangolo/uvicorn-gunicorn:python3.11
2
 
3
  COPY ./requirements.txt /tmp/requirements.txt
4
  COPY ./entrypoint.sh /tmp/entrypoint.sh
5
  COPY ./src /app/src
6
  COPY ./tests /app/tests
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  RUN pip install --no-cache-dir -r /tmp/requirements.txt
9
 
10
  WORKDIR /app
@@ -16,7 +30,7 @@ EXPOSE 8860
16
 
17
  # Health Check
18
  HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
19
- CMD [ "curl", "-f", "http://localhost:8860/check_health" ]
20
 
21
  # Create a non-root user 'appuser' and switch to this user
22
  RUN useradd --create-home appuser
 
1
+ FROM python:3.11-slim
2
 
3
  COPY ./requirements.txt /tmp/requirements.txt
4
  COPY ./entrypoint.sh /tmp/entrypoint.sh
5
  COPY ./src /app/src
6
  COPY ./tests /app/tests
7
 
8
+ RUN chmod +x /tmp/entrypoint.sh
9
+
10
+ # Avoid interactive prompts during package installation
11
+ ENV DEBIAN_FRONTEND=noninteractive
12
+
13
+ # Install gcc and curl for building and downloading packages
14
+ # Use --no-install-recommends to avoid installing unnecessary packages
15
+ # Clean up apt cache to reduce image size
16
+ # Use pip to install Python packages
17
+ RUN apt-get update && \
18
+ apt-get install -y --no-install-recommends gcc curl && \
19
+ pip install --upgrade pip && \
20
+ apt-get clean && rm -rf /var/lib/apt/lists/*
21
+
22
  RUN pip install --no-cache-dir -r /tmp/requirements.txt
23
 
24
  WORKDIR /app
 
30
 
31
  # Health Check
32
  HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
33
+ CMD [ "curl", "-f", "http://localhost:8860/check_health" ]
34
 
35
  # Create a non-root user 'appuser' and switch to this user
36
  RUN useradd --create-home appuser
requirements.txt CHANGED
@@ -3,5 +3,4 @@ fastapi
3
  sqlalchemy
4
  psycopg[binary]
5
  pytest
6
- appengine-python-standard>=1.0.0
7
  uvicorn
 
3
  sqlalchemy
4
  psycopg[binary]
5
  pytest
 
6
  uvicorn