Parcourir la source

fix intermitten failure on rpi3b & 4

tuanchris il y a 7 mois
Parent
commit
5fa0579e0b
2 fichiers modifiés avec 15 ajouts et 22 suppressions
  1. 14 21
      Dockerfile
  2. 1 1
      requirements.txt

+ 14 - 21
Dockerfile

@@ -1,29 +1,22 @@
-# Use an official Python runtime as a parent image
-FROM python:3.9-slim
+FROM --platform=$TARGETPLATFORM python:3.11-slim-bookworm
 
 
-# Set the working directory in the container
-WORKDIR /app
+# Faster, repeatable builds
+ENV PYTHONDONTWRITEBYTECODE=1 \
+    PYTHONUNBUFFERED=1 \
+    PIP_NO_CACHE_DIR=1 \
+    PIP_DISABLE_PIP_VERSION_CHECK=1
 
 
-# Copy the current directory contents into the container at /app
-COPY . /app
+WORKDIR /app
 
 
-# Install required system packages
+COPY requirements.txt ./
 RUN apt-get update && apt-get install -y --no-install-recommends \
 RUN apt-get update && apt-get install -y --no-install-recommends \
-    gcc \
-    avrdude \
-    wget \
-    unzip \
-    git \
+        gcc libjpeg-dev zlib1g-dev git \
+    && pip install --upgrade pip \
+    && pip install --no-cache-dir -r requirements.txt \
+    && apt-get purge -y gcc \
     && rm -rf /var/lib/apt/lists/*
     && rm -rf /var/lib/apt/lists/*
 
 
-# Install any needed packages specified in requirements.txt
-RUN pip install --no-cache-dir -r requirements.txt
+COPY . .
 
 
-# Expose the port the app runs on
 EXPOSE 8080
 EXPOSE 8080
-
-# Define environment variable
-ENV FLASK_ENV=development
-
-# Run the command to start the app
-CMD ["python", "app.py"]
+CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080"]

+ 1 - 1
requirements.txt

@@ -4,7 +4,7 @@ paho-mqtt>=1.6.1
 python-dotenv>=1.0.0
 python-dotenv>=1.0.0
 websocket-client>=1.6.1
 websocket-client>=1.6.1
 fastapi>=0.100.0
 fastapi>=0.100.0
-uvicorn[standard]>=0.23.0
+uvicorn>=0.23.0
 pydantic>=2.0.0
 pydantic>=2.0.0
 jinja2>=3.1.2
 jinja2>=3.1.2
 aiofiles>=23.1.0
 aiofiles>=23.1.0