Multistage build im Dockerfile von logic eingebaut. GCC, ... werden damit nicht in das finale Image kopiert.

This commit is contained in:
2026-06-25 17:15:15 +02:00
parent a77bc1b90b
commit 65a5f65511
5 changed files with 30 additions and 31 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
FROM python:3.11-slim
#FROM python:3.11-slim
FROM python:3.14-slim
WORKDIR /app
+23 -25
View File
@@ -1,35 +1,33 @@
# Basis-Image von Node-RED verwenden
FROM nodered/node-red:latest
# Zu root wechseln, um Pakete zu installieren
# ==========================================
# STAGE 1: Der Builder (Hier wird kompiliert)
# ==========================================
FROM nodered/node-red:latest AS builder
USER root
# Python und notwendige Tools installieren
#RUN apk add --no-update python3 py3-pip
RUN apk add --no-cache \
python3 \
py3-pip \
python3-dev \
gcc \
g++ \
musl-dev \
libffi-dev \
tzdata
# Compiler installieren, die Scout bemängelt
RUN apk add --no-cache python3 py3-pip python3-dev gcc g++ musl-dev libffi-dev
USER node-red
# Python-Pakete installieren (ldap3 separat via pip)
RUN pip install --no-cache-dir ldap3 --break-system-packages
# Falls Ihre Skripte spezielle Python-Libraries brauchen (z.B. pymongo, pandas)
# RUN pip3 install pymongo pandas --break-system-packages
RUN pip3 install --no-cache-dir --break-system-packages \
# Python-Pakete in einen separaten Ordner installieren
RUN pip3 install --no-cache-dir --break-system-packages --target=/var/tmp/python-packages \
pandas \
numpy \
ldap3
# Zurück zum Node-RED User für die Sicherheit
# ================================================
# STAGE 2: Das finale, saubere Image
# gcc, ... wird nicht in das finale Image kopiert.
# ================================================
FROM nodered/node-red:latest
USER root
# NUR die Laufzeitumgebung installieren (KEIN gcc, KEIN g++, KEIN musl-dev!)
RUN apk add --no-cache python3 py3-pip tzdata
# Die fertig kompilierten Pakete aus Stage 1 rüberkopieren
COPY --from=builder /var/tmp/python-packages /usr/lib/python3.11/site-packages
# Zurück zum sicheren Standard-User von Node-RED
USER node-red
# Installiere zusaetzliche Node-RED Module (moment fuer Zeitzonen, cron-plus fuer erweiterte Zeitsteuerung)
# Node-RED Module installieren
RUN npm install node-red-contrib-moment node-red-contrib-cron-plus
+3 -3
View File
@@ -27,7 +27,7 @@
"v": 4,
"tabs": [],
"primary": {
"width": 304,
"width": 280,
"top": {
"tabs": [
"info",
@@ -35,7 +35,7 @@
"config",
"context"
],
"height": 466,
"height": 468,
"hidden": false,
"active": "help"
},
@@ -53,7 +53,7 @@
"tabs": [
"explorer"
],
"height": 308,
"height": 310,
"hidden": false,
"active": "explorer"
},
@@ -1 +1 @@
size_by_ownergroup_and_number_of_copies_2026-06-25T14_46_23.json
size_by_ownergroup_and_number_of_copies_2026-06-25T14_49_44.json
File diff suppressed because one or more lines are too long